pgstore

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package pgstore is the Postgres alerting.StateStore.

The schema is not applied by the store. A consumer applies it the way it applies every other migration: SchemaSQL renders the DDL for a schema name, and a consumer with its own migration tool copies that into a migration file (and pins it with a test comparing the file to SchemaSQL). Migrate applies it directly for a deployment that has no migration tool of its own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB, schema string) error

Migrate applies SchemaSQL. It is idempotent.

func SchemaSQL

func SchemaSQL(schema string) (string, error)

SchemaSQL is the DDL with its tables in schema ("" for the connection's search_path).

Types

type Store

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

Store implements alerting.StateStore over database/sql with a Postgres driver.

func New

func New(db *sql.DB, schema string) (*Store, error)

New builds a Store whose tables live in schema ("" for search_path).

func (*Store) Apply

func (s *Store) Apply(ctx context.Context, ch alerting.Changes) error

Apply implements alerting.StateStore. One transaction per call.

func (*Store) Events

func (s *Store) Events(ctx context.Context, q alerting.EventQuery) ([]alerting.Event, error)

Events implements alerting.StateStore.

func (*Store) LoadOwner

func (s *Store) LoadOwner(ctx context.Context, owner string) ([]alerting.Instance, error)

LoadOwner implements alerting.StateStore.

func (*Store) Owners

func (s *Store) Owners(ctx context.Context) ([]string, error)

Owners implements alerting.StateStore.

func (*Store) PruneEvents

func (s *Store) PruneEvents(ctx context.Context, before time.Time) (int64, error)

PruneEvents deletes history older than before and returns how many rows went.

Jump to

Keyboard shortcuts

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