pool

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pool provides reference implements of environent pool and cgroup pool

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPool added in v0.3.0

func NewPool(builder EnvBuilder) envexec.EnvironmentPool

NewPool returns a pool for EnvBuilder

Types

type Cgroup added in v0.3.0

type Cgroup interface {
	SetCpuset(string) error
	SetMemoryLimit(envexec.Size) error
	SetProcLimit(uint64) error
	SetCPURate(float64) error

	CPUUsage() (time.Duration, error)
	MemoryUsage() (envexec.Size, error)

	AddProc(int) error
	Reset() error
	Destroy() error
}

Cgroup defines interface to limit and monitor resources consumption of a process

type CgroupBuilder

type CgroupBuilder interface {
	Build() (cg *cgroup.Cgroup, err error)
}

CgroupBuilder builds cgroup for runner

type CgroupListPool added in v0.3.0

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

CgroupListPool implements cgroup pool

func (*CgroupListPool) Get added in v0.3.0

func (w *CgroupListPool) Get() (Cgroup, error)

Get gets cgroup from pool, if pool is empty, creates new one

func (*CgroupListPool) Put added in v0.3.0

func (w *CgroupListPool) Put(c Cgroup)

Put puts cgroup into the pool

func (*CgroupListPool) Shutdown added in v0.3.0

func (w *CgroupListPool) Shutdown()

Shutdown destroy all cgroup

type CgroupPool

type CgroupPool interface {
	Get() (Cgroup, error)
	Put(Cgroup)
}

CgroupPool implements pool of Cgroup

func NewCgroupListPool added in v0.3.0

func NewCgroupListPool(builder CgroupBuilder, cfsPeriod time.Duration) CgroupPool

NewCgroupListPool creates new cgroup pool

func NewFakeCgroupPool

func NewFakeCgroupPool(builder CgroupBuilder, cfsPeriod time.Duration) CgroupPool

NewFakeCgroupPool creates FakeCgroupPool

type Config added in v0.9.2

type Config struct {
	Builder    EnvironmentBuilder
	CgroupPool CgroupPool
	WorkDir    string
	Seccomp    []syscall.SockFilter
	Cpuset     string
	CPURate    bool
}

Config specifies configuration to build environment builder

type EnvBuilder added in v0.3.0

type EnvBuilder interface {
	Build() (Environment, error)
}

EnvBuilder defines the abstract builder for container environment

func NewEnvBuilder added in v0.3.0

func NewEnvBuilder(c Config) EnvBuilder

NewEnvBuilder creates builder for linux container pools

type Environment

type Environment interface {
	envexec.Environment
	Reset() error
	Destroy() error
}

Environment defines envexec.Environment with destroy

type EnvironmentBuilder

type EnvironmentBuilder interface {
	Build() (container.Environment, error)
}

EnvironmentBuilder defines the abstract builder for container environment

type FakeCgroupPool

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

FakeCgroupPool implements cgroup pool but not actually do pool

func (*FakeCgroupPool) Get

func (f *FakeCgroupPool) Get() (Cgroup, error)

Get gets new cgroup

func (*FakeCgroupPool) Put

func (f *FakeCgroupPool) Put(c Cgroup)

Put destory the cgroup

func (*FakeCgroupPool) Shutdown

func (f *FakeCgroupPool) Shutdown()

Shutdown noop

Jump to

Keyboard shortcuts

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