Documentation
¶
Overview ¶
Package postgres provides a database/sql-backed Postgres queue checkpoint store.
Index ¶
- Variables
- type Store
- func (p *Store) AcquireLease(ctx context.Context, key checkpoint.QueueKey, holderID string, ...) (bool, error)
- func (p *Store) ApplyMigrations(ctx context.Context) error
- func (p *Store) DeleteQueue(ctx context.Context, key checkpoint.QueueKey) error
- func (p *Store) LoadQueue(ctx context.Context, key checkpoint.QueueKey) (checkpoint.QueueSnapshot, bool, error)
- func (p *Store) SaveQueue(ctx context.Context, snapshot checkpoint.QueueSnapshot) error
Constants ¶
This section is empty.
Variables ¶
var PostgresMigrationV1 string
PostgresMigrationV1 creates the queue-state table used by Postgres.
var PostgresMigrationV2 string
PostgresMigrationV2 creates the queue-lease table used to coordinate replicas.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores queue snapshots in a Postgres database. Call ApplyMigrations before the first LoadQueue or SaveQueue.
func New ¶
New returns a Postgres-backed Store using db. The caller owns opening and closing db, including registering the chosen Postgres driver.
func (*Store) AcquireLease ¶ added in v0.7.0
func (p *Store) AcquireLease(ctx context.Context, key checkpoint.QueueKey, holderID string, ttl time.Duration) (bool, error)
AcquireLease atomically acquires or renews a lease for key. It returns false, nil when another holder has an unexpired lease. A holder can renew its own lease, and a different holder can take over after expiry.
func (*Store) ApplyMigrations ¶
ApplyMigrations ensures the backing tables and indexes exist.
func (*Store) DeleteQueue ¶
DeleteQueue removes any durable state for key.
func (*Store) LoadQueue ¶
func (p *Store) LoadQueue(ctx context.Context, key checkpoint.QueueKey) (checkpoint.QueueSnapshot, bool, error)
LoadQueue returns the stored snapshot for key. The boolean is false when the queue has no durable state yet.
func (*Store) SaveQueue ¶
func (p *Store) SaveQueue(ctx context.Context, snapshot checkpoint.QueueSnapshot) error
SaveQueue upserts a complete queue snapshot.