Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
Executor is an implementation prototype for an object capable of running multiple tasks
func NewSerialExecutor ¶
NewSerialExecutor creates a new SerialExecutor, which can execute the slice of tasks serially.
type RunningExecutor ¶
type RunningExecutor struct {
// contains filtered or unexported fields
}
RunningExecutor is an implementation of RunningTask which executes an Executor on a separate go routine, then returns the result over a channel.
func (*RunningExecutor) Description ¶
func (re *RunningExecutor) Description() string
Description returns the description of the executor.
func (*RunningExecutor) OnComplete ¶
func (re *RunningExecutor) OnComplete() <-chan error
OnComplete returns the outbound channel that occurs when the executor is complete
type RunningTask ¶
type RunningTask interface { // Description of the task. Description() string // The completion channel OnComplete() <-chan error }
RunningTask is an implementation prototype for the execution of a task in the running state.
func ExecuteSerially ¶
func ExecuteSerially(tasks []Task, description string) RunningTask
ExecuteSerially executes the provided tasks in order asynchronously via RunningTask, and returns the running task.
func RunExecutor ¶
func RunExecutor(e Executor) RunningTask
RunExecutor creates a new RunningTask implementation and starts executing the Executor in a separate go routine
type SerialExecutor ¶
type SerialExecutor struct {
// contains filtered or unexported fields
}
SerialExecutor is a task executor which executes each child task serially. It also implements the Task interface so it can be used to represent a single task as well.
func (*SerialExecutor) Description ¶
func (se *SerialExecutor) Description() string
Description returns a description of the execution steps.
func (*SerialExecutor) Execute ¶
func (se *SerialExecutor) Execute() error
Executes each child task serially and reports any errors
func (*SerialExecutor) IsRunning ¶
func (se *SerialExecutor) IsRunning() bool
Wheather or not the task is running
type Task ¶
type Task interface { // Executes a task and returns an error of one occurs Execute() error // Description of the task. Description() string }
Task is an implementation prototype that represents an executable task with status message
func TaskForError ¶
TaskFor returns a specific Task context for an error iff the error was a task error. Otherwise, nil is returned.
func TaskFromFunc ¶
TaskFromFunc returns a Task implementation for a func() error.
type TaskQueue ¶
type TaskQueue []Task
TaskQueue is a FIFO implementation for tasks.
func NewTaskQueue ¶
NewTaskQueue creates a new task queue and enqueues all tasks from the provided slice.
func (*TaskQueue) Dequeue ¶
Deqeue removes the first item from the queue. If there are no items in the queue, nil is returned.
func (*TaskQueue) DrainTo ¶
DrainTo drains the queue to a buffered channel of tasks. Note that this method could block if the buffered channel length is hit
func (*TaskQueue) ReceiveFrom ¶
Enqueue tasks from an input channel buffer of tasks. Note that this method could block if the buffered channel isn't closed.