Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package postgres implements the authoritative ledger. The caller owns the pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AESGCM

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

func NewAESGCM

func NewAESGCM(key []byte) (*AESGCM, error)

func (*AESGCM) Open

func (a *AESGCM) Open(t string, b []byte) ([]byte, error)

func (*AESGCM) Seal

func (a *AESGCM) Seal(t string, p []byte) ([]byte, error)

type Cipher

type Cipher interface {
	Seal(tenant string, plaintext []byte) ([]byte, error)
	Open(tenant string, ciphertext []byte) ([]byte, error)
}

Cipher encrypts retained payloads. Production implementations should use envelope encryption and operator-managed versioned keys; destroying one shared key is not selective retention.

type ExtractionInventoryBackfill

type ExtractionInventoryBackfill struct {
	Inventoried int
	Complete    bool
}

ExtractionInventoryBackfill reports a committed page. Complete means no missing inventory receipts were observed in that tenant at the final query; it is not authorization for disposal or verification of all retained copies.

type Ledger

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

func New

func New(ctx context.Context, pool *pgxpool.Pool, cipher Cipher, opts ...Option) (*Ledger, error)

func (*Ledger) AbandonRebuild

func (l *Ledger) AbandonRebuild(ctx context.Context, k model.GenerationKey, a model.RebuildActor, fence int64) (model.RebuildStatus, error)

func (*Ledger) AcknowledgeDelivery

func (l *Ledger) AcknowledgeDelivery(ctx context.Context, d model.Delivery) error

func (*Ledger) ActivateRebuild

func (l *Ledger) ActivateRebuild(ctx context.Context, k model.GenerationKey, a model.RebuildActor, verifiedFence int64) (model.RebuildStatus, error)

func (*Ledger) ActiveProjection

func (l *Ledger) ActiveProjection(ctx context.Context, tenant string) (model.ActiveProjection, error)

func (*Ledger) ArchivePayload

func (l *Ledger) ArchivePayload(ctx context.Context, d model.Delivery) (model.ArchivePayload, error)

ArchivePayload retains the full event and immutable referenced artifacts. Missing classes are explicit gaps; this is not a complete database backup.

func (*Ledger) BackfillExtractionInputInventories

func (l *Ledger) BackfillExtractionInputInventories(ctx context.Context, tenant string, limit int) (result ExtractionInventoryBackfill, err error)

BackfillExtractionInputInventories is a host-authorized maintenance operation, not an engine command or public RPC. Upgrade and stop legacy extraction writers first. The host owns tenant authorization, pool credentials and decryption keys. Each call processes at most limit attempts (1..100) and 64 MiB of ciphertext. It never rewrites an attempt or a completed inventory. Malformed input, missing source content, or partial inventory rows fail the entire page atomically. Repeating calls drains missing receipts without requiring a persistent cursor.

func (*Ledger) ClaimDelivery

func (l *Ledger) ClaimDelivery(ctx context.Context, k model.ConsumerKey, lease time.Duration) (model.Delivery, error)

func (*Ledger) ConsumerStatus

func (l *Ledger) ConsumerStatus(ctx context.Context, k model.ConsumerKey) (model.ConsumerStatus, error)

func (*Ledger) FailDelivery

func (l *Ledger) FailDelivery(ctx context.Context, d model.Delivery, backoff time.Duration) error

func (*Ledger) FinishActivation

func (l *Ledger) FinishActivation(ctx context.Context, k model.GenerationKey, a model.RebuildActor, fence int64) (model.RebuildStatus, error)

func (*Ledger) FinishResume

func (l *Ledger) FinishResume(ctx context.Context, k model.GenerationKey, a model.RebuildActor, fence int64) (model.RebuildStatus, error)

func (*Ledger) FreezeRebuild

func (*Ledger) ProjectionCleanupStatus

func (l *Ledger) ProjectionCleanupStatus(ctx context.Context, k model.ProjectionCleanupKey) (model.ProjectionCleanupStatus, error)

func (*Ledger) ProjectionDestinationInventory

func (l *Ledger) ProjectionDestinationInventory(ctx context.Context, tenant string) (model.ProjectionDestinationInventory, error)

func (*Ledger) ProjectionDocument

func (l *Ledger) ProjectionDocument(ctx context.Context, d model.Delivery, generation string) (*model.ProjectionDocument, error)

ProjectionDocument resolves immutable content at the acceptance event's revision, even when a delayed delivery follows a later correction.

func (*Ledger) ProjectionDocumentPage

func (l *Ledger) ProjectionDocumentPage(ctx context.Context, k model.GenerationKey, fence, through int64, after model.ProjectionCursor, limit int) (model.ProjectionPage, error)

func (*Ledger) ProjectionDocuments

func (l *Ledger) ProjectionDocuments(ctx context.Context, k model.GenerationKey, through int64) ([]model.ProjectionDocument, error)

ProjectionDocuments is a bounded exhaustive acceptance inventory, pinned to the frozen source revision. Immutable versions remain stable across reads.

func (*Ledger) ReadOutboxProgress

func (l *Ledger) ReadOutboxProgress(ctx context.Context, key model.ConsumerKey) (model.OutboxProgress, error)

func (*Ledger) RebuildStatus

func (l *Ledger) RebuildStatus(ctx context.Context, k model.GenerationKey) (model.RebuildStatus, error)

func (*Ledger) RegisterConsumer

func (l *Ledger) RegisterConsumer(ctx context.Context, k model.ConsumerKey, maxAttempts int) error

func (*Ledger) RegisterProjectionDestination

func (l *Ledger) RegisterProjectionDestination(ctx context.Context, k model.GenerationKey) error

func (*Ledger) RenewDelivery

func (l *Ledger) RenewDelivery(ctx context.Context, d model.Delivery, lease time.Duration) error

func (*Ledger) ResumeRebuild

func (l *Ledger) ResumeRebuild(ctx context.Context, k model.GenerationKey, a model.RebuildActor, fence int64) (model.RebuildStatus, error)

func (*Ledger) RetentionDomain

func (l *Ledger) RetentionDomain(ctx context.Context) (string, error)

func (*Ledger) RetryConsumer

func (l *Ledger) RetryConsumer(ctx context.Context, k model.ConsumerKey, failedFence int64) error

RetryConsumer is a trusted operator command, fenced against a specific failure. Its immutable receipt makes retries safe after a lost response.

func (*Ledger) ScanProjectionCleanup

func (l *Ledger) ScanProjectionCleanup(ctx context.Context, r model.ProjectionCleanupQuery) ([]model.ProjectionCleanupRequest, error)

func (*Ledger) StartRebuild

func (l *Ledger) StartRebuild(ctx context.Context, k model.GenerationKey, a model.RebuildActor, maxAttempts int) (model.RebuildStatus, error)

func (*Ledger) Transact

func (l *Ledger) Transact(ctx context.Context, tenant string, fn func(model.Tx) error) error

func (*Ledger) VerifyRebuild

type Option

type Option func(*options)

Option configures New.

func WithSchema

func WithSchema(name string) Option

WithSchema names the PostgreSQL schema that holds the ledger tables. The default is "public". With this option the pool's search_path must resolve to the same schema, because runtime queries use unqualified table names; without it New behaves as before and checks public only.

Jump to

Keyboard shortcuts

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