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

postgres

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package postgres provides a Postgres-backed implementation of store.Store. It uses the pure-Go github.com/jackc/pgx/v5 driver (no cgo) via database/sql, so the Console binary stays static. Flag variants and component config are persisted as JSONB columns; timestamps are stored as TIMESTAMPTZ in UTC.

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 is a Postgres-backed store.Store. It is safe for concurrent use: the underlying *sql.DB manages a connection pool.

func Open

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

Open connects to the Postgres database at dsn, sets sane pool limits, verifies connectivity, runs the idempotent schema migrations, and returns a ready Store.

func (*Store) Close

func (s *Store) Close() error

Close releases the underlying database handle.

func (*Store) CreateComponent

func (s *Store) CreateComponent(ctx context.Context, c core.Component) error

CreateComponent inserts a new component, or returns core.ErrConflict.

func (*Store) CreateFlag

func (s *Store) CreateFlag(ctx context.Context, f core.Flag) error

CreateFlag inserts a new flag. It returns core.ErrConflict if the key exists.

func (*Store) DeleteComponent

func (s *Store) DeleteComponent(ctx context.Context, key string) error

DeleteComponent removes the component with the given key (and, via the foreign key, its checks), or returns core.ErrNotFound.

func (*Store) DeleteFlag

func (s *Store) DeleteFlag(ctx context.Context, key string) error

DeleteFlag removes the flag with the given key, or returns core.ErrNotFound.

func (*Store) GetComponent

func (s *Store) GetComponent(ctx context.Context, key string) (core.Component, error)

GetComponent returns the component with the given key, or core.ErrNotFound.

func (*Store) GetFlag

func (s *Store) GetFlag(ctx context.Context, key string) (core.Flag, error)

GetFlag returns the flag with the given key, or core.ErrNotFound.

func (*Store) LatestCheck

func (s *Store) LatestCheck(ctx context.Context, component string) (core.Check, error)

LatestCheck returns the most recent check for the given component, or core.ErrNotFound if it has none.

func (*Store) LatestChecks

func (s *Store) LatestChecks(ctx context.Context) ([]core.Check, error)

LatestChecks returns the most recent check for each component, one row per component, ordered by component key.

func (*Store) ListComponents

func (s *Store) ListComponents(ctx context.Context) ([]core.Component, error)

ListComponents returns all components ordered by key.

func (*Store) ListFlags

func (s *Store) ListFlags(ctx context.Context) ([]core.Flag, error)

ListFlags returns all flags ordered by key.

func (*Store) Ping

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

Ping verifies the backend is reachable.

func (*Store) RecordCheck

func (s *Store) RecordCheck(ctx context.Context, c core.Check) error

RecordCheck appends a health-check observation.

func (*Store) UpdateComponent

func (s *Store) UpdateComponent(ctx context.Context, c core.Component) error

UpdateComponent overwrites the component with the given key, or returns core.ErrNotFound. CreatedAt is preserved.

func (*Store) UpdateFlag

func (s *Store) UpdateFlag(ctx context.Context, f core.Flag) error

UpdateFlag overwrites the flag with the given key. It returns core.ErrNotFound if no such flag exists. CreatedAt is preserved.

Jump to

Keyboard shortcuts

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