postgres

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 14 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 is the PostgreSQL backend of meta.Store.

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 the embedded migrations that the database lacks, in name order. A lock serializes replicas that start together.

Types

type Store

type Store struct{ Pool *pgxpool.Pool }

Store keeps the metadata in the schema of Pool.

func Open

func Open(ctx context.Context, dsn string) (*Store, error)

Open connects to the database at dsn and applies the migrations.

func (*Store) AckLand added in v0.19.0

func (s *Store) AckLand(ctx context.Context, repo, id string) error

func (*Store) AcquireLandLease

func (s *Store) AcquireLandLease(ctx context.Context, repo, ref, owner string, now, until time.Time) (time.Time, error)

func (*Store) AcquireLease

func (s *Store) AcquireLease(ctx context.Context, id string, partition int, owner string, now, until time.Time) (meta.Lease, error)

func (*Store) AddPack

func (s *Store) AddPack(ctx context.Context, repo, packID string, bytes int64) error

func (*Store) AdvanceCursor

func (s *Store) AdvanceCursor(ctx context.Context, id string, partition int, owner string, cursor int64) error

func (*Store) BeginDelete added in v0.10.0

func (s *Store) BeginDelete(ctx context.Context, repo string, keys []string, now, staleBefore, retiredBefore time.Time) ([]string, error)

func (*Store) Claim

func (s *Store) Claim(ctx context.Context, id string, epoch uint64, owner, repo string) (meta.Workspace, error)

func (*Store) ClaimLands

func (s *Store) ClaimLands(ctx context.Context, repo, ref, owner string, now time.Time, limit int) ([]meta.LandItem, error)

func (*Store) ClaimRetired added in v0.10.0

func (s *Store) ClaimRetired(ctx context.Context, repo string, keys []string) (bool, error)

ClaimRetired locks the rows first, so a mark that is not yet committed is seen: the lock waits for it, and the statements after it read the row as it is.

func (*Store) Close

func (s *Store) Close()

func (*Store) CreateRepo

func (s *Store) CreateRepo(ctx context.Context, r meta.Repo, repoText, commit string) error

func (*Store) CreateSubscription

func (s *Store) CreateSubscription(ctx context.Context, sub meta.Subscription) (meta.Subscription, error)

func (*Store) CreateUserToken added in v0.9.0

func (s *Store) CreateUserToken(ctx context.Context, hash string, t meta.UserToken) error

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

func (*Store) DeleteRef

func (s *Store) DeleteRef(ctx context.Context, ws string, epoch uint64, repo, name string, expect int64) error

func (*Store) DeleteSubscription

func (s *Store) DeleteSubscription(ctx context.Context, id string) error

func (*Store) EnqueueLand

func (s *Store) EnqueueLand(ctx context.Context, r meta.LandRequest, now time.Time) (meta.LandItem, error)

func (*Store) EventHeads

func (s *Store) EventHeads(ctx context.Context) ([]int64, error)

func (*Store) Events

func (s *Store) Events(ctx context.Context, partition int, after int64, limit int) ([]meta.Event, error)

Events reads the rows first and the floor second, so a prune between the reads gives ErrEventsPruned and never a silent gap.

func (*Store) FinishLands

func (s *Store) FinishLands(ctx context.Context, repo, ref, owner string, now time.Time, results []meta.LandDone) error

func (*Store) Flush

func (s *Store) Flush(ctx context.Context, ws string, epoch uint64, generation int64, prev, op, snapshot string) error

func (*Store) ForgetRetired added in v0.10.0

func (s *Store) ForgetRetired(ctx context.Context, repo string, keys []string) error

func (*Store) LandItem

func (s *Store) LandItem(ctx context.Context, repo, id string) (meta.LandItem, error)

func (*Store) LandLogSince

func (s *Store) LandLogSince(ctx context.Context, repo, ref, base string, limit int) ([]meta.LandLogRow, error)

func (*Store) LandPending

func (s *Store) LandPending(ctx context.Context) ([]meta.LandKey, error)

func (*Store) LandRef

func (s *Store) LandRef(ctx context.Context, m meta.LandMove, owner string, now time.Time) (meta.Ref, error)

func (*Store) Live

func (s *Store) Live(ctx context.Context, id string, epoch uint64, repo string) error

func (*Store) Manifest added in v0.10.0

func (s *Store) Manifest(ctx context.Context, repo string) (meta.Manifest, error)

func (*Store) MergeDeleteRef

func (s *Store) MergeDeleteRef(ctx context.Context, repo, name string, expect int64) error

func (*Store) MergeRef

func (s *Store) MergeRef(ctx context.Context, repo, name string, expect int64, sha string) (meta.Ref, error)

func (*Store) OpHeads

func (s *Store) OpHeads(ctx context.Context, ws string) (meta.OpHeads, error)

func (*Store) PackRepos added in v0.8.0

func (s *Store) PackRepos(ctx context.Context) ([]string, error)

func (*Store) Packs

func (s *Store) Packs(ctx context.Context, repo string) ([]meta.Pack, error)

func (*Store) Ping

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

Ping checks that the database answers.

func (*Store) ProtectedRefs

func (s *Store) ProtectedRefs(ctx context.Context, repo string) ([]string, error)

func (*Store) PruneEvents

func (s *Store) PruneEvents(ctx context.Context, before time.Time) error

func (*Store) PruneLands

func (s *Store) PruneLands(ctx context.Context, before time.Time) error

func (*Store) Ref

func (s *Store) Ref(ctx context.Context, repo, name string) (meta.Ref, error)

func (*Store) Refs

func (s *Store) Refs(ctx context.Context, repo string) ([]meta.Ref, error)

func (*Store) ReleaseLandLease

func (s *Store) ReleaseLandLease(ctx context.Context, repo, ref, owner string) error

func (*Store) RemovePack added in v0.10.0

func (s *Store) RemovePack(ctx context.Context, repo, packID string) error

func (*Store) Repo

func (s *Store) Repo(ctx context.Context, path string) (meta.Repo, error)

func (*Store) Report

func (s *Store) Report(ctx context.Context, ws string, epoch uint64, repo string, generation int64, prev, op, snapshot string) error

func (*Store) Repos

func (s *Store) Repos(ctx context.Context) ([]meta.Repo, error)

func (*Store) RetireFiles added in v0.10.0

func (s *Store) RetireFiles(ctx context.Context, repo string, keys []string, at time.Time) error

func (*Store) RetiredFiles added in v0.10.0

func (s *Store) RetiredFiles(ctx context.Context, repo string) ([]meta.Retired, error)

func (*Store) RevokeUserToken added in v0.9.0

func (s *Store) RevokeUserToken(ctx context.Context, id string) error

func (*Store) SetProtectedRefs

func (s *Store) SetProtectedRefs(ctx context.Context, repo string, patterns []string) error

func (*Store) Subscriptions

func (s *Store) Subscriptions(ctx context.Context) ([]meta.Subscription, error)

func (*Store) SwapManifest added in v0.10.0

func (s *Store) SwapManifest(ctx context.Context, repo string, expect int64, body []byte) (int64, error)

func (*Store) SwapOpHeads

func (s *Store) SwapOpHeads(ctx context.Context, ws string, epoch uint64, repo string, expect int64, heads []string) (meta.OpHeads, error)

func (*Store) SwapRef

func (s *Store) SwapRef(ctx context.Context, ws string, epoch uint64, repo, name string, expect int64, sha string) (meta.Ref, error)

func (*Store) UpdateRef

func (s *Store) UpdateRef(ctx context.Context, repo, name, old, new, kind string) (meta.Ref, error)

UpdateRef compares on the commit of the ref instead of its generation. The write and its event commit together.

func (*Store) UpdateSubscription added in v0.19.0

func (s *Store) UpdateSubscription(ctx context.Context, sub meta.Subscription) (meta.Subscription, error)

func (*Store) UserTokenByHash added in v0.9.0

func (s *Store) UserTokenByHash(ctx context.Context, hash string) (meta.UserToken, error)

func (*Store) UserTokens added in v0.9.0

func (s *Store) UserTokens(ctx context.Context) ([]meta.UserToken, error)

Jump to

Keyboard shortcuts

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