postgres

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package postgres implements store.Store in PostgreSQL. It passes the same contract as the memory store. A database's row holds both its version and its lease, so granting a lease, fencing and applying a commit all run under the same row lock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, pool *pgxpool.Pool) error

Migrate applies all pending migrations. It holds a PostgreSQL session lock, so if several pods start at the same time, only one of them migrates.

func PoolConfig

func PoolConfig(databaseURL string) (*pgxpool.Config, error)

PoolConfig parses the connection string for the store's pool. Its connections commit with synchronous_commit on, whatever the database's default is: a commit then waits for the WAL to be flushed locally and, if synchronous standbys are configured, on them. A commit that the server has acknowledged must survive a crash.

func SyncStandbyNames

func SyncStandbyNames(ctx context.Context, pool *pgxpool.Pool) (string, error)

SyncStandbyNames returns PostgreSQL's synchronous_standby_names. If it is empty, commits are not replicated synchronously, and a failover to a replica or a restore from a backup can lose acknowledged commits.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store keeps the databases in PostgreSQL.

func New

func New(pool *pgxpool.Pool) *Store

New returns a store that uses pool. The schema must be up to date. See Migrate.

func (*Store) Changes

func (s *Store) Changes(ctx context.Context, key store.Key, fromVersion uint64) (store.ChangeSet, error)

Changes implements store.Store.

func (*Store) ClaimSlot added in v0.3.0

func (s *Store) ClaimSlot(ctx context.Context, req store.ClaimRequest) (store.ClaimResult, error)

ClaimSlot implements store.Store.

func (*Store) Commit

func (s *Store) Commit(ctx context.Context, req store.CommitRequest) (uint64, error)

Commit implements store.Store.

func (*Store) Delete

func (*Store) DeleteSlot added in v0.3.0

func (s *Store) DeleteSlot(ctx context.Context, owner, subject string) ([]store.Key, error)

DeleteSlot implements store.Store.

func (*Store) DeleteUnused

func (s *Store) DeleteUnused(ctx context.Context, cutoff time.Time, limit int) ([]store.Key, error)

DeleteUnused implements store.Store. Each database is deleted in its own transaction, after its row is locked and checked again: an open or commit since the candidates were read keeps it.

func (*Store) Fetch

func (s *Store) Fetch(ctx context.Context, key store.Key, version, first, count uint64) ([][]byte, error)

Fetch implements store.Store.

func (*Store) GetSlot added in v0.3.0

func (s *Store) GetSlot(ctx context.Context, owner string) (store.Slot, bool, error)

GetSlot implements store.Store.

func (*Store) Open

func (s *Store) Open(ctx context.Context, req store.OpenRequest) (store.OpenResult, error)

Open implements store.Store.

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

Ping implements store.Store.

func (*Store) Release

func (s *Store) Release(ctx context.Context, key store.Key, epoch uint64) error

Release implements store.Store.

func (*Store) Renew

func (s *Store) Renew(ctx context.Context, key store.Key, epoch uint64, now time.Time, ttl time.Duration) error

Renew implements store.Store.

func (*Store) SetSlotLabel added in v0.4.0

func (s *Store) SetSlotLabel(ctx context.Context, owner, subject, label string) (store.Slot, error)

SetSlotLabel implements store.Store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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