tasks

package
v1.4.10-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tasks provides an API for supervising system processes as Task's. It provides stronger guarantees with respect to process lifecycle than a standalone kubelet running static pods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Completion

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

Completion represents the termination of a Task process. Each process execution should yield (barring drops because of an abort signal) exactly one Completion.

type Events

type Events interface {
	// Close stops delivery of events in the completion and errors channels; callers must close this when they intend to no longer read from completion() or errors()
	Close() Events

	// Completion reports Completion events as they happen
	Completion() <-chan *Completion

	// Done returns a signal chan that closes when all tasks have completed and there are no more events to deliver
	Done() <-chan struct{}
}

func MergeOutput

func MergeOutput(tasks []*Task, shouldQuit <-chan struct{}) Events

MergeOutput waits for the given tasks to complete. meanwhile it logs each time a task process completes or generates an error. when shouldQuit closes, tasks are canceled and this func eventually returns once all ongoing event handlers have completed running.

type Option added in v1.2.0

type Option func(*Task) Option

Option is a functional option type for a Task that returns an "undo" Option after upon modifying the Task

func Environment added in v1.2.0

func Environment(env []string) Option

Environment customizes the process runtime environment for a Task

func NoRespawn added in v1.2.0

func NoRespawn(listener chan<- struct{}) Option

NoRespawn configures the Task lifecycle such that it will not respawn upon termination

type Task

type Task struct {
	Env          []string                   // optional: process environment override
	Finished     func(restarting bool) bool // callback invoked when a task process has completed; if `restarting` then it will be restarted if it returns true
	RestartDelay time.Duration              // interval between repeated task restarts
	// contains filtered or unexported fields
}

task is a specification for running a system process; it provides hooks for customizing logging and restart handling as well as provides event channels for communicating process termination and errors related to process management.

func New

func New(name, bin string, args []string, cl func() io.WriteCloser, options ...Option) *Task

New builds a newly initialized task object but does not start any processes for it. callers are expected to invoke task.run(...) on their own.

func (*Task) Start

func (t *Task) Start()

Start spawns a goroutine to execute the Task. Panics if invoked more than once.

Jump to

Keyboard shortcuts

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