worker

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedFile added in v0.5.0

type CachedFile struct {
	FileID string
}

CachedFile defines file cached in the file store

func (*CachedFile) EnvFile added in v0.5.0

func (f *CachedFile) EnvFile(fs filestore.FileStore) (interface{}, error)

EnvFile prepares file for envexec file

func (*CachedFile) String added in v0.8.3

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  envexec.Size
	StackLimit   envexec.Size
	ProcLimit    uint64
	CPURateLimit float64

	CopyIn map[string]CmdFile

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

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

type CmdFile

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

CmdFile defines file used in the cmd

type Config added in v0.8.1

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

Config defines worker configuration

type LocalFile added in v0.5.0

type LocalFile struct {
	Src string
}

LocalFile defines file stores on the local file system

func (*LocalFile) EnvFile added in v0.5.0

func (f *LocalFile) EnvFile(fs filestore.FileStore) (interface{}, error)

EnvFile prepares file for envexec file

func (*LocalFile) String added in v0.8.3

func (f *LocalFile) String() string

type MemoryFile added in v0.5.0

type MemoryFile struct {
	Content []byte
}

MemoryFile defines file stores in the memory

func (*MemoryFile) EnvFile added in v0.5.0

func (f *MemoryFile) EnvFile(fs filestore.FileStore) (interface{}, error)

EnvFile prepares file for envexec file

func (*MemoryFile) String added in v0.8.3

func (f *MemoryFile) String() string

type PipeCollector added in v0.5.0

type PipeCollector struct {
	Name string // pseudo name generated into copyOut
	Max  int64  // max size to be collected
}

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

func (*PipeCollector) EnvFile added in v0.5.0

func (f *PipeCollector) EnvFile(fs filestore.FileStore) (interface{}, error)

EnvFile prepares file for envexec file

func (*PipeCollector) String added in v0.8.3

func (f *PipeCollector) String() string

type PipeIndex

type PipeIndex struct {
	Index int
	Fd    int
}

PipeIndex defines indexing for a pipe fd

type PipeMap

type PipeMap struct {
	In  PipeIndex
	Out PipeIndex
}

PipeMap defines in / out pipe for multiple program

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][]byte
	FileIDs    map[string]string
}

Result defines single command response

func (Result) String added in v0.9.5

func (r Result) String() string

type Worker

type Worker interface {
	Start()
	Submit(context.Context, *Request) <-chan Response
	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