postgres

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package postgres implements the store.Store interface using PostgreSQL with sqlc-generated query code and pgx as the driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements store.Store using PostgreSQL.

func New

func New(pool *pgxpool.Pool) *Store

New creates a new PostgreSQL store.

func (*Store) BeginTx

func (s *Store) BeginTx(ctx context.Context) (pgx.Tx, *sqlc.Queries, error)

BeginTx starts a transaction and returns queries scoped to it.

func (*Store) CreateNamespace

func (s *Store) CreateNamespace(ctx context.Context, ns *store.Namespace) error

func (*Store) CreateSchema

func (s *Store) CreateSchema(ctx context.Context, schema *store.Schema) error

func (*Store) DiscardStaging

func (s *Store) DiscardStaging(ctx context.Context, namespaceID string) error

func (*Store) GetBlob

func (s *Store) GetBlob(ctx context.Context, namespaceID, sha256hex string) (*store.ProtoBlob, error)

func (*Store) GetNamespace

func (s *Store) GetNamespace(ctx context.Context, id string) (*store.Namespace, error)

func (*Store) GetSchema

func (s *Store) GetSchema(ctx context.Context, namespaceID, schemaID string) (*store.Schema, error)

func (*Store) GetVersion

func (s *Store) GetVersion(ctx context.Context, namespaceID, schemaID string, version uint64) (*store.SchemaVersion, error)

func (*Store) GetVersionDeps added in v0.71.0

func (s *Store) GetVersionDeps(ctx context.Context, namespaceID, schemaID string, version uint64) ([]store.VersionDep, error)

func (*Store) GetVersionFiles

func (s *Store) GetVersionFiles(ctx context.Context, namespaceID, schemaID string, version uint64) ([]store.VersionFile, error)

func (*Store) ListNamespaceParentEvents added in v0.71.0

func (s *Store) ListNamespaceParentEvents(ctx context.Context, namespaceID string, limit int) ([]*store.NamespaceParentEvent, error)

func (*Store) ListNamespaces

func (s *Store) ListNamespaces(ctx context.Context) ([]*store.Namespace, error)

func (*Store) ListNamespacesPage

func (s *Store) ListNamespacesPage(ctx context.Context, after string, limit int) ([]*store.Namespace, error)

func (*Store) ListSchemas

func (s *Store) ListSchemas(ctx context.Context, namespaceID string) ([]*store.Schema, error)

func (*Store) ListSchemasPage

func (s *Store) ListSchemasPage(ctx context.Context, namespaceID, after string, limit int) ([]*store.Schema, error)

func (*Store) ListVersions

func (s *Store) ListVersions(ctx context.Context, namespaceID, schemaID string) ([]uint64, error)

func (*Store) LoadAllCurrent

func (s *Store) LoadAllCurrent(ctx context.Context) ([]*store.CurrentSchema, error)

func (*Store) LoadNamespaceCurrent

func (s *Store) LoadNamespaceCurrent(ctx context.Context, namespaceID string) ([]*store.CurrentSchema, error)

func (*Store) LoadNamespaceProposed

func (s *Store) LoadNamespaceProposed(ctx context.Context, namespaceID string) ([]*store.CurrentSchema, error)

func (*Store) Promote

func (s *Store) Promote(ctx context.Context, namespaceID string) ([]store.PromotedSchema, error)

func (*Store) PutBlob

func (s *Store) PutBlob(ctx context.Context, blob *store.ProtoBlob) error

func (*Store) PutVersion

func (s *Store) PutVersion(ctx context.Context, ver *store.SchemaVersion, files []store.VersionFile, deps []store.VersionDep) error

func (*Store) RecordNamespaceParentEvent added in v0.71.0

func (s *Store) RecordNamespaceParentEvent(ctx context.Context, ev *store.NamespaceParentEvent) error

RecordNamespaceParentEvent appends to the re-parenting audit log. Phase 3 callers should invoke this in the same transaction as the SetNamespaceParent call for atomicity (see decision D9). Phase 1 ships the persistence; transactional wiring lands with the RPC.

func (*Store) SetNamespaceParent added in v0.71.0

func (s *Store) SetNamespaceParent(ctx context.Context, namespaceID string, parentID *string, actorID string) error

SetNamespaceParent sets a namespace's parent with cycle prevention and records a re-parenting audit row in the same transaction (decision D9). Returns store.ErrParentCycle if a cycle would be created (including self-reference) and store.ErrNamespaceNotFound if either namespace is missing.

func (*Store) SetStaged

func (s *Store) SetStaged(ctx context.Context, namespaceID, schemaID string, version uint64) error

Directories

Path Synopsis
Package pgtest provides a shared test helper for spinning up a PostgreSQL container with migrations applied.
Package pgtest provides a shared test helper for spinning up a PostgreSQL container with migrations applied.

Jump to

Keyboard shortcuts

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