Documentation
¶
Overview ¶
Package partitions maintains the partitions of the five partitioned tables (C-02.FR-11, design/db/schema.md §6): it creates the partitions Muster will need ahead of time, at startup before serving and hourly on the Leader, and drops a partition whose whole range is older than the Organization's retention period. Partition maintenance is runtime work, never a migration, and is safe to run twice: it creates only what is missing and drops only what exists.
Index ¶
Constants ¶
const ( // DaysAhead and MonthsAhead are how far ahead partitions are created: daily partitions for today and the next 7 // days, monthly partitions for this and the next 2 months. DaysAhead = 7 MonthsAhead = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Maintainer ¶
type Maintainer struct {
// contains filtered or unexported fields
}
Maintainer creates and drops partitions over a session connection it opens for each run.
func New ¶
func New(connect func(context.Context) (Session, error), business clock.Clock, log *logging.Logger) *Maintainer
New returns a Maintainer that opens its session connections with connect and reads the date from the business clock, which retention follows. connect bounds each session like the Leader's lock session, so that the advisory lock of a frozen or cut-off process goes within leader.server_bound.
type Session ¶
Session is a session connection. Maintenance sets lock_timeout and holds an advisory lock for the life of the connection, which a transaction pooler would not keep, and DETACH CONCURRENTLY runs outside a transaction block. *pgx.Conn implements it.
type Store ¶
type Store interface {
ListPartitions(ctx context.Context, parent string) ([]dbgen.ListPartitionsRow, error)
ListDetachedPartitions(ctx context.Context, prefix string) ([]string, error)
ListRetention(ctx context.Context) ([]dbgen.ListRetentionRow, error)
}
Store is the queries of maintenance; *dbgen.Queries implements it.