Documentation ¶
Index ¶
- type Condition
- type Options
- type Task
- type TaskContext
- func (tc *TaskContext) AbandonedObjects() object.ObjMetadataSet
- func (tc *TaskContext) AddAbandonedObject(id object.ObjMetadata)
- func (tc *TaskContext) AddInvalidObject(id object.ObjMetadata)
- func (tc *TaskContext) EventChannel() chan event.Event
- func (tc *TaskContext) Graph() *graph.Graph
- func (tc *TaskContext) InvalidObjects() object.ObjMetadataSet
- func (tc *TaskContext) InventoryManager() *inventory.Manager
- func (tc *TaskContext) IsAbandonedObject(id object.ObjMetadata) bool
- func (tc *TaskContext) IsInvalidObject(id object.ObjMetadata) bool
- func (tc *TaskContext) ResourceCache() cache.ResourceCache
- func (tc *TaskContext) SendEvent(e event.Event)
- func (tc *TaskContext) SetGraph(g *graph.Graph)
- func (tc *TaskContext) TaskChannel() chan TaskResult
- type TaskResult
- type TaskStatusRunner
- type WaitTask
- func (w *WaitTask) Action() event.ResourceAction
- func (w *WaitTask) Cancel(_ *TaskContext)
- func (w *WaitTask) Identifiers() object.ObjMetadataSet
- func (w *WaitTask) Name() string
- func (w *WaitTask) Start(taskContext *TaskContext)
- func (w *WaitTask) StatusUpdate(taskContext *TaskContext, id object.ObjMetadata)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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" )
type Options ¶ added in v0.7.0
type Options struct {
EmitStatusEvents bool
}
Options defines properties that is passed along to the statusPoller.
type Task ¶
type Task interface { Name() string Action() event.ResourceAction Identifiers() object.ObjMetadataSet Start(*TaskContext) StatusUpdate(*TaskContext, object.ObjMetadata) Cancel(*TaskContext) }
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, resourceCache cache.ResourceCache) *TaskContext
NewTaskContext returns a new TaskContext
func (*TaskContext) AbandonedObjects ¶ added in v0.27.0
func (tc *TaskContext) AbandonedObjects() object.ObjMetadataSet
AbandonedObjects returns all the abandoned objects
func (*TaskContext) AddAbandonedObject ¶ added in v0.27.0
func (tc *TaskContext) AddAbandonedObject(id object.ObjMetadata)
AddAbandonedObject registers that the object is abandoned
func (*TaskContext) AddInvalidObject ¶ added in v0.28.0
func (tc *TaskContext) AddInvalidObject(id object.ObjMetadata)
AddInvalidObject registers that the object is abandoned
func (*TaskContext) EventChannel ¶ added in v0.7.0
func (tc *TaskContext) EventChannel() chan event.Event
func (*TaskContext) Graph ¶ added in v0.29.0
func (tc *TaskContext) Graph() *graph.Graph
func (*TaskContext) InvalidObjects ¶ added in v0.28.0
func (tc *TaskContext) InvalidObjects() object.ObjMetadataSet
InvalidObjects returns all the abandoned objects
func (*TaskContext) InventoryManager ¶ added in v0.28.0
func (tc *TaskContext) InventoryManager() *inventory.Manager
func (*TaskContext) IsAbandonedObject ¶ added in v0.27.0
func (tc *TaskContext) IsAbandonedObject(id object.ObjMetadata) bool
IsAbandonedObject returns true if the object is abandoned
func (*TaskContext) IsInvalidObject ¶ added in v0.28.0
func (tc *TaskContext) IsInvalidObject(id object.ObjMetadata) bool
IsInvalidObject returns true if the object is abandoned
func (*TaskContext) ResourceCache ¶ added in v0.26.0
func (tc *TaskContext) ResourceCache() cache.ResourceCache
func (*TaskContext) SendEvent ¶ added in v0.27.0
func (tc *TaskContext) SendEvent(e event.Event)
SendEvent sends an event on the event channel
func (*TaskContext) SetGraph ¶ added in v0.29.0
func (tc *TaskContext) SetGraph(g *graph.Graph)
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 TaskStatusRunner ¶ added in v0.28.0
type TaskStatusRunner struct { Identifiers object.ObjMetadataSet StatusWatcher watcher.StatusWatcher }
TaskStatusRunner is a taskRunner that executes a set of tasks while at the same time uses the statusPoller to keep track of the status of the resources.
func NewTaskStatusRunner ¶
func NewTaskStatusRunner(identifiers object.ObjMetadataSet, statusWatcher watcher.StatusWatcher) *TaskStatusRunner
NewTaskStatusRunner returns a new TaskStatusRunner.
func (*TaskStatusRunner) Run ¶ added in v0.28.0
func (tsr *TaskStatusRunner) Run( ctx context.Context, taskContext *TaskContext, taskQueue chan Task, opts Options, ) error
Run executes the tasks in the taskqueue, with the statusPoller running in the background.
The tasks run in a loop where a single goroutine will process events from three different channels.
- taskQueue is read to allow updating the task queue at runtime.
- statusChannel is read to allow updates to the resource cache and triggering validation of wait conditions.
- eventChannel is written to with events based on status updates, if emitStatusEvents is true.
type WaitTask ¶
type WaitTask struct { // TaskName allows providing a name for the task. TaskName string // Ids is the full list of resources that we are waiting for. Ids object.ObjMetadataSet // 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 // Mapper is the RESTMapper to update after CRDs have been reconciled Mapper meta.RESTMapper // 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(name string, ids object.ObjMetadataSet, cond Condition, timeout time.Duration, mapper meta.RESTMapper) *WaitTask
NewWaitTask creates a new wait task where we will wait until the resources specifies by ids all meet the specified condition.
func (*WaitTask) Action ¶ added in v0.26.0
func (w *WaitTask) Action() event.ResourceAction
func (*WaitTask) Cancel ¶ added in v0.27.0
func (w *WaitTask) Cancel(_ *TaskContext)
Cancel exits early with a timeout error
func (*WaitTask) Identifiers ¶
func (w *WaitTask) Identifiers() object.ObjMetadataSet
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.
func (*WaitTask) StatusUpdate ¶ added in v0.27.0
func (w *WaitTask) StatusUpdate(taskContext *TaskContext, id object.ObjMetadata)
StatusUpdate records objects status updates and sends WaitEvents. If all objects are reconciled or skipped, cancelFunc is called. The pending set is write locked during execution of StatusUpdate.