tasker

package
v0.0.0-...-eec41c3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command uint8

Command is number that uniquely identifies a command function.

const (
	// CmdNOOP does nothing. It is a default placeholder. Uninitialized variable of this type will point to NOOP command by default.
	CmdNOOP Command = iota
	// CmdSignalEnd gracefully ends current task. Never ending tasks (loop over) or Batched jobs will not take the next iteration,
	// but may finish the current state to completion.
	CmdSignalEnd
	// CmdSignalAbort ends the current task at hand immediately. It may still cleanup dangling issues quickly.
	CmdSignalAbort
	// CmdSignalSuspend suspends the current task.
	CmdSignalSuspend
	// CmdSignalResume resumes a suspended task.
	CmdSignalResume
	// CmdPriorityLow is optimized to conserve resources and complete the task at a slow pace. This option is ideal for batch processed tasks.
	CmdPriorityLow
	// CmdPriorityMedium is the default priority. It is a balanced option between resources and speed.
	CmdPriorityMedium
	// CmdPriorityHigh is optimized for speed. This option is ideal for short lived tasks (like meta-data related) that are latency sensitive. Use this option wisely.
	CmdPriorityHigh
	// CmdPrioritySuper is an exclusive priority. All tasks with priority lower than Super (including High) are paused
	// temporarily until this task completes. Anytime you consider using this priority level, please seek for approval.
	CmdPrioritySuper
)

Enumerate the task commands.

type Handle

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

Handle as the name suggests is a handle (self reference) to its own task structure. Task has limited privileges over itself. Only the task controller (TaskCtl) can manage the task by sending commands to the task over channels.

func (Handle) Close

func (t Handle) Close()

Close notifies the TaskCtl about the end of this Task. Owner of the task must invoke Close() when it is done performing its job.

func (Handle) Listen

func (t Handle) Listen() <-chan Command

Listen returns a channel to receive commands.

func (Handle) StatusBusy

func (t Handle) StatusBusy()

StatusBusy rejects a command with busy status.

func (Handle) StatusDone

func (t Handle) StatusDone()

StatusDone acknowledges successful completion of a command.

func (Handle) StatusFail

func (t Handle) StatusFail(err *probe.Error)

StatusFail returns failure status.

type TaskCtl

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

TaskCtl (Task Controller) is a framework to create and manage tasks.

func New

func New(name string) *TaskCtl

New creates a new TaskCtl to create and control a collection of tasks. Single application can create multiple task controllers to manage different set of tasks separately.

func (*TaskCtl) NewTask

func (tc *TaskCtl) NewTask(name string) Handle

NewTask creates a new task structure and returns a handle to it. Only the task controller has access to the task structure. The caller routine only receives a handle to its task structure. Task handle is like a reference to task self. Caller is expected to listen for commands from the task controller and comply with it co-operatively.

func (*TaskCtl) Resume

func (tc *TaskCtl) Resume() bool

Resume wakes up all suspended task from sleep.

func (*TaskCtl) Shutdown

func (tc *TaskCtl) Shutdown()

Shutdown ends all tasks, including the suspended ones.

func (*TaskCtl) Suspend

func (tc *TaskCtl) Suspend() bool

Suspend puts all tasks to sleep.

Jump to

Keyboard shortcuts

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