containermanager

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContainerCreate       = errors.New("container create error")
	ErrContainerStart        = errors.New("container start error")
	ErrContainerReady        = errors.New("ready wait timeout")
	ErrContainerBusy         = errors.New("container is already in use")
	ErrContainerDoesNotExist = errors.New("container does not exist")
	ErrStdoutChannelNotSet   = errors.New("stdout channel is not set")
)

Functions

This section is empty.

Types

type ConsumedResources

type ConsumedResources struct {
	CPUTime uint64 // mCPU/sec
	Net     uint64 // bytes
}

type ContainerManager

type ContainerManager interface {
	ImageExist(name string) error
	FindContainers(name string) ([]string, error)
	ContainerExist(containerID string) bool
	WaitForIdle(containerID string, timeout time.Duration) error
	CreateAndRunContainer(setup *ContainerSetup) (string, error)
	StopContainer(containerID string, force bool)
	Execute(containerID string, commands []string, pipe ContainerPipe, limits RuntimeLimits) (int, error) // TODO: return consumed resources!
	Stats() map[string]string
}

ContainerManager defines a container manager interface

func New

func New(logger log.MetaLogger) (ContainerManager, error)

New returns an instance of the container manager

type ContainerPipe

type ContainerPipe struct {
	StdIn    chan []byte
	StdOut   chan []byte
	StdErr   chan []byte
	Consumed chan ConsumedResources // channel is written by executor after the streaming has stopped or the container is stopped
}

ContainerPipe defines a channel for reading data from container's stdout/stderr and, optionally, write data into container's stdin

type ContainerSetup

type ContainerSetup struct {
	Image            string
	DefaultCmd       bool          // true for running the container with its own built-in Docker CMD
	ReadyString      string        // set a substring to look for in container logs which signals that the container is ready
	ReadyTimeout     time.Duration // timeout for looking for ReadyString in container logs. Default is `defaultReadyTimeout`
	WorkingDir       string        // absolute host directory mounted as /home/dummy/
	WorkingDirRO     bool
	CacheVolume      []string
	CacheVolumeMount []string
	Envs             map[string]string
	Label            string // {compiler|runner}-{lang}-{version}
	Resources
}

ContainerSetup defines the image and its settings to run the container

type Resources

type Resources struct {
	RAM    uint // Mb
	CPUs   uint // CPUs or cores (in 1/1000)
	Net    bool // connect to network
	TmpDir uint // Mb
}

Resources defines a set of resources (or limits, for that matter) which are available from within the container

type RuntimeLimits

type RuntimeLimits struct {
	CPUTime uint // msec
	Net     uint // bytes
	RunTime uint // sec
	TmpDir  uint // Mb
}

RuntimeLimits defines a single run limits for the exec

Jump to

Keyboard shortcuts

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