pruner

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pruner runs the background loop that deletes old finished jobs: completed and cancelled ones after the retention period, dead ones after the (longer) dead retention. Every server runs it; the store's SKIP LOCKED makes that safe.

Index

Constants

View Source
const (
	DefaultInterval      = time.Minute
	DefaultRetention     = 24 * time.Hour
	DefaultDeadRetention = 7 * 24 * time.Hour
	DefaultBatch         = 1000
)

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, s Store, cfg Config, log *slog.Logger)

Run prunes once immediately and then every Interval until ctx is cancelled. Errors are logged, never fatal: the next tick tries again.

Types

type Config

type Config struct {
	Interval      time.Duration
	Retention     time.Duration
	DeadRetention time.Duration
	Batch         int
	Metrics       *metrics.Metrics // nil records nothing
}

Config sets the loop's period, both retention periods and the batch size. Non-positive values take the defaults.

type Store

type Store interface {
	PruneFinished(ctx context.Context, age time.Duration, limit int) (int, error)
	PruneDead(ctx context.Context, age time.Duration, limit int) (int, error)
}

Store is the part of store.Store the pruner needs.

Jump to

Keyboard shortcuts

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