Documentation
¶
Index ¶
- type Config
- type ErrDuplicateTaskName
- type ErrorHandler
- type HookBinder
- type Task
- type TaskFunc
- type TaskName
- type Workflow
- func (w *Workflow) AppendTask(name TaskName, t Task) error
- func (w *Workflow) BindPostTaskHook(id TaskName, t Task)
- func (w *Workflow) BindPostWorkflowHook(t Task)
- func (w *Workflow) BindPreTaskHook(id TaskName, t Task)
- func (w *Workflow) BindPreWorkflowHook(t Task)
- func (w *Workflow) Execute(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ErrorHandler is handler called when a workflow experiences an error. The error may originate
// from hook or from a task. The original error is alwasy returned from the workflow's Execute.
// Optional. Defaults to a no-op handler.
ErrorHandler ErrorHandler
}
Config is the configuration for constructing a Workflow instance.
type ErrDuplicateTaskName ¶
type ErrDuplicateTaskName struct {
Name TaskName
}
ErrDuplicateTaskName indicates 2 tasks with the same TaskName have been added to a workflow.
func (ErrDuplicateTaskName) Error ¶
func (e ErrDuplicateTaskName) Error() string
type ErrorHandler ¶
ErrorHandler is a function called when a workflow experiences an error during execution. The error may originate from hook execution or from a task.
type HookBinder ¶
type HookBinder interface {
// BindPreWorkflowHook binds a task to a workflow that is run _before_ a workflow is executed.
BindPreWorkflowHook(Task)
// BindPostWorkflowHook binds a task to a workflow that is run _after_ a workflow is executed.
BindPostWorkflowHook(Task)
// BindPreTaskHook binds task to be run _before_ the anchor task is executed.
BindPreTaskHook(anchor TaskName, task Task)
// BindPostTaskHook binds Task to be run _after_ the anchor task is executed.
BindPostTaskHook(anchor TaskName, task Task)
}
HookBinder is used by hook registrars to bind tasks to be executed among the workflow's core task set.
type Task ¶
type Task interface {
// RunTask executes the task. Tasks may return a context that should be used in subsequent task
// execution.
RunTask(context.Context) (context.Context, error)
}
Task represents an individual step within a workflow that can be run.
type TaskFunc ¶ added in v0.13.0
TaskFunc is a helper for defining inline tasks. It is used by type converting a function to TaskFunc.
Example:
workflow.TaskFunc(func(ctx context.Context) (context.Context, error) {
return ctx, nil
})
type Workflow ¶
type Workflow struct {
Config
// contains filtered or unexported fields
}
Workflow defines an abstract workflow that can execute a serialized set of tasks.
func (*Workflow) AppendTask ¶
AppendTask appends t to the list of workflow tasks. Task names must be unique within a workflow. Duplicate names will receive an ErrDuplicateTaskName.
func (*Workflow) BindPostTaskHook ¶
BindPostHook implements the HookBinder interface.
func (*Workflow) BindPostWorkflowHook ¶
BindPostWorkflowHook implements the HookBinder interface.
func (*Workflow) BindPreTaskHook ¶
BindPreTaskHook implements the HookBinder interface.
func (*Workflow) BindPreWorkflowHook ¶
BindPreWorkflowHook implements the HookBinder interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
task
|
|
|
Package workflowcontext contains utility functions for populating workflow context specific data in a context.Context.
|
Package workflowcontext contains utility functions for populating workflow context specific data in a context.Context. |