cleanup

package
v1.119.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module(ball *mud.Ball)

Module is a mud module.

Types

type Cleanup

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

Cleanup is a service, which combines retain,TTL,trash, and runs only once (if load is not too high).

func NewCleanup

func NewCleanup(log *zap.Logger, loop *SafeLoop, blobs blobstore.Blobs, pieces *pieces.Store, usedSerials *usedserials.Table, config collector.Config) *Cleanup

NewCleanup creates a new Cleanup.

func (*Cleanup) EmptyTrash

func (c *Cleanup) EmptyTrash(ctx context.Context) (err error)

EmptyTrash removes all the trashed pieces, which are older than the trashExpiryInterval.

func (*Cleanup) Run

func (c *Cleanup) Run(ctx context.Context) error

Run starts running RunOnce in the safe loop.

func (*Cleanup) RunCollector

func (c *Cleanup) RunCollector(ctx context.Context) (err error)

RunCollector runs the collector.

func (*Cleanup) RunOnce

func (c *Cleanup) RunOnce(ctx context.Context) (err error)

RunOnce executes all (TODO) chores, one by one. Can be stopped with cancelling context.

type CoreLoad

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

CoreLoad is an availability check which is false if load/core is high.

func NewCoreLoad

func NewCoreLoad(config CoreLoadConfig) *CoreLoad

NewCoreLoad creates a new CoreLoad.

func (*CoreLoad) Enabled

func (s *CoreLoad) Enabled() (bool, error)

Enabled implements Enablement.

type CoreLoadConfig

type CoreLoadConfig struct {
	MaxCoreLoad float64 `help:"max Linux load / core for executing background jobs. Jobs will be cancelled if load is higher" default:"10"`
}

CoreLoadConfig is the configuration for core load.

type Enablement

type Enablement interface {
	Enabled() (bool, error)
}

Enablement checks if we have free resources to run background jobs.

type FileExists

type FileExists struct {
	Path string
}

FileExists is an availability check which is false if file exists.

func NewFileExists

func NewFileExists(config FileExistsConfig) *FileExists

NewFileExists creates a new FileExists.

func (*FileExists) Enabled

func (f *FileExists) Enabled() (bool, error)

Enabled implements Enablement.

type FileExistsConfig

type FileExistsConfig struct {
	Path string `help:"path to the file. Cleanup will be stopped if file exists" default:"/tmp/storj.chore.disable"`
}

FileExistsConfig contains the configuration for FileExists.

type Period

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

Period is an availability check which is false if the current time is outside the configured period.

func NewPeriod

func NewPeriod(config PeriodConfig) *Period

NewPeriod creates a new Period.

func (*Period) Enabled

func (p *Period) Enabled() (bool, error)

Enabled implements Enablement.

type PeriodConfig

type PeriodConfig struct {
	FromHour int `usage:"hour to start cleanup" default:"0"`
	ToHour   int `usage:"hour to stop cleanup" default:"24"`
}

PeriodConfig contains the configuration for Period.

type SafeLoop

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

SafeLoop is an execution.

func NewSafeLoop

func NewSafeLoop(log *zap.Logger, availability []Enablement, cfg SafeLoopConfig) *SafeLoop

NewSafeLoop creates a new SafeLoop.

func (*SafeLoop) RunSafe

func (s *SafeLoop) RunSafe(ctx context.Context, do func(ctx context.Context) error) (err error)

RunSafe runs the given function in a loop until it returns an error or the context is done. If stops the function, with context cancellation, if condition is false (for example: if load is high).

type SafeLoopConfig

type SafeLoopConfig struct {
	CheckingPeriod time.Duration `help:"time period to check the availability condition" default:"1m"`
	RunPeriod      time.Duration `help:"minimum time between the execution of cleanup" default:"1h"`
}

SafeLoopConfig is the configuration for SafeLoop.

Jump to

Keyboard shortcuts

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