maintenance

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchFunc

type BatchFunc func(context.Context, time.Time) (rows int64, more bool, err error)

type Config

type Config struct {
	LeaseDuration        time.Duration
	RenewInterval        time.Duration
	RetryInterval        time.Duration
	ContinuationInterval time.Duration
	PassTimeout          time.Duration
	MaxBatches           int
}

type Coordinator

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

func New

func New(store LeaseStore, logger *slog.Logger, metrics Metrics, jobs []Job, cfg Config) (*Coordinator, error)

func (*Coordinator) Done

func (c *Coordinator) Done() <-chan struct{}

func (*Coordinator) Run

func (c *Coordinator) Run(ctx context.Context)

func (*Coordinator) Shutdown

func (c *Coordinator) Shutdown(ctx context.Context) error

type Job

type Job struct {
	Name     string
	Interval time.Duration
	RunBatch BatchFunc
}

type LeaseStore

type LeaseStore interface {
	TryAcquireMaintenanceLease(context.Context, string, uuid.UUID, time.Duration) (store.MaintenanceLease, bool, error)
	RenewMaintenanceLease(context.Context, store.MaintenanceLease, time.Duration) (store.MaintenanceLease, bool, error)
	ReleaseMaintenanceLease(context.Context, store.MaintenanceLease) (bool, error)
	RunMaintenanceBatch(context.Context, store.MaintenanceLease, func(context.Context) (int64, bool, error)) (int64, bool, bool, error)
}

type Metrics

type Metrics interface {
	ObserveMaintenanceLease(outcome string)
	SetMaintenanceLeader(leader bool)
	ObserveMaintenanceRun(job, outcome string, duration time.Duration, rows int64)
}

Jump to

Keyboard shortcuts

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