worker

package
v0.8.0 Latest Latest
Warning

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

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

type Cmd

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

	CPULimit     uint64
	RealCPULimit uint64
	MemoryLimit  uint64
	StackLimit   uint64
	ProcLimit    uint64

	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)
}

CmdFile defines file used in the cmd

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

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

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

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       uint64
	RunTime    uint64
	Memory     uint64
	Files      map[string][]byte
	FileIDs    map[string]string
}

Result defines single command response

type Worker

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

Worker defines executor worker

func New

func New(fs filestore.FileStore, pool envexec.EnvironmentPool, parallelism int, workDir string) *Worker

New creates new worker

func (*Worker) Execute added in v0.5.3

func (w *Worker) Execute(ctx context.Context, req *Request) <-chan Response

Execute will execute the request in new goroutine (bypass the parallelism limit)

func (*Worker) Shutdown

func (w *Worker) Shutdown()

Shutdown waits all worker to finish

func (*Worker) Start

func (w *Worker) Start()

Start starts worker loops with given parallelism

func (*Worker) Submit

func (w *Worker) Submit(ctx context.Context, req *Request) <-chan Response

Submit submits a single request

Jump to

Keyboard shortcuts

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