maintenance

package
v16.7.8-rc42 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartWorkers

func StartWorkers(
	ctx context.Context,
	l log.Logger,
	workers ...WorkerFunc,
) (func(), error)

StartWorkers will start any background workers and returns a function that can be used to shut down the background workers.

Types

type DailyWorker

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

DailyWorker allows for a storage job to be executed on a daily schedule

func NewDailyWorker

func NewDailyWorker() DailyWorker

NewDailyWorker returns an initialized daily worker

func (DailyWorker) StartDaily

func (dw DailyWorker) StartDaily(ctx context.Context, l log.Logger, schedule config.DailyJob, job StoragesJob) error

StartDaily will run the provided job every day at the specified time for the specified duration. Only the specified storages wil be worked on.

type Optimizer

type Optimizer interface {
	OptimizeRepository(context.Context, log.Logger, storage.Repository) error
}

Optimizer knows how to optimize a repository

type OptimizerFunc

type OptimizerFunc func(context.Context, log.Logger, storage.Repository) error

OptimizerFunc is an adapter to allow the use of an ordinary function as an Optimizer

func (OptimizerFunc) OptimizeRepository

func (o OptimizerFunc) OptimizeRepository(ctx context.Context, logger log.Logger, repo storage.Repository) error

OptimizeRepository calls o(ctx, repo)

type StoragesJob

type StoragesJob func(context.Context, log.Logger, []string) error

StoragesJob runs a job on storages. The string slice param indicates which storages are currently enabled for the feature.

func OptimizeReposRandomly

func OptimizeReposRandomly(cfg config.Cfg, optimizer Optimizer, ticker helper.Ticker, rand *rand.Rand) StoragesJob

OptimizeReposRandomly returns a function to walk through each storage and attempts to optimize any repos encountered. The ticker is used to rate-limit optimizations.

Only storage paths that map to an enabled storage name will be walked. Any storage paths shared by multiple storages will only be walked once.

Any errors during the optimization will be logged. Any other errors will be returned and cause the walk to end prematurely.

type WorkerFunc

type WorkerFunc func(context.Context, log.Logger) error

WorkerFunc is a function that does a unit of work meant to run in the background

func DailyOptimizationWorker

func DailyOptimizationWorker(cfg config.Cfg, optimizer Optimizer) WorkerFunc

DailyOptimizationWorker creates a worker that runs repository maintenance daily

Jump to

Keyboard shortcuts

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