Documentation
¶
Overview ¶
Package ttlworker provides a background worker for purging expired data from the database.
Package ttlworker provides a background worker for purging expired data from the database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNilStore = errors.New("ttlworker: store is required")
ErrNilStore is returned when New is called with a nil Store.
Functions ¶
func DropOldPartitions ¶
func DropOldPartitions(ctx context.Context, pool *pgxpool.Pool, st store.Store, cutoff time.Time, logger *slog.Logger) error
DropOldPartitions drops entire monthly partitions older than the cutoff date. This is much more efficient than row-by-row deletion for large partitions. Stray rows in the parent table (if any) are handled by the fallback DELETE queries. Returns an aggregated error if any table operations fail.
Types ¶
type Options ¶
type Options struct {
// Store is the database store for executing TTL cleanup queries.
Store store.Store
// TTL is the time-to-live duration for logs, events, diffs, and artifact bundles.
// Rows older than TTL will be deleted. Default: 30 days.
TTL time.Duration
// Interval is how often the worker runs. Default: 1 hour.
Interval time.Duration
// Logger is used for structured logging. If nil, a default logger is used.
Logger *slog.Logger
// DropPartitions enables dropping entire monthly partitions instead of
// row-by-row deletion when the operator configures partitioned tables
// out-of-band (e.g., on logs/events/artifact_bundles). Default: false.
DropPartitions bool
}
Options configures the TTL worker.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is a background task that purges expired data from the database.
Click to show internal directories.
Click to hide internal directories.