maintenance

package
v15.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartWorkers

func StartWorkers(
	ctx context.Context,
	l logrus.FieldLogger,
	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 logrus.FieldLogger, 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, repository.GitRepo) error
}

Optimizer knows how to optimize a repository

type OptimizerFunc

type OptimizerFunc func(context.Context, repository.GitRepo) 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, repo repository.GitRepo) error

OptimizeRepository calls o(ctx, repo)

type StoragesJob

type StoragesJob func(context.Context, logrus.FieldLogger, []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(storages []config.Storage, 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, logrus.FieldLogger) 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