Documentation
¶
Index ¶
- Constants
- func ConnectToDB(ctx context.Context, logger *zap.Logger, dsn string, namespace string, ...) (*sql.DB, error)
- func Get5MinutesOfCongestion(ctx context.Context, querier *queries.Queries, originatorID, endMinute int32) (out [5]int32, err error)
- func InsertGatewayEnvelopeAndIncrementUnsettledUsage(ctx context.Context, db *sql.DB, ...) (int64, error)
- func NewNamespacedDB(ctx context.Context, logger *zap.Logger, dsn string, namespace string, ...) (*sql.DB, error)
- func NullInt32(v int32) sql.NullInt32
- func NullInt64(v int64) sql.NullInt64
- func RunInTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions, ...) error
- func RunInTxWithResult[T any](ctx context.Context, db *sql.DB, opts *sql.TxOptions, ...) (result T, err error)
- func SetVectorClock(q *queries.SelectGatewayEnvelopesParams, vc VectorClock) *queries.SelectGatewayEnvelopesParams
- type DBSubscription
- type PollableDBQuery
- type PollingOptions
- type Topic
- type VectorClock
Constants ¶
const MAX_NAMESPACE_LENGTH = 32
Variables ¶
This section is empty.
Functions ¶
func ConnectToDB ¶ added in v0.4.0
func ConnectToDB( ctx context.Context, logger *zap.Logger, dsn string, namespace string, waitForDB time.Duration, statementTimeout time.Duration, ) (*sql.DB, error)
ConnectToDB establishes a connection to an existing database using the provided DSN. Unlike NewNamespacedDB, this function does not create the database or run migrations. If namespace is provided, it overrides the database name in the DSN.
func Get5MinutesOfCongestion ¶ added in v0.3.0
func Get5MinutesOfCongestion( ctx context.Context, querier *queries.Queries, originatorID, endMinute int32, ) (out [5]int32, err error)
Gets the congestion for the minute specified by `endMinute` and the previous 4 minutes returned in descending order with missing values filled with 0
func InsertGatewayEnvelopeAndIncrementUnsettledUsage ¶ added in v0.3.0
func InsertGatewayEnvelopeAndIncrementUnsettledUsage( ctx context.Context, db *sql.DB, insertParams queries.InsertGatewayEnvelopeParams, incrementParams queries.IncrementUnsettledUsageParams, ) (int64, error)
InsertGatewayEnvelopeAndIncrementUnsettledUsage inserts a gateway envelope and increments the unsettled usage for the payer. It returns the number of rows inserted.
func NewNamespacedDB ¶ added in v0.1.2
func NewNamespacedDB( ctx context.Context, logger *zap.Logger, dsn string, namespace string, waitForDB time.Duration, statementTimeout time.Duration, ) (*sql.DB, error)
Creates a new database with the given namespace if it doesn't exist and returns the full DSN for the new database.
func RunInTxWithResult ¶ added in v0.3.0
func SetVectorClock ¶
func SetVectorClock( q *queries.SelectGatewayEnvelopesParams, vc VectorClock, ) *queries.SelectGatewayEnvelopesParams
Types ¶
type DBSubscription ¶
type DBSubscription[ValueType any, CursorType any] struct { // contains filtered or unexported fields }
A subscription that polls a DB for updates Assumes there is only one listener (updates block on a single unbuffered channel)
func NewDBSubscription ¶
func NewDBSubscription[ValueType any, CursorType any]( ctx context.Context, log *zap.Logger, query PollableDBQuery[ValueType, CursorType], lastSeen CursorType, options PollingOptions, ) *DBSubscription[ValueType, CursorType]
func (*DBSubscription[ValueType, CursorType]) Start ¶
func (s *DBSubscription[ValueType, CursorType]) Start() (<-chan []ValueType, error)
type PollableDBQuery ¶
type PollingOptions ¶
Poll whenever notified, or at an interval if not notified
type VectorClock ¶
func ToVectorClock ¶
func ToVectorClock(rows []queries.SelectVectorClockRow) VectorClock