pool

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: MIT Imports: 9 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

This section is empty.

Types

type CgroupBuilder

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

CgroupBuilder builds cgroup for runner

type CgroupPool

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

CgroupPool implements cgroup pool

func NewCgroupPool

func NewCgroupPool(builder CgroupBuilder) *CgroupPool

NewCgroupPool creates new cgroup pool

func (*CgroupPool) Get

func (w *CgroupPool) Get() (envexec.Cgroup, error)

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

func (*CgroupPool) Put

func (w *CgroupPool) Put(c envexec.Cgroup)

Put puts cgroup into the pool

func (*CgroupPool) Shutdown

func (w *CgroupPool) Shutdown()

Shutdown destroy all cgroup

type EnvPool

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

EnvPool implements container environment pool

func NewEnvPool

func NewEnvPool(builder EnvironmentBuilder) *EnvPool

NewEnvPool creats new EnvPool with a builder

func (*EnvPool) Destroy

func (p *EnvPool) Destroy(env container.Environment)

Destroy destory an environment

func (*EnvPool) Get

func (p *EnvPool) Get() (envexec.Environment, error)

Get gets environment from pool, if pool is empty, creates new environment

func (*EnvPool) Put

func (p *EnvPool) Put(env envexec.Environment)

Put puts environment to the pool with reset the environment

func (*EnvPool) Release

func (p *EnvPool) Release()

Release clears the pool

func (*EnvPool) Shutdown

func (p *EnvPool) Shutdown()

Shutdown indicates a shutdown event, not implemented yes

type Environment

type Environment struct {
	container.Environment
	// contains filtered or unexported fields
}

Environment defines interface to access container resources

func (*Environment) OpenAtWorkDir

func (c *Environment) OpenAtWorkDir(path string, flags int, perm os.FileMode) (*os.File, error)

OpenAtWorkDir opens file relative to work directory

func (*Environment) WorkDir

func (c *Environment) WorkDir() *os.File

WorkDir returns opened work directory, should not close after

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 NewFakeCgroupPool

func NewFakeCgroupPool(builder CgroupBuilder) *FakeCgroupPool

NewFakeCgroupPool creates FakeCgroupPool

func (*FakeCgroupPool) Get

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

Get gets new cgroup

func (*FakeCgroupPool) Put

func (f *FakeCgroupPool) Put(c envexec.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