runners

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const QueueFullMsg = "No resources available. Please try later."
View Source
const QueueInitingMsg = "Queue is still initializing. Please try later."
View Source
const QueueInvalidMsg = "Failed initialization, queue permanently broken."
View Source
const UnknownRunIDMsg = "unknown run id %v"

Variables

This section is empty.

Functions

func MinDuration

func MinDuration(a, b time.Duration) time.Duration

MinDuration returns the smallest duration of two given durations

func Module

func Module() ice.Module

Module returns a module that creates a new Runner.

func NewPollingService

func NewPollingService(c runner.Controller, nower runner.StatusQueryNower, period time.Duration) runner.Service

NewPollingService creates a new Service from a Controller, and a StatusQueryNower. (This is a convenience function over NewPollingStatusQuerier

func NewQueueRunner

func NewQueueRunner(
	exec execer.Execer,
	filerMap runner.RunTypeMap,
	output runner.OutputCreator,
	capacity int,
	stat stats.StatsReceiver,
	dirMonitor *stats.DirsMonitor,
	rID runner.RunnerID,
	preprocessors []func() error,
	postprocessors []func() error,
) runner.Service

NewQueueRunner creates a new Service that uses a Queue If the worker has an initialization step (indicated by non-nil in idc) the queue will wait for the worker to finish initialization before accepting any run requests. If the queue is full when a command is received, an empty RunStatus and a queue full error will be returned.

@param: exec - runs the command @param: filerMap - mapping of runner.RunType's to filers and corresponding InitDoneCh's that are used by underlying Invokers. The Controller waits on all non-nil InitDoneCh's to complete successfully before serving requests. @param: output @param: tmp @param: capacity - the maximum number of commands to support on the queue. If 0 then the queue is unbounded. @param: stats - the stats receiver the queue will use when reporting its metrics @param: dirMonitor - monitor directory size changes from running the task's command @param: rID - the runner id

func NewSingleRunner

func NewSingleRunner(
	exec execer.Execer,
	filerMap runner.RunTypeMap,
	output runner.OutputCreator,
	stat stats.StatsReceiver,
	dirMonitor *stats.DirsMonitor,
	rID runner.RunnerID,
	preprocessors []func() error,
	postprocessors []func() error,
) runner.Service

NewSingleRunner create a SingleRunner

Types

type ChaosRunner

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

ChaosRunner implements Runner by calling to a delegate runner in the happy path, but delaying a random time between 0 and MaxDelay, or returning an error

func NewChaosRunner

func NewChaosRunner(delegate runner.Service) *ChaosRunner

Creates a new Chaos Runner

func (*ChaosRunner) Abort

func (r *ChaosRunner) Abort(run runner.RunID) (runner.RunStatus, error)

func (*ChaosRunner) Query

func (*ChaosRunner) QueryNow

func (*ChaosRunner) Release

func (r *ChaosRunner) Release()

func (*ChaosRunner) Run

func (r *ChaosRunner) Run(cmd *runner.Command) (runner.RunStatus, error)

Implement Runner

func (*ChaosRunner) SetDelay

func (r *ChaosRunner) SetDelay(delay time.Duration)

SetDelay sets the max delay to delay; the actual delay will be randomly selected up to delay

func (*ChaosRunner) SetError

func (r *ChaosRunner) SetError(err error)

SetError sets the error to return on calls to the Runner

func (*ChaosRunner) SetRunStatus

func (r *ChaosRunner) SetRunStatus(status runner.RunStatus)

func (*ChaosRunner) Status

func (*ChaosRunner) StatusAll

func (r *ChaosRunner) StatusAll() ([]runner.RunStatus, runner.ServiceStatus, error)

type HttpOutputCreator

type HttpOutputCreator interface {
	http.Handler
	runner.OutputCreator
	HttpPath() string
}

func NewHttpOutputCreator

func NewHttpOutputCreator(httpUri string) (HttpOutputCreator, error)

Takes a tempdir to place new files and optionally an httpUri, ex: 'http://HOST:PORT/ENDPOINT/', to use instead of 'file://HOST/PATH'

type Invoker

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

Invoker Runs a Scoot Command by performing the Scoot setup and gathering. (E.g., checking out a Snapshot, or saving the Output once it's done) Unlike a full Runner, it has no idea of what else is running or has run.

func NewInvoker

func NewInvoker(
	exec execer.Execer,
	filerMap runner.RunTypeMap,
	output runner.OutputCreator,
	stat stats.StatsReceiver,
	dirMonitor *stats.DirsMonitor,
	rID runner.RunnerID,
	preprocessors []func() error,
	postprocessors []func() error,
) *Invoker

NewInvoker creates an Invoker that will use the supplied helpers

func (*Invoker) Run

func (inv *Invoker) Run(cmd *runner.Command, id runner.RunID) (abortCh chan<- struct{}, updateCh <-chan runner.RunStatus)

Run runs cmd Run will send updates as the process is running to updateCh. The RunStatus'es that come out of updateCh will have an empty RunID Run will enforce cmd's Timeout, and will abort cmd if abortCh is signaled. updateCh will not close until the run is finished running.

type NullOutput

type NullOutput struct{}

func (*NullOutput) AsFile

func (o *NullOutput) AsFile() string

AsFile returns /dev/null

func (*NullOutput) Close

func (o *NullOutput) Close() error

Close implements io.Closer as a no-op

func (*NullOutput) URI

func (o *NullOutput) URI() string

URI returns file:///dev/null

func (*NullOutput) Write

func (o *NullOutput) Write(p []byte) (int, error)

Write implements io.Writer as a no-op

type NullOutputCreator

type NullOutputCreator struct{}

NullOutputCreator pretends to create an Output but doesn't.

func NewNullOutputCreator

func NewNullOutputCreator() *NullOutputCreator

Creates a new OutputCreator that will not save anything

func (*NullOutputCreator) Create

func (c *NullOutputCreator) Create(id string) (runner.Output, error)

Create creates a null output for id

type PollingStatusQuerier

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

PollingStatusQuerier turns a StatusQueryNower into a StatusQuerier

func NewPollingStatusQuerier

func NewPollingStatusQuerier(del runner.StatusQueryNower, period time.Duration) *PollingStatusQuerier

NewPollingStatusQuerier creates a new StatusQuerier by polling a StatusQueryNower that polls every period

func (*PollingStatusQuerier) Query

Query returns all RunStatus'es matching q, waiting as described by w

func (*PollingStatusQuerier) QueryNow

QueryNow returns all RunStatus'es matching q in their current state

func (*PollingStatusQuerier) Status

Status returns the current status of id from q.

func (*PollingStatusQuerier) StatusAll

StatusAll returns the Current status of all runs

type QueueController

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

QueueController maintains a queue of commands to run (up to capacity). Manages updates to underlying Filer via Filer's Update interface, if a non-zero update interval is defined (updates and tasks cannot run concurrently)

func (*QueueController) Abort

func (c *QueueController) Abort(run runner.RunID) (runner.RunStatus, error)

Abort kills the given run, returning its final status.

func (*QueueController) Release

func (c *QueueController) Release()

Cancels all goroutines created by this instance and exits run loop.

func (*QueueController) Run

Run enqueues the command or rejects it, returning its status or an error.

type Service

type Service struct {
	runner.Controller
	runner.StatusReader
}

Service makes a runner.Service from component parts.

type StatusManager

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

StatusManager is a database of RunStatus'es. It allows clients to Write StatusManager, Query the current status, and listen for updates to status. It implements runner.RunStatus

func NewStatusManager

func NewStatusManager(capacity int) *StatusManager

NewStatusManager creates a new empty StatusManager

func (*StatusManager) NewRun

func (s *StatusManager) NewRun() (runner.RunStatus, error)

NewRun creates a new RunID in state PENDING

func (*StatusManager) Query

func (s *StatusManager) Query(q runner.Query, wait runner.Wait) (rs []runner.RunStatus, ss runner.ServiceStatus, e error)

Query returns all RunStatus'es matching q, waiting as described by w, plus the overall service status.

func (*StatusManager) QueryNow

QueryNow returns all RunStatus'es matching q in their current state

func (*StatusManager) Status

Status returns the current status of id from q.

func (*StatusManager) StatusAll

func (s *StatusManager) StatusAll() ([]runner.RunStatus, runner.ServiceStatus, error)

StatusAll returns the Current status of all runs

func (*StatusManager) Update

func (s *StatusManager) Update(newStatus runner.RunStatus) error

Update writes a new status for a run. It enforces several rules:

cannot change a status once it is Done
cannot erase Stdout/Stderr Refs

func (*StatusManager) UpdateService

func (s *StatusManager) UpdateService(svcStatus runner.ServiceStatus) error

Update the overall service status independent of run status.

type StatusesRO

type StatusesRO []runner.RunStatus

StatusesRO is an adapter that lets you query a slice of RunStatus

func (StatusesRO) QueryNow

func (s StatusesRO) QueryNow(q runner.Query) ([]runner.RunStatus, error)

QueryNow satisfies runner.QueryNower

Jump to

Keyboard shortcuts

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