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 ¶
- func Migrate(ctx context.Context, pool *pgxpool.Pool) error
- func PoolConfig(databaseURL string) (*pgxpool.Config, error)
- func SyncStandbyNames(ctx context.Context, pool *pgxpool.Pool) (string, error)
- type Store
- func (s *Store) Changes(ctx context.Context, key store.Key, fromVersion uint64) (store.ChangeSet, error)
- func (s *Store) Commit(ctx context.Context, req store.CommitRequest) (uint64, error)
- func (s *Store) Delete(ctx context.Context, req store.DeleteRequest) (store.DeleteResult, error)
- func (s *Store) DeleteUnused(ctx context.Context, cutoff time.Time, limit int) ([]store.Key, error)
- func (s *Store) Fetch(ctx context.Context, key store.Key, version, first, count uint64) ([][]byte, error)
- func (s *Store) Open(ctx context.Context, req store.OpenRequest) (store.OpenResult, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) Release(ctx context.Context, key store.Key, epoch uint64) error
- func (s *Store) Renew(ctx context.Context, key store.Key, epoch uint64, now time.Time, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrate ¶
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 ¶
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 ¶
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 (*Store) Changes ¶
func (s *Store) Changes(ctx context.Context, key store.Key, fromVersion uint64) (store.ChangeSet, error)
Changes implements store.Store.
func (*Store) Delete ¶
func (s *Store) Delete(ctx context.Context, req store.DeleteRequest) (store.DeleteResult, error)
func (*Store) DeleteUnused ¶
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) Open ¶
func (s *Store) Open(ctx context.Context, req store.OpenRequest) (store.OpenResult, error)
Open implements store.Store.