Documentation
¶
Index ¶
- type CloudSQLConfig
- type DBTX
- type ErrorSourcesEnum
- type InsertPocketSessionParams
- type InsertRelaysParams
- type InsertServiceRecordsParams
- type NullErrorSourcesEnum
- type PocketSession
- type PortalRegion
- type PostgresDriver
- func (d *PostgresDriver) ReadRelay(ctx context.Context, relayID int) (types.Relay, error)
- func (d *PostgresDriver) ReadServiceRecord(ctx context.Context, serviceRecordID int) (types.ServiceRecord, error)
- func (d *PostgresDriver) WriteRegion(ctx context.Context, region types.PortalRegion) error
- func (d *PostgresDriver) WriteRelay(ctx context.Context, relay types.Relay) error
- func (d *PostgresDriver) WriteRelays(ctx context.Context, relays []*types.Relay) error
- func (d *PostgresDriver) WriteServiceRecord(ctx context.Context, serviceRecord types.ServiceRecord) error
- func (d *PostgresDriver) WriteServiceRecords(ctx context.Context, serviceRecords []*types.ServiceRecord) error
- func (d *PostgresDriver) WriteSession(ctx context.Context, session types.PocketSession) error
- type Queries
- func (q *Queries) InsertPocketSession(ctx context.Context, arg InsertPocketSessionParams) error
- func (q *Queries) InsertPortalRegion(ctx context.Context, portalRegionName string) error
- func (q *Queries) InsertRelays(ctx context.Context, arg []InsertRelaysParams) (int64, error)
- func (q *Queries) InsertServiceRecords(ctx context.Context, arg []InsertServiceRecordsParams) (int64, error)
- func (q *Queries) SelectRelay(ctx context.Context, id int64) (SelectRelayRow, error)
- func (q *Queries) SelectServiceRecord(ctx context.Context, id int64) (ServiceRecord, error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type Relay
- type SelectRelayRow
- type ServiceRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudSQLConfig ¶ added in v1.22.0
type CloudSQLConfig struct { DBUser string DBPassword string DBName string InstanceConnectionName string PublicIP string PrivateIP string }
The PostgresDriver struct satisfies the Driver interface which defines all database driver methods
type DBTX ¶
type DBTX interface { Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error) Query(context.Context, string, ...interface{}) (pgx.Rows, error) QueryRow(context.Context, string, ...interface{}) pgx.Row CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) }
type ErrorSourcesEnum ¶ added in v1.5.0
type ErrorSourcesEnum string
const ( ErrorSourcesEnumInternal ErrorSourcesEnum = "internal" ErrorSourcesEnumExternal ErrorSourcesEnum = "external" )
func (*ErrorSourcesEnum) Scan ¶ added in v1.5.0
func (e *ErrorSourcesEnum) Scan(src interface{}) error
type InsertRelaysParams ¶ added in v1.23.0
type InsertRelaysParams struct { PoktChainID string `json:"poktChainId"` EndpointID string `json:"endpointId"` SessionKey string `json:"sessionKey"` ProtocolAppPublicKey string `json:"protocolAppPublicKey"` RelaySourceUrl pgtype.Text `json:"relaySourceUrl"` PoktNodeAddress pgtype.Text `json:"poktNodeAddress"` PoktNodeDomain pgtype.Text `json:"poktNodeDomain"` PoktNodePublicKey pgtype.Text `json:"poktNodePublicKey"` RelayStartDatetime pgtype.Timestamp `json:"relayStartDatetime"` RelayReturnDatetime pgtype.Timestamp `json:"relayReturnDatetime"` IsError bool `json:"isError"` ErrorCode pgtype.Int4 `json:"errorCode"` ErrorName pgtype.Text `json:"errorName"` ErrorMessage pgtype.Text `json:"errorMessage"` ErrorSource NullErrorSourcesEnum `json:"errorSource"` ErrorType pgtype.Text `json:"errorType"` RelayRoundtripTime float64 `json:"relayRoundtripTime"` RelayChainMethodIds string `json:"relayChainMethodIds"` RelayDataSize int32 `json:"relayDataSize"` RelayPortalTripTime float64 `json:"relayPortalTripTime"` RelayNodeTripTime float64 `json:"relayNodeTripTime"` RelayUrlIsPublicEndpoint bool `json:"relayUrlIsPublicEndpoint"` PortalRegionName string `json:"portalRegionName"` IsAltruistRelay bool `json:"isAltruistRelay"` IsUserRelay bool `json:"isUserRelay"` RequestID string `json:"requestId"` PoktTxID pgtype.Text `json:"poktTxId"` GigastakeAppID pgtype.Text `json:"gigastakeAppId"` CreatedAt pgtype.Timestamp `json:"createdAt"` UpdatedAt pgtype.Timestamp `json:"updatedAt"` BlockingPlugin pgtype.Text `json:"blockingPlugin"` }
type InsertServiceRecordsParams ¶ added in v1.23.0
type InsertServiceRecordsParams struct { NodePublicKey string `json:"nodePublicKey"` PoktChainID string `json:"poktChainId"` SessionKey string `json:"sessionKey"` RequestID string `json:"requestId"` PortalRegionName string `json:"portalRegionName"` Latency float64 `json:"latency"` Tickets int32 `json:"tickets"` Result string `json:"result"` Available bool `json:"available"` Successes int32 `json:"successes"` Failures int32 `json:"failures"` P90SuccessLatency float64 `json:"p90SuccessLatency"` MedianSuccessLatency float64 `json:"medianSuccessLatency"` WeightedSuccessLatency float64 `json:"weightedSuccessLatency"` SuccessRate float64 `json:"successRate"` CreatedAt pgtype.Timestamp `json:"createdAt"` UpdatedAt pgtype.Timestamp `json:"updatedAt"` }
type NullErrorSourcesEnum ¶ added in v1.5.0
type NullErrorSourcesEnum struct { ErrorSourcesEnum ErrorSourcesEnum `json:"errorSourcesEnum"` Valid bool `json:"valid"` // Valid is true if ErrorSourcesEnum is not NULL }
func (*NullErrorSourcesEnum) Scan ¶ added in v1.5.0
func (ns *NullErrorSourcesEnum) Scan(value interface{}) error
Scan implements the Scanner interface.
type PocketSession ¶
type PortalRegion ¶
type PortalRegion struct {
PortalRegionName string `json:"portalRegionName"`
}
type PostgresDriver ¶
type PostgresDriver struct { *Queries // contains filtered or unexported fields }
The PostgresDriver struct satisfies the Driver interface which defines all database driver methods
func NewCloudSQLPostgresDriver ¶ added in v1.22.0
func NewCloudSQLPostgresDriver(options CloudSQLConfig) (*PostgresDriver, func() error, error)
NewCloudSQLPostgresDriver - Creates a pool of connections to a Cloud SQL instance using the provided CloudSQLConfig. - Uses the Cloud SQL Connector for Go and pgx for the connections. - Establishes a dialer with the desired options (like using private IP). - For each acquired connection from the pool, custom enum types are registered.. - It is important to note that this function will return an error if both PublicIP and PrivateIP are provided in the CloudSQLConfig.
func NewPostgresDriver ¶
func NewPostgresDriver(connectionString string) (*PostgresDriver, func() error, error)
NewPostgresDriver - Creates a pool of connections to a PostgreSQL database using the provided connection string. - Parses the connection string into a pgx pool configuration object. - For each acquired connection from the pool, custom enum types are registered. - Returns the established connection pool. - This function is ideal for creating multiple reusable connections to a PostgreSQL database, particularly useful for handling multiple concurrent database operations.
func (*PostgresDriver) ReadServiceRecord ¶ added in v1.7.0
func (d *PostgresDriver) ReadServiceRecord(ctx context.Context, serviceRecordID int) (types.ServiceRecord, error)
func (*PostgresDriver) WriteRegion ¶
func (d *PostgresDriver) WriteRegion(ctx context.Context, region types.PortalRegion) error
func (*PostgresDriver) WriteRelay ¶
func (*PostgresDriver) WriteRelays ¶ added in v1.2.0
func (*PostgresDriver) WriteServiceRecord ¶ added in v1.7.0
func (d *PostgresDriver) WriteServiceRecord(ctx context.Context, serviceRecord types.ServiceRecord) error
func (*PostgresDriver) WriteServiceRecords ¶ added in v1.7.0
func (d *PostgresDriver) WriteServiceRecords(ctx context.Context, serviceRecords []*types.ServiceRecord) error
func (*PostgresDriver) WriteSession ¶
func (d *PostgresDriver) WriteSession(ctx context.Context, session types.PocketSession) error
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) InsertPocketSession ¶
func (q *Queries) InsertPocketSession(ctx context.Context, arg InsertPocketSessionParams) error
func (*Queries) InsertPortalRegion ¶
func (*Queries) InsertRelays ¶ added in v1.23.0
func (*Queries) InsertServiceRecords ¶ added in v1.23.0
func (*Queries) SelectRelay ¶
func (*Queries) SelectServiceRecord ¶ added in v1.7.0
type Relay ¶
type Relay struct { ID int64 `json:"id"` PoktChainID string `json:"poktChainId"` EndpointID string `json:"endpointId"` SessionKey string `json:"sessionKey"` ProtocolAppPublicKey string `json:"protocolAppPublicKey"` RelaySourceUrl pgtype.Text `json:"relaySourceUrl"` PoktNodeAddress pgtype.Text `json:"poktNodeAddress"` PoktNodeDomain pgtype.Text `json:"poktNodeDomain"` PoktNodePublicKey pgtype.Text `json:"poktNodePublicKey"` RelayStartDatetime pgtype.Timestamp `json:"relayStartDatetime"` RelayReturnDatetime pgtype.Timestamp `json:"relayReturnDatetime"` IsError bool `json:"isError"` ErrorCode pgtype.Int4 `json:"errorCode"` ErrorName pgtype.Text `json:"errorName"` ErrorMessage pgtype.Text `json:"errorMessage"` ErrorSource NullErrorSourcesEnum `json:"errorSource"` ErrorType pgtype.Text `json:"errorType"` RelayRoundtripTime float64 `json:"relayRoundtripTime"` RelayChainMethodIds string `json:"relayChainMethodIds"` RelayDataSize int32 `json:"relayDataSize"` RelayPortalTripTime float64 `json:"relayPortalTripTime"` RelayNodeTripTime float64 `json:"relayNodeTripTime"` RelayUrlIsPublicEndpoint bool `json:"relayUrlIsPublicEndpoint"` PortalRegionName string `json:"portalRegionName"` IsAltruistRelay bool `json:"isAltruistRelay"` IsUserRelay bool `json:"isUserRelay"` RequestID string `json:"requestId"` PoktTxID pgtype.Text `json:"poktTxId"` GigastakeAppID pgtype.Text `json:"gigastakeAppId"` CreatedAt pgtype.Timestamp `json:"createdAt"` UpdatedAt pgtype.Timestamp `json:"updatedAt"` BlockingPlugin pgtype.Text `json:"blockingPlugin"` }
type SelectRelayRow ¶
type SelectRelayRow struct { ID int64 `json:"id"` PoktChainID string `json:"poktChainId"` EndpointID string `json:"endpointId"` SessionKey string `json:"sessionKey"` ProtocolAppPublicKey string `json:"protocolAppPublicKey"` RelaySourceUrl pgtype.Text `json:"relaySourceUrl"` PoktNodeAddress pgtype.Text `json:"poktNodeAddress"` PoktNodeDomain pgtype.Text `json:"poktNodeDomain"` PoktNodePublicKey pgtype.Text `json:"poktNodePublicKey"` RelayStartDatetime pgtype.Timestamp `json:"relayStartDatetime"` RelayReturnDatetime pgtype.Timestamp `json:"relayReturnDatetime"` IsError bool `json:"isError"` ErrorCode pgtype.Int4 `json:"errorCode"` ErrorName pgtype.Text `json:"errorName"` ErrorMessage pgtype.Text `json:"errorMessage"` ErrorSource NullErrorSourcesEnum `json:"errorSource"` ErrorType pgtype.Text `json:"errorType"` RelayRoundtripTime float64 `json:"relayRoundtripTime"` RelayChainMethodIds string `json:"relayChainMethodIds"` RelayDataSize int32 `json:"relayDataSize"` RelayPortalTripTime float64 `json:"relayPortalTripTime"` RelayNodeTripTime float64 `json:"relayNodeTripTime"` RelayUrlIsPublicEndpoint bool `json:"relayUrlIsPublicEndpoint"` IsAltruistRelay bool `json:"isAltruistRelay"` IsUserRelay bool `json:"isUserRelay"` RequestID string `json:"requestId"` PoktTxID pgtype.Text `json:"poktTxId"` GigastakeAppID pgtype.Text `json:"gigastakeAppId"` CreatedAt pgtype.Timestamp `json:"createdAt"` UpdatedAt pgtype.Timestamp `json:"updatedAt"` BlockingPlugin pgtype.Text `json:"blockingPlugin"` SessionKey_2 string `json:"sessionKey2"` SessionHeight int32 `json:"sessionHeight"` CreatedAt_2 pgtype.Timestamp `json:"createdAt2"` UpdatedAt_2 pgtype.Timestamp `json:"updatedAt2"` PortalRegionName string `json:"portalRegionName"` }
type ServiceRecord ¶ added in v1.7.0
type ServiceRecord struct { ID int64 `json:"id"` NodePublicKey string `json:"nodePublicKey"` PoktChainID string `json:"poktChainId"` SessionKey string `json:"sessionKey"` RequestID string `json:"requestId"` PortalRegionName string `json:"portalRegionName"` Latency float64 `json:"latency"` Tickets int32 `json:"tickets"` Result string `json:"result"` Available bool `json:"available"` Successes int32 `json:"successes"` Failures int32 `json:"failures"` P90SuccessLatency float64 `json:"p90SuccessLatency"` MedianSuccessLatency float64 `json:"medianSuccessLatency"` WeightedSuccessLatency float64 `json:"weightedSuccessLatency"` SuccessRate float64 `json:"successRate"` CreatedAt pgtype.Timestamp `json:"createdAt"` UpdatedAt pgtype.Timestamp `json:"updatedAt"` }