Documentation
¶
Overview ¶
Package resource applies resource constraints to processes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(constraint Constraint) error
Apply applies the provided resources constraints to the process specified by the PID and name. If a constraint is missing, then that constraint is simply skipped.
func NewOOMWatcher ¶
func NewOOMWatcher(ctx context.Context, constraint Constraint, interval time.Duration) (events.Watcher, error)
NewOOMWatcher sets a new OOM watcher for the given process. This will trigger events when the process is killed due to OOM.
func RemoveConstraint ¶
RemoveConstraint removes and cleans up the resource constraints set by Apply for a given process. The name is the full name of the process. For plugins, this is the value returned by FullName(). The statePath is the path to the state of the process. This is mainly used by the windows implementation for saving the JobObject handles.
Types ¶
type Constraint ¶
type Constraint struct { // PID is the PID of the process. PID int // Name is the name of the process or plugin. Name string // MaxMemoryUsage is the maximum memory usage of the process, in bytes. MaxMemoryUsage int64 // MaxCPUUsage is the maximum CPU usage of the process. MaxCPUUsage int32 }
Constraint is a resource constraint.
type ConstraintClient ¶
type ConstraintClient interface { // Apply applies the provided resources constraints to the process specified // by the PID and name. Apply(constraint Constraint) error // RemoveConstraint removes and cleans up the resource constraints set by // Apply for a given process. RemoveConstraint(ctx context.Context, name string) error // NewOOMWatcher initializes a OOM watcher for the given process. On // success, it returns the watcher ID that can be used to subscribe the // watcher events. NewOOMWatcher(ctx context.Context, constraint Constraint, interval time.Duration) (events.Watcher, error) }
ConstraintClient is the interface for applying resource constraints to processes.
var Client ConstraintClient
Client is the default client for applying resource constraints.