cleaner

package
v0.0.0-...-ea22f37 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cleaner

type Cleaner func(ctx context.Context) error

Cleaner is a function that cleans up some resource provided by the operating system, such as stale processes in a process table or files in a temporary directory.

func NewChainedCleaner

func NewChainedCleaner(cleaners []Cleaner) Cleaner

NewChainedCleaner creates a new Cleaner that invokes a series of existing Cleaner objects sequentially. If any of them fail, the first observed error is returned.

func NewCommandRunningCleaner

func NewCommandRunningCleaner(command string, args []string) Cleaner

NewCommandRunningCleaner creates a new Cleaner that executes a command on the system and expects it to succeed.

func NewDirectoryCleaner

func NewDirectoryCleaner(directory filesystem.Directory, path string) Cleaner

NewDirectoryCleaner creates a Cleaner that can remove all files within a given directory. It can, for example, be used to remove files from build directories and system temporary directories.

func NewProcessTableCleaner

func NewProcessTableCleaner(processTable ProcessTable) Cleaner

NewProcessTableCleaner creates a decorator for Runner that kills processes that were left behind by previous build actions (e.g., daemonized processes).

type IdleInvoker

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

IdleInvoker is a helper type for invoking a Cleaner function. As it's generally not safe to call a Cleaner function while one or more build actions are running, they should only be invoked when the system is idle.

IdleInvoker keeps track of a use count to determine whether the system is idle. When transitioning from idle to busy or from busy to idle, the Cleaner function is called.

func NewIdleInvoker

func NewIdleInvoker(f Cleaner) *IdleInvoker

NewIdleInvoker creates a new IdleInvoker that is in the idle state.

func (*IdleInvoker) Acquire

func (i *IdleInvoker) Acquire(ctx context.Context) error

Acquire the IdleInvoker by incrementing its use count. If the use count transitions from zero to one, the Cleaner is called. Acquisition does not take place if the Cleaner returns an error.

func (*IdleInvoker) Release

func (i *IdleInvoker) Release(ctx context.Context) error

Release the IdleInvoker by decrementing its use count. If the use count transitions from one to zero, the Cleaner is called. The use count is always decremented, even if cleaning fails.

type Process

type Process struct {
	ProcessID    int
	UserID       int
	CreationTime time.Time
}

Process running on the operating system. This type contains a subset of the information normally displayed by tools such as ps and top.

type ProcessFilterFunc

type ProcessFilterFunc func(process *Process) bool

ProcessFilterFunc is a callback that is provided to NewFilteringProcessTable to act as a filter function for processes returned by GetProcesses(). Only processes for which this callback function returns true are returned.

type ProcessTable

type ProcessTable interface {
	GetProcesses() ([]Process, error)
}

ProcessTable is an interface for extracting a list of processes running on the operating system.

var SystemProcessTable ProcessTable = systemProcessTable{}

SystemProcessTable corresponds with the process table of the locally running operating system. On this operating system the information is extracted from procfs.

func NewFilteringProcessTable

func NewFilteringProcessTable(base ProcessTable, filter ProcessFilterFunc) ProcessTable

NewFilteringProcessTable is a decorator for ProcessTable that only causes it to return processes matching a given filter. These are the processes that bb_runner should consider terminating.

Jump to

Keyboard shortcuts

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