db

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_NAMESPACE_LENGTH = 32

Variables

This section is empty.

Functions

func NewDB

func NewDB(
	ctx context.Context,
	dsn string,
	waitForDB, statementTimeout time.Duration,
) (*sql.DB, error)

func NewNamespacedDB added in v0.1.2

func NewNamespacedDB(
	ctx context.Context,
	dsn string,
	namespace string,
	waitForDB, 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 NullInt32

func NullInt32(v int32) sql.NullInt32

func NullInt64

func NullInt64(v int64) sql.NullInt64

func RunInTx

func RunInTx(
	ctx context.Context,
	db *sql.DB,
	opts *sql.TxOptions,
	fn func(ctx context.Context, txQueries *queries.Queries) error,
) error

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 PollableDBQuery[ValueType any, CursorType any] func(
	ctx context.Context,
	lastSeen CursorType,
	numRows int32,
) (results []ValueType, nextCursor CursorType, err error)

type PollingOptions

type PollingOptions struct {
	Interval time.Duration
	Notifier <-chan bool
	NumRows  int32
}

Poll whenever notified, or at an interval if not notified

type Topic

type Topic = []byte

type VectorClock

type VectorClock = map[uint32]uint64

func ToVectorClock

func ToVectorClock(rows []queries.SelectVectorClockRow) VectorClock

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL