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) 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 ¶
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 ¶
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 ¶
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.