gc

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultInterval is the time between two garbage collections run by the server.
	DefaultInterval = 24 * time.Hour
	// MinInterval prevents the server from garbage collecting in a tight loop.
	MinInterval = time.Minute
	// DefaultBatchSize is the number of reports deleted by a single statement.
	DefaultBatchSize = 5000
)

Variables

View Source
var ErrDisabled = errors.New("garbage collection is disabled, gc.maxHistoryDays must be set")

ErrDisabled is returned when a garbage collection is requested without a retention.

Functions

func Run

func Run(ctx context.Context, o Options)

Run garbage collects the database every interval, until ctx is done.

It is meant to run in its own goroutine next to the server. A failed run is logged and never stops it, the next one simply tries again.

func RunOnce

func RunOnce(ctx context.Context, o Options, dryRun bool) (database.GCResult, error)

RunOnce garbage collects the database a single time.

Types

type Options

type Options struct {
	// MaxHistoryDays is how many days of reports are kept. Older reports are deleted,
	// along with the scms, labels and resource configs no remaining report uses.
	// Zero, the default, disables the garbage collector.
	MaxHistoryDays int
	// Interval is the time between two garbage collections run by the server.
	Interval time.Duration
	// BatchSize is the maximum number of reports deleted by a single statement.
	BatchSize int
}

Options holds the garbage collector settings.

func (Options) Enabled

func (o Options) Enabled() bool

Enabled reports whether reports are ever deleted.

func (*Options) Init

func (o *Options) Init() error

Init fills in the defaults and the environment variable fallbacks, and reports what it cannot make sense of.

Jump to

Keyboard shortcuts

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