taskrunner

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTaskRunner

func NewTaskRunner() *taskRunner

NewTaskRunner returns a new taskRunner. It can process taskqueues that does not contain any wait tasks.

func NewTaskStatusRunner

func NewTaskStatusRunner(identifiers []object.ObjMetadata, statusPoller poller.Poller) *taskStatusRunner

NewTaskStatusRunner returns a new TaskStatusRunner.

Types

type Condition added in v0.10.0

type Condition string

Condition is a type that defines the types of conditions which a WaitTask can use.

const (
	// AllCurrent Condition means all the provided resources
	// has reached (and remains in) the Current status.
	AllCurrent Condition = "AllCurrent"

	// AllNotFound Condition means all the provided resources
	// has reached the NotFound status, i.e. they are all deleted
	// from the cluster.
	AllNotFound Condition = "AllNotFound"
)

func (Condition) Meets added in v0.10.0

func (c Condition) Meets(s status.Status) bool

Meets returns true if the provided status meets the condition and false if it does not.

type Options added in v0.7.0

type Options struct {
	PollInterval     time.Duration
	UseCache         bool
	EmitStatusEvents bool
}

Options defines properties that is passed along to the statusPoller.

type Task

type Task interface {
	Start(taskContext *TaskContext)
	ClearTimeout()
}

Task is the interface that must be implemented by all tasks that will be executed by the taskrunner.

type TaskContext added in v0.7.0

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

TaskContext defines a context that is passed between all the tasks that is in a taskqueue.

func NewTaskContext added in v0.7.0

func NewTaskContext(eventChannel chan event.Event) *TaskContext

NewTaskContext returns a new TaskContext

func (*TaskContext) EventChannel added in v0.7.0

func (tc *TaskContext) EventChannel() chan event.Event

func (*TaskContext) ResourceApplied added in v0.8.0

func (tc *TaskContext) ResourceApplied(id object.ObjMetadata, gen int64)

ResourceApplied updates the context with information about the resource identified by the provided id. Currently, we keep information about the generation of the resource after the apply operation completed.

func (*TaskContext) ResourceGeneration added in v0.8.0

func (tc *TaskContext) ResourceGeneration(id object.ObjMetadata) int64

ResourceGeneration looks up the generation of the given resource after it was applied.

func (*TaskContext) TaskChannel added in v0.7.0

func (tc *TaskContext) TaskChannel() chan TaskResult

type TaskResult

type TaskResult struct {
	Err error
}

TaskResult is the type returned from tasks once they have completed or failed. If it has failed or timed out, the Err property will be set.

type TimeoutError added in v0.10.0

type TimeoutError struct {
	// Identifiers contains the identifiers of all resources that the
	// WaitTask was waiting for.
	Identifiers []object.ObjMetadata

	// Timeout is the amount of time it took before it timed out.
	Timeout time.Duration

	// Condition defines the criteria for which the task was waiting.
	Condition Condition
}

TimeoutError is a special error used by tasks when they have timed out.

func IsTimeoutError

func IsTimeoutError(err error) (TimeoutError, bool)

IsTimeoutError checks whether a given error is a TimeoutError.

func (TimeoutError) Error added in v0.10.0

func (te TimeoutError) Error() string

type WaitTask

type WaitTask struct {
	// Identifiers is the list of resources that we are waiting for.
	Identifiers []object.ObjMetadata
	// Condition defines the status we want all resources to reach
	Condition Condition
	// Timeout defines how long we are willing to wait for the condition
	// to be met.
	Timeout time.Duration
	// contains filtered or unexported fields
}

WaitTask is an implementation of the Task interface that is used to wait for a set of resources (identified by a slice of ObjMetadata) will all meet the condition specified. It also specifies a timeout for how long we are willing to wait for this to happen. Unlike other implementations of the Task interface, the wait task is handled in a special way to the taskrunner and is a part of the core package.

func NewWaitTask

func NewWaitTask(ids []object.ObjMetadata, cond Condition, timeout time.Duration) *WaitTask

NewWaitTask creates a new wait task where we will wait until the resources specifies by ids all meet the specified condition.

func (*WaitTask) ClearTimeout

func (w *WaitTask) ClearTimeout()

ClearTimeout cancels the timeout for the wait task.

func (*WaitTask) Start

func (w *WaitTask) Start(taskContext *TaskContext)

Start kicks off the task. For the wait task, this just means setting up the timeout timer.

Jump to

Keyboard shortcuts

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