worker

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 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 Cmd

type Cmd struct {
	Args  []string   `json:"args"`
	Env   []string   `json:"env,omitempty"`
	Files []*CmdFile `json:"files,omitempty"`

	CPULimit     uint64 `json:"cpuLimit"`
	RealCPULimit uint64 `json:"realCpuLimit"`
	MemoryLimit  uint64 `json:"memoryLimit"`
	ProcLimit    uint64 `json:"procLimit"`

	CopyIn map[string]CmdFile `json:"copyIn"`

	CopyOut       []string `json:"copyOut"`
	CopyOutCached []string `json:"copyOutCached"`
	CopyOutDir    string   `json:"copyOutDir"`
}

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

type CmdFile

type CmdFile struct {
	Src     *string `json:"src"`
	Content *string `json:"content"`
	FileID  *string `json:"fileId"`
	Name    *string `json:"name"`
	Max     *int64  `json:"max"`
}

CmdFile defines file from multiple source including local / memory / cached or pipe collector

type PipeIndex

type PipeIndex struct {
	Index int `json:"index"`
	Fd    int `json:"fd"`
}

PipeIndex defines indexing for a pipe fd

type PipeMap

type PipeMap struct {
	In  PipeIndex `json:"in"`
	Out PipeIndex `json:"out"`
}

PipeMap defines in / out pipe for multiple program

type Request

type Request struct {
	RequestID   string    `json:"requestId"`
	Cmd         []Cmd     `json:"cmd"`
	PipeMapping []PipeMap `json:"pipeMapping"`
}

Request defines single worker request

type Response

type Response struct {
	Status     Status            `json:"status"`
	ExitStatus int               `json:"exitStatus"`
	Error      string            `json:"error,omitempty"`
	Time       uint64            `json:"time"`
	Memory     uint64            `json:"memory"`
	Files      map[string]string `json:"files,omitempty"`
	FileIDs    map[string]string `json:"fileIds,omitempty"`
}

Response defines single command response

type Result

type Result struct {
	RequestID string     `json:"requestId"`
	Response  []Response `json:"results"`
	Error     error      `json:"-"`
	ErrorMsg  string     `json:"error,omitempty"`
}

Result defines worker response for single request

type Status

type Status envexec.Status

Status offers JSON marshal for envexec.Status

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON convert status into string

type Worker

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

Worker defines executor worker

func New

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

New creates new worker

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 parallism

func (*Worker) Submit

func (w *Worker) Submit(req *Request) <-chan Result

Submit submits a single request

Jump to

Keyboard shortcuts

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