Versions in this module Expand all Collapse all v0 v0.1.3 Jun 4, 2024 Changes in this version + const TraverseContinue + const TraverseEndBranch + const TraverseStop + var DefaultRetryOption = RetryOption + var ErrWorkflowIsRunning = fmt.Errorf("Workflow is running, please wait for it terminated") + func As[T Steper](s Steper) []T + func ConditionOrDefault(cond Condition) func(context.Context, map[Steper]StepResult) StepStatus + func HasStep(step, target Steper) bool + func Has[T Steper](s Steper) bool + func Keys[M ~map[K]V, K comparable, V any](m M) []K + func LogValue(step Steper) logValue + func String(step Steper) string + func Values[M ~map[K]V, K comparable, V any](m M) []V + func WithStackTraces(skip, depth int, ignores ...func(runtime.Frame) bool) func(error) error + type AddStep struct + Steps []S + func Step[S Steper](steps ...S) AddStep[S] + func (as AddStep[S]) AfterStep(afters ...AfterStep) AddStep[S] + func (as AddStep[S]) BeforeStep(befores ...BeforeStep) AddStep[S] + func (as AddStep[S]) DependsOn(ups ...Steper) AddStep[S] + func (as AddStep[S]) Input(fns ...func(context.Context, S) error) AddStep[S] + func (as AddStep[S]) Output(fns ...func(context.Context, S) error) AddStep[S] + func (as AddStep[S]) Retry(fns ...func(*RetryOption)) AddStep[S] + func (as AddStep[S]) Timeout(timeout time.Duration) AddStep[S] + func (as AddStep[S]) When(when Condition) AddStep[S] + type AddSteps map[Steper]*StepConfig + func BatchPipe(batch ...AddSteps) AddSteps + func Pipe(steps ...Steper) AddSteps + func Steps(steps ...Steper) AddSteps + func (as AddSteps) AddToWorkflow() map[Steper]*StepConfig + func (as AddSteps) AfterStep(afters ...AfterStep) AddSteps + func (as AddSteps) BeforeStep(befores ...BeforeStep) AddSteps + func (as AddSteps) DependsOn(ups ...Steper) AddSteps + func (as AddSteps) Merge(others ...AddSteps) AddSteps + func (as AddSteps) Retry(opts ...func(*RetryOption)) AddSteps + func (as AddSteps) Timeout(timeout time.Duration) AddSteps + func (as AddSteps) When(cond Condition) AddSteps + type AfterStep func(context.Context, Steper, error) error + type BeforeStep func(context.Context, Steper) (context.Context, error) + type BranchCheck struct + Check BranchCheckFunc[T] + Error error + OK bool + func (bc *BranchCheck[T]) Do(ctx context.Context, target T) + type BranchCheckFunc func(context.Context, T) (bool, error) + type Condition func(ctx context.Context, ups map[Steper]StepResult) StepStatus + var DefaultCondition Condition = AllSucceeded + var DefaultIsCanceled = func(err error) bool { ... } + type ErrBeforeStep struct + func (e ErrBeforeStep) Unwrap() error + type ErrCancel struct + func Cancel(err error) ErrCancel + func (e ErrCancel) Unwrap() error + type ErrCycleDependency map[Steper][]Steper + func (e ErrCycleDependency) Error() string + type ErrPanic struct + func (e ErrPanic) Unwrap() error + type ErrSkip struct + func Skip(err error) ErrSkip + func (e ErrSkip) Unwrap() error + type ErrSucceed struct + func Succeed(err error) ErrSucceed + func (e ErrSucceed) Unwrap() error + type ErrWithStackTraces struct + Err error + Frames []runtime.Frame + func (e ErrWithStackTraces) Error() string + func (e ErrWithStackTraces) StackTraces() []string + func (e ErrWithStackTraces) Unwrap() error + type ErrWorkflow map[Steper]StepResult + func (e ErrWorkflow) AllSucceeded() bool + func (e ErrWorkflow) AllSucceededOrSkipped() bool + func (e ErrWorkflow) Error() string + func (e ErrWorkflow) Unwrap() []error + type Function struct + DoFunc func(context.Context, I) (O, error) + Input I + Name string + Output O + func Func(name string, do func(context.Context) error) *Function[struct{}, struct{}] + func FuncIO[I, O any](name string, do func(context.Context, I) (O, error)) *Function[I, O] + func FuncI[I any](name string, do func(context.Context, I) error) *Function[I, struct{}] + func FuncO[O any](name string, do func(context.Context) (O, error)) *Function[struct{}, O] + func (f *Function[I, O]) Do(ctx context.Context) error + func (f *Function[I, O]) String() string + type IfBranch struct + BranchCheck BranchCheck[T] + Cond Condition + ElseStep []Steper + Target T + ThenStep []Steper + func If[T Steper](target T, check BranchCheckFunc[T]) *IfBranch[T] + func (i *IfBranch[T]) AddToWorkflow() map[Steper]*StepConfig + func (i *IfBranch[T]) Else(el ...Steper) *IfBranch[T] + func (i *IfBranch[T]) Then(th ...Steper) *IfBranch[T] + func (i *IfBranch[T]) When(cond Condition) *IfBranch[T] + type MockStep struct + MockDo func(context.Context) error + Step Steper + func (m *MockStep) Do(ctx context.Context) error + func (m *MockStep) Unwrap() Steper + type NamedStep struct + Name string + func (ns *NamedStep) String() string + func (ns *NamedStep) Unwrap() Steper + type NoOpStep struct + Name string + func NoOp(name string) *NoOpStep + func (*NoOpStep) Do(context.Context) error + func (n *NoOpStep) String() string + type RetryEvent struct + Attempt uint64 + Error error + Since time.Duration + type RetryOption struct + Attempts uint64 + Backoff backoff.BackOff + NextBackOff func(ctx context.Context, re RetryEvent, nextBackOff time.Duration) time.Duration + Notify backoff.Notify + TimeoutPerTry time.Duration + Timer backoff.Timer + type Set map[T]struct + func (s *Set[T]) Add(vs ...T) + func (s *Set[T]) Union(sets ...Set[T]) + func (s Set[T]) Flatten() []T + func (s Set[T]) Has(v T) bool + type State struct + Config *StepConfig + func (s *State) AddUpstream(up Steper) + func (s *State) After(ctx context.Context, step Steper, err error) error + func (s *State) Before(ctx context.Context, step Steper) (context.Context, error) + func (s *State) GetError() error + func (s *State) GetStatus() StepStatus + func (s *State) GetStepResult() StepResult + func (s *State) MergeConfig(sc *StepConfig) + func (s *State) Option() *StepOption + func (s *State) SetError(err error) + func (s *State) SetStatus(ss StepStatus) + func (s *State) Upstreams() Set[Steper] + type StepBuilder struct + func (sb *StepBuilder) BuildStep(s Steper) + type StepConfig struct + After []AfterStep + Before []BeforeStep + Option []func(*StepOption) + Upstreams Set[Steper] + func (sc *StepConfig) Merge(other *StepConfig) + type StepOption struct + Condition Condition + RetryOption *RetryOption + Timeout *time.Duration + type StepResult struct + Err error + Status StepStatus + func (e StepResult) Error() string + func (e StepResult) Unwrap() error + type StepStatus string + const Canceled + const Failed + const Pending + const Running + const Skipped + const Succeeded + func AllSucceeded(ctx context.Context, ups map[Steper]StepResult) StepStatus + func AllSucceededOrSkipped(ctx context.Context, ups map[Steper]StepResult) StepStatus + func Always(context.Context, map[Steper]StepResult) StepStatus + func AnyFailed(ctx context.Context, ups map[Steper]StepResult) StepStatus + func AnySucceeded(ctx context.Context, ups map[Steper]StepResult) StepStatus + func BeCanceled(ctx context.Context, ups map[Steper]StepResult) StepStatus + func StatusFromError(err error) StepStatus + func (s StepStatus) IsTerminated() bool + func (s StepStatus) String() string + type Steper interface + Do func(context.Context) error + func ToSteps[S Steper](steps []S) []Steper + type StringerNamedStep struct + Name fmt.Stringer + func (sns *StringerNamedStep) String() string + func (sns *StringerNamedStep) Unwrap() Steper + type SwitchBranch struct + CasesToCheck map[Steper]*BranchCheck[T] + Cond Condition + DefaultStep []Steper + Target T + func Switch[T Steper](target T) *SwitchBranch[T] + func (s *SwitchBranch[T]) AddToWorkflow() map[Steper]*StepConfig + func (s *SwitchBranch[T]) Case(step Steper, check BranchCheckFunc[T]) *SwitchBranch[T] + func (s *SwitchBranch[T]) Cases(steps []Steper, check BranchCheckFunc[T]) *SwitchBranch[T] + func (s *SwitchBranch[T]) Default(step ...Steper) *SwitchBranch[T] + func (s *SwitchBranch[T]) When(cond Condition) *SwitchBranch[T] + type TraverseDecision int + func Traverse(s Steper, f func(Steper, []Steper) TraverseDecision, walked ...Steper) TraverseDecision + type Workflow struct + Clock clock.Clock + DontPanic bool + MaxConcurrency int + SkipAsError bool + func (w *Workflow) Add(was ...WorkflowAdder) *Workflow + func (w *Workflow) Do(ctx context.Context) error + func (w *Workflow) Empty() bool + func (w *Workflow) IsTerminated() bool + func (w *Workflow) Reset() error + func (w *Workflow) RootOf(step Steper) Steper + func (w *Workflow) StateOf(step Steper) *State + func (w *Workflow) Steps() []Steper + func (w *Workflow) Unwrap() []Steper + func (w *Workflow) UpstreamOf(step Steper) map[Steper]StepResult + type WorkflowAdder interface + AddToWorkflow func() map[Steper]*StepConfig + func Mock[T Steper](step T, do func(context.Context) error) WorkflowAdder + func Name(step Steper, name string) WorkflowAdder + func NameFunc(step Steper, fn func() string) WorkflowAdder + func NameStringer(step Steper, name fmt.Stringer) WorkflowAdder + func Names(m map[Steper]string) WorkflowAdder