postgres

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package postgres provides a database/sql-backed Postgres queue checkpoint store.

Index

Constants

This section is empty.

Variables

View Source
var PostgresMigrationV1 string

PostgresMigrationV1 creates the queue-state table used by Postgres.

View Source
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

func New(db *sql.DB) *Store

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

func (p *Store) ApplyMigrations(ctx context.Context) error

ApplyMigrations ensures the backing tables and indexes exist.

func (*Store) DeleteQueue

func (p *Store) DeleteQueue(ctx context.Context, key checkpoint.QueueKey) error

DeleteQueue removes any durable state for key.

func (*Store) LoadQueue

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.

Jump to

Keyboard shortcuts

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