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 ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateComponent(ctx context.Context, c core.Component) error
- func (s *Store) CreateFlag(ctx context.Context, f core.Flag) error
- func (s *Store) DeleteComponent(ctx context.Context, key string) error
- func (s *Store) DeleteFlag(ctx context.Context, key string) error
- func (s *Store) GetComponent(ctx context.Context, key string) (core.Component, error)
- func (s *Store) GetFlag(ctx context.Context, key string) (core.Flag, error)
- func (s *Store) LatestCheck(ctx context.Context, component string) (core.Check, error)
- func (s *Store) LatestChecks(ctx context.Context) ([]core.Check, error)
- func (s *Store) ListComponents(ctx context.Context) ([]core.Component, error)
- func (s *Store) ListFlags(ctx context.Context) ([]core.Flag, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) RecordCheck(ctx context.Context, c core.Check) error
- func (s *Store) UpdateComponent(ctx context.Context, c core.Component) error
- func (s *Store) UpdateFlag(ctx context.Context, f core.Flag) error
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 ¶
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) CreateComponent ¶
CreateComponent inserts a new component, or returns core.ErrConflict.
func (*Store) CreateFlag ¶
CreateFlag inserts a new flag. It returns core.ErrConflict if the key exists.
func (*Store) DeleteComponent ¶
DeleteComponent removes the component with the given key (and, via the foreign key, its checks), or returns core.ErrNotFound.
func (*Store) DeleteFlag ¶
DeleteFlag removes the flag with the given key, or returns core.ErrNotFound.
func (*Store) GetComponent ¶
GetComponent returns the component with the given key, or core.ErrNotFound.
func (*Store) LatestCheck ¶
LatestCheck returns the most recent check for the given component, or core.ErrNotFound if it has none.
func (*Store) LatestChecks ¶
LatestChecks returns the most recent check for each component, one row per component, ordered by component key.
func (*Store) ListComponents ¶
ListComponents returns all components ordered by key.
func (*Store) RecordCheck ¶
RecordCheck appends a health-check observation.
func (*Store) UpdateComponent ¶
UpdateComponent overwrites the component with the given key, or returns core.ErrNotFound. CreatedAt is preserved.