worker

package
v0.0.0-...-ed43dd5 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedFile

type CachedFile struct {
	FileID string
}

CachedFile defines file cached in the file store

func (*CachedFile) EnvFile

func (f *CachedFile) EnvFile(fs filestore.FileStore) (envexec.File, error)

EnvFile prepares file for envexec file

func (*CachedFile) String

func (f *CachedFile) String() string

type Cmd

type Cmd struct {
	Args  []string
	Env   []string
	Files []CmdFile
	TTY   bool

	CPULimit          time.Duration
	ClockLimit        time.Duration
	MemoryLimit       Size
	StackLimit        Size
	OutputLimit       Size
	ProcLimit         uint64
	OpenFileLimit     uint64
	CPURateLimit      uint64
	CPUSetLimit       string
	StrictMemoryLimit bool

	CopyIn   map[string]CmdFile
	Symlinks map[string]string

	CopyOut       []CmdCopyOutFile
	CopyOutCached []CmdCopyOutFile
	CopyOutMax    uint64
	CopyOutDir    string
}

Cmd defines command and limits to start a program using in envexec

type CmdCopyOutFile

type CmdCopyOutFile = envexec.CmdCopyOutFile

type CmdFile

type CmdFile interface {
	// EnvFile prepares file for envexec file
	EnvFile(fs filestore.FileStore) (envexec.File, error)
	// Stringer to print debug information
	String() string
}

CmdFile defines file used in the cmd

type Collector

type Collector struct {
	Name string       // pseudo name generated into copyOut
	Max  envexec.Size // max size to be collected
	Pipe bool
}

Collector defines on the output (stdout / stderr) to be collected over pipe

func (*Collector) EnvFile

func (f *Collector) EnvFile(fs filestore.FileStore) (envexec.File, error)

EnvFile prepares file for envexec file

func (*Collector) String

func (f *Collector) String() string

type Config

type Config struct {
	FileStore             filestore.FileStore
	EnvironmentPool       EnvironmentPool
	Parallelism           int
	WorkDir               string
	TimeLimitTickInterval time.Duration
	ExtraMemoryLimit      envexec.Size
	OutputLimit           envexec.Size
	CopyOutLimit          envexec.Size
	OpenFileLimit         uint64
	ExecObserver          func(Response)
}

Config defines worker configuration

type EnvironmentPool

type EnvironmentPool interface {
	Get() (envexec.Environment, error)
	Put(envexec.Environment)
}

EnvironmentPool defines pools for environment to be used to execute commands

type LocalFile

type LocalFile struct {
	Src string
}

LocalFile defines file stores on the local file system

func (*LocalFile) EnvFile

func (f *LocalFile) EnvFile(fs filestore.FileStore) (envexec.File, error)

EnvFile prepares file for envexec file

func (*LocalFile) String

func (f *LocalFile) String() string

type MemoryFile

type MemoryFile struct {
	Content []byte
}

MemoryFile defines file stores in the memory

func (*MemoryFile) EnvFile

func (f *MemoryFile) EnvFile(fs filestore.FileStore) (envexec.File, error)

EnvFile prepares file for envexec file

func (*MemoryFile) String

func (f *MemoryFile) String() string

type PipeIndex

type PipeIndex = envexec.PipeIndex

type PipeMap

type PipeMap = envexec.Pipe

type Request

type Request struct {
	RequestID   string
	Cmd         []Cmd
	PipeMapping []PipeMap
}

Request defines single worker request

type Response

type Response struct {
	RequestID string
	Results   []Result
	Error     error
}

Response defines worker response for single request

type Result

type Result struct {
	Status     envexec.Status
	ExitStatus int
	Error      string
	Time       time.Duration
	RunTime    time.Duration
	Memory     envexec.Size
	Files      map[string]*os.File
	FileIDs    map[string]string
	FileError  []envexec.FileError
}

Result defines single command response

func (Result) String

func (r Result) String() string

type Size

type Size = envexec.Size

type Worker

type Worker interface {
	Start()
	Submit(context.Context, *Request) (<-chan Response, <-chan struct{})
	Execute(context.Context, *Request) <-chan Response
	Shutdown()
}

Worker defines interface for executor

func New

func New(conf Config) Worker

New creates new worker

Jump to

Keyboard shortcuts

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