Documentation ¶
Index ¶
- func Run(queue Queue, ctx context.Context) error
- type ContextProvider
- type Queue
- type Task
- func (a Task) Do(ctx context.Context) error
- func (a Task) Guard() Task
- func (a Task) Queue(tasks ...Task) Task
- func (a Task) QueueWithPriority(priority int, tasks ...Task) Task
- func (a Task) RequireValue(key string) Task
- func (a Task) RunOnce(f *bool, t Task) Task
- func (a Task) Then(b Task) Task
- func (a Task) Using(f ContextProvider) Task
- func (a Task) UsingValue(key string, f ValueProvider) Task
- func (a Task) WithContext(srcCtx context.Context, keys ...string) Task
- func (a Task) WithValue(key string, value interface{}) Task
- type ValueProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextProvider ¶ added in v1.2.0
ContextProvider provides a context based on another, used by Using
type Task ¶
Task is a task that the Generator must run once all other Handler's have been run. They are usually tasks created by those Handlers.
func (Task) Guard ¶ added in v1.2.0
Guard wraps a task so that any error or panic returned by that task is ignored. It is used when you don't want the task to stop all other processing.
func (Task) Queue ¶
Queue will defer the queued task onto the underlying Queue. If one or more tasks are provided then they will be queued if the flow reaches this location. If none, then the current task will be queued when run.
func (Task) QueueWithPriority ¶
QueueWithPriority will defer the queued task onto the underlying Queue with a priority If one or more tasks are provided then they will be queued if the flow reaches this location. If none, then the current task will be queued when run.
func (Task) RequireValue ¶
RequireValue ensures that a key is defined within the current Context.
func (Task) RunOnce ¶
RunOnce will invoke a task exactly once. It uses a pointer to a boolean to store this state. It's useful for simple tasks but should be treated as Deprecated. Currently, here as Book still uses it as it only works for one Book not multiple books.
func (Task) Using ¶ added in v1.2.0
func (a Task) Using(f ContextProvider) Task
Using allows a ContextProvider to be used in a task, an alternate method to UsingValue
func (Task) UsingValue ¶ added in v1.2.0
func (a Task) UsingValue(key string, f ValueProvider) Task
UsingValue adds a named value to the context before passing it to the parent task
func (Task) WithContext ¶
WithContext copies the specified keys from a source context. It's the equivalent of WithValue(key,srcCtx.Value(key))
type ValueProvider ¶ added in v1.2.0
ValueProvider provides a value at runtime, used with UsingValue