Documentation ¶
Overview ¶
Package flow provides utilities to construct a directed acyclic computational graph that is then executed and monitored with maximum parallelism.
Index ¶
- func Causes(err error) *multierror.Error
- func Errors(err error) *multierror.Error
- func WasCanceled(err error) bool
- type Flow
- type Graph
- type Opts
- type ProgressReporter
- type RecoverFn
- type Stats
- type Task
- type TaskFn
- func (t TaskFn) DoIf(condition bool) TaskFn
- func (t TaskFn) Recover(recoverFn RecoverFn) TaskFn
- func (t TaskFn) RecoverTimeout(recoverFn RecoverFn) TaskFn
- func (t TaskFn) Retry(interval time.Duration) TaskFn
- func (t TaskFn) RetryUntilTimeout(interval, timeout time.Duration) TaskFn
- func (t TaskFn) SkipIf(condition bool) TaskFn
- func (t TaskFn) ToRecoverFn() RecoverFn
- type TaskID
- type TaskIDSlice
- type TaskIDer
- type TaskIDs
- func (t TaskIDs) Copy() TaskIDs
- func (t TaskIDs) Delete(iders ...TaskIDer)
- func (t TaskIDs) Has(id TaskID) bool
- func (t TaskIDs) Insert(iders ...TaskIDer)
- func (t TaskIDs) Len() int
- func (t TaskIDs) List() TaskIDSlice
- func (t TaskIDs) StringList() []string
- func (t TaskIDs) TaskIDs() []TaskID
- func (t TaskIDs) UnsortedList() TaskIDSlice
- func (t TaskIDs) UnsortedStringList() []string
- type TaskSpec
- type Tasks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Causes ¶
func Causes(err error) *multierror.Error
Causes reports the causes of all Task errors of the given Flow error.
func Errors ¶
func Errors(err error) *multierror.Error
Errors reports all wrapped Task errors of the given Flow error.
func WasCanceled ¶
WasCanceled determines whether the given flow error was caused by cancellation.
Types ¶
type Flow ¶
type Flow struct {
// contains filtered or unexported fields
}
Flow is a validated executable Graph.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a builder for a Flow.
func (*Graph) Add ¶
Add adds the given Task to the graph. This panics if - There is already a Task present with the same name - One of the dependencies of the Task is not present
type Opts ¶
type Opts struct { Logger logrus.FieldLogger ProgressReporter func(stats *Stats) Context context.Context }
Opts are options for a Flow execution. If they are not set, they are left blank and don't affect the Flow.
type ProgressReporter ¶
type ProgressReporter func(*Stats)
ProgressReporter is continuously called on progress in a flow.
type Stats ¶
Stats are the statistics of a Flow execution.
func InitialStats ¶
InitialStats creates a new Stats object with the given set of initial TaskIDs. The initial TaskIDs are added to all TaskIDs as well as to the pending ones.
func (*Stats) ProgressPercent ¶
ProgressPercent retrieves the progress of a Flow execution in percent.
type Task ¶
Task is a unit of work. It has a name, a payload function and a set of dependencies. A is only started once all its dependencies have been completed successfully.
type TaskFn ¶
TaskFn is a payload function of a task.
EmptyTaskFn is a TaskFn that does nothing (returns nil).
func SimpleTaskFn ¶
SimpleTaskFn converts the given function to a TaskFn, disrespecting any context.Context it is being given. deprecated: Only used during transition period. Do not use for new functions.
func (TaskFn) DoIf ¶
DoIf returns a TaskFn that will be executed if the condition is true when it is called. Otherwise, it will do nothing when called.
func (TaskFn) Recover ¶
Recover creates a new TaskFn that recovers an error with the given RecoverFn.
func (TaskFn) RecoverTimeout ¶
RecoverTimeout creates a new TaskFn that recovers an error that satisfies `utils.IsTimedOut` with the given RecoverFn.
func (TaskFn) RetryUntilTimeout ¶
RetryUntilTimeout returns a TaskFn that is retried until the timeout is reached.
func (TaskFn) SkipIf ¶
SkipIf returns a TaskFn that does nothing if the condition is true, otherwise the function will be executed once called.
func (TaskFn) ToRecoverFn ¶
ToRecoverFn converts the TaskFn to a RecoverFn that ignores the incoming error.
type TaskIDSlice ¶
type TaskIDSlice []TaskID
TaskIDSlice is a slice of TaskIDs.
func (TaskIDSlice) Len ¶
func (t TaskIDSlice) Len() int
func (TaskIDSlice) Less ¶
func (t TaskIDSlice) Less(i1, i2 int) bool
func (TaskIDSlice) Swap ¶
func (t TaskIDSlice) Swap(i1, i2 int)
func (TaskIDSlice) TaskIDs ¶
func (t TaskIDSlice) TaskIDs() []TaskID
TaskIDs returns this as a slice of TaskIDs.
type TaskIDer ¶
type TaskIDer interface { // TaskIDs reports all TaskIDs of this TaskIDer. TaskIDs() []TaskID }
TaskIDer can produce a slice of TaskIDs. Default implementations of this are TaskIDs, TaskID and TaskIDSlice
type TaskIDs ¶
type TaskIDs map[TaskID]struct{}
TaskIDs is a set of TaskID.
func NewTaskIDs ¶
NewTaskIDs returns a new set of TaskIDs initialized to contain all TaskIDs of the given TaskIDers.
func (TaskIDs) List ¶
func (t TaskIDs) List() TaskIDSlice
List returns the elements of this in an ordered slice.
func (TaskIDs) StringList ¶
StringList returns the elements of this in an ordered string slice.
func (TaskIDs) UnsortedList ¶
func (t TaskIDs) UnsortedList() TaskIDSlice
UnsortedList returns the elements of this in an unordered slice.
func (TaskIDs) UnsortedStringList ¶
UnsortedStringList returns the elements of this in an unordered string slice.