Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartWorkers ¶
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 ¶
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 ¶
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 ¶
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