Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL-backed durable relay operation log. It is intentionally separate from durable so applications opt into the database driver and own pool construction, credentials, TLS, and migrations.
Index ¶
- Variables
- type Config
- type Pool
- type Store
- func (store *Store) Append(groupID string, change replica.Change) (durable.AppendResult, error)
- func (store *Store) Close() error
- func (store *Store) Closed() bool
- func (store *Store) EnsureSchema(ctx context.Context) error
- func (store *Store) Replay(groupID string, after, maxEvents, maxBytes uint64, manifest replica.Manifest, ...) ([]durable.Event, uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrSequenceRange = errors.New("crdt postgres provider: sequence exceeds PostgreSQL bigint range")
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config bounds one retained operation log per group. Timeout applies to each Append and Replay call because durable.Log intentionally has no context parameter; connection and pool lifetime remain application-owned.
type Pool ¶
type Pool interface {
BeginTx(context.Context, pgx.TxOptions) (pgx.Tx, error)
Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
}
Pool is the minimum pgx pool surface used by Store. *pgxpool.Pool satisfies it directly; keeping the port narrow also permits deterministic SQL-path tests without a running database.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements durable.Log with one row lock per group. It does not close the supplied pool, which may be shared by multiple relay handlers.
func New ¶
New validates provider limits. Call EnsureSchema with a migration role before accepting traffic; runtime applications should grant only the needed table privileges to the relay role.
func (*Store) Append ¶
Append atomically verifies a retry's payload digest, reserves a sequence, persists its envelope, and updates capacity accounting under a group row lock. PostgreSQL BIGINT intentionally limits provider sequences and dots to MaxInt64; applications must rotate/bootstrap long before that boundary.
func (*Store) EnsureSchema ¶
EnsureSchema creates the fixed provider tables. It is intentionally an explicit migration step rather than hidden startup DDL.
func (*Store) Replay ¶
func (store *Store) Replay(groupID string, after, maxEvents, maxBytes uint64, manifest replica.Manifest, policy crdt.ProtocolPolicy, maxMessageBytes, maxActorBytes int) ([]durable.Event, uint64, error)
Replay reads one repeatable PostgreSQL snapshot and refuses a partial, corrupt, over-budget, or manifest-incompatible suffix.