pg

package
v0.0.0-...-63b02d4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnifiedPath string = "/sys/fs/cgroup/unified"
)

Functions

func Chain

func Chain(id string) []string

func NewContext

func NewContext(ctx context.Context) context.Context

func RevChain

func RevChain(id string) []string

RevChain returns the list of self and parents from closest to farthest

Types

type CPUQuota

type CPUQuota string

func (CPUQuota) Convert

func (t CPUQuota) Convert(period uint64) (int64, error)

Convert converts, for a 100us period and 4 cpu threads, * 100%@all => 400000 100000 * 50% => 50000 100000 * 50%@3 => 150000 100000

type Config

type Config struct {
	ID            string
	CPUs          string
	Mems          string
	CPUShares     string
	CPUQuota      string
	MemOOMControl string
	MemLimit      string
	VMemLimit     string
	MemSwappiness string
	BlockIOWeight string
}

func (Config) Apply

func (c Config) Apply() error

Apply creates the cgroup, set caps, and add the running process

func (Config) ApplyNoProc

func (c Config) ApplyNoProc() error

ApplyNoProc creates the cgroup, set caps, but does not add a process

func (Config) ApplyProc

func (c Config) ApplyProc(pid int) error

ApplyProc creates the cgroup, set caps, and add the specified process

func (Config) Delete

func (c Config) Delete() (bool, error)

func (Config) String

func (c Config) String() string

type Mgr

type Mgr map[string]*entry

func FromContext

func FromContext(ctx context.Context) *Mgr

func (Mgr) Apply

func (t Mgr) Apply(id string) []Run

func (Mgr) Clean

func (t Mgr) Clean() []Run

func (Mgr) IDs

func (t Mgr) IDs() []string

func (Mgr) Register

func (t Mgr) Register(c *Config)

func (Mgr) RevIDs

func (t Mgr) RevIDs() []string

type Run

type Run struct {
	Err     error
	Config  *Config
	Changed bool
}

type State

type State int
const (
	Init State = iota
	Applied
	Deleted
)

Jump to

Keyboard shortcuts

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