retention

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package retention provides lifecycle management for periodic retention work.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPeriodicWorkerCallbackRequired reports a missing retention callback.
	ErrPeriodicWorkerCallbackRequired = errors.New("periodic retention worker callback is required")
	// ErrPeriodicWorkerContextRequired reports a nil start context.
	ErrPeriodicWorkerContextRequired = errors.New("periodic retention worker context is required")
	// ErrPeriodicWorkerInvalidInterval reports a non-positive sweep cadence.
	ErrPeriodicWorkerInvalidInterval = errors.New("periodic retention worker interval must be greater than zero")
	// ErrPeriodicWorkerAlreadyStarted reports an attempt to start an active worker.
	ErrPeriodicWorkerAlreadyStarted = errors.New("periodic retention worker is already started")
)

Functions

This section is empty.

Types

type PeriodicWorker

type PeriodicWorker struct {
	// contains filtered or unexported fields
}

PeriodicWorker runs one retention callback at a fixed interval and joins it on shutdown.

func NewPeriodicWorker

func NewPeriodicWorker(
	label string,
	sweep func(context.Context) error,
	interval time.Duration,
	onError func(error),
) *PeriodicWorker

NewPeriodicWorker builds a joined periodic worker for one retention callback.

func (*PeriodicWorker) Shutdown

func (w *PeriodicWorker) Shutdown(ctx context.Context) error

Shutdown cancels and joins periodic work.

func (*PeriodicWorker) Start

func (w *PeriodicWorker) Start(ctx context.Context) error

Start begins periodic work until shutdown or parent cancellation.

Jump to

Keyboard shortcuts

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