tasks

package
v0.0.0-...-da10ef3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2016 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 Task

type Task struct {
	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, env []string, cl func() io.WriteCloser) *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