cpu

package
v0.0.0-...-c5bc0ce Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

type Limiter struct {
	PollingDelay time.Duration
	// contains filtered or unexported fields
}

Limiter limit cpu usage linux cgroup.

func New

func New(cgroupPath string, cgroupName string) *Limiter

New create new CPULimiter

func (*Limiter) Context

func (limiter *Limiter) Context() context.Context

Context return new context that cancelled when the cpu usage of processes exceeding the limit.

func (*Limiter) Limit

func (limiter *Limiter) Limit(duration time.Duration) error

Limit set cpu limit in this cgroup.

func (*Limiter) Prepare

func (limiter *Limiter) Prepare() error

Prepare create new cgroup tree inside cpuacct subsystem. When old cgroup with same name already exists, it will be removed.

func (*Limiter) Put

func (limiter *Limiter) Put(process *os.Process) error

Put will put `process` inside cgroup in cpu subsystem. This basically declare that you want `process`'s cpu usage to be monitored, and killed when exceeding the limit of `Limiter`.

func (*Limiter) Usage

func (limiter *Limiter) Usage() time.Duration

Usage return current cpu usage.

Jump to

Keyboard shortcuts

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