partitions

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

func (*Maintainer) Create

func (m *Maintainer) Create(ctx context.Context) error

Create creates the partitions that are missing, as the start-up step before serving; it drops nothing. When none is missing it takes no lock, so a start never waits for the Leader's run.

func (*Maintainer) Maintain

func (m *Maintainer) Maintain(ctx context.Context) error

Maintain creates the partitions that are missing and drops those past their retention period, as the hourly Leader task. A failure is logged as partition_maintenance_failed and returned; the next run retries.

type Session

type Session interface {
	dbgen.DBTX
	Close(ctx context.Context) error
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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