Documentation
¶
Overview ¶
Package workflow builds typed DAGs of cron jobs.
Index ¶
- Variables
- type Builder
- type Condition
- type ConfigError
- type Execution
- func (e *Execution) Err() error
- func (e *Execution) Error(name string) error
- func (e *Execution) Errors() map[string]error
- func (e *Execution) Get[T any](output Output[T]) (T, bool)
- func (e *Execution) Result(name string) (Result, bool)
- func (e *Execution) Results() map[string]Result
- func (e *Execution) Step(name string) (StepReport, bool)
- func (e *Execution) Steps() map[string]StepReport
- type Inputs
- type Option
- type Output
- type Result
- type StepOption
- type StepReport
- type Unit
- type Workflow
Constants ¶
This section is empty.
Variables ¶
var ( ErrDuplicateStep = errors.New("workflow: duplicate step") ErrDuplicateDep = errors.New("workflow: duplicate dependency") ErrUnknownDep = errors.New("workflow: unknown dependency") ErrCycle = errors.New("workflow: dependency cycle") ErrNilJob = errors.New("workflow: step has no job") ErrInvalidName = errors.New("workflow: invalid step name") ErrInvalidOption = errors.New("workflow: invalid option") ErrBuilderFrozen = errors.New("workflow: builder is frozen") ErrNilContext = errors.New("workflow: nil context") )
Errors reported while configuring or executing a workflow.
Functions ¶
This section is empty.
Types ¶
type Builder ¶ added in v0.5.3
type Builder struct {
// contains filtered or unexported fields
}
Builder incrementally constructs one Workflow. Build freezes it. Builder is not safe for concurrent use; its zero value is ready to use.
func (*Builder) Build ¶ added in v0.5.3
Build validates the graph, freezes the Builder, and returns an immutable Workflow. Repeated calls return the same result.
func (*Builder) Job ¶ added in v0.5.3
Job adds a cron.Job step. Configuration errors are deferred to Build.
type Condition ¶
type Condition uint8
Condition selects the upstream result required by After.
const ( OnSuccess Condition OnFailure OnSkipped OnComplete )
type ConfigError ¶
ConfigError identifies the step involved in an invalid graph.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
func (*ConfigError) Unwrap ¶
func (e *ConfigError) Unwrap() error
type Execution ¶
type Execution struct {
ID uuid.UUID
StartedAt time.Time
Duration time.Duration
// contains filtered or unexported fields
}
Execution reports one completed Workflow run.
func (*Execution) Step ¶ added in v0.5.3
func (e *Execution) Step(name string) (StepReport, bool)
Step returns the named report.
func (*Execution) Steps ¶ added in v0.3.0
func (e *Execution) Steps() map[string]StepReport
Steps returns a copy of all reports.
type Inputs ¶ added in v0.3.0
type Inputs struct {
// contains filtered or unexported fields
}
Inputs exposes the successful outputs of a step's declared dependencies.
type Option ¶ added in v0.5.3
type Option func(*builderConfig) error
Option configures a Builder.
func WithMaxParallelism ¶ added in v0.5.3
WithMaxParallelism limits simultaneously running steps. The default is 32.
type Output ¶ added in v0.5.3
type Output[T any] struct { // contains filtered or unexported fields }
Output identifies one typed step output.
type StepOption ¶ added in v0.5.3
type StepOption func(*step) error
StepOption configures one step.
func After ¶
func After[T any](output Output[T], when Condition) StepOption
After declares an upstream dependency and its required result.
func WithRetry ¶ added in v0.5.3
func WithRetry(policy cron.RetryPolicy) StepOption
WithRetry applies a retry policy to one step.
func WithTimeout ¶ added in v0.5.3
func WithTimeout(timeout time.Duration) StepOption
WithTimeout caps one step run. Zero disables the timeout.
type StepReport ¶ added in v0.3.0
type StepReport struct {
Result Result
Err error
StartedAt time.Time
Duration time.Duration
// contains filtered or unexported fields
}
StepReport contains one step's outcome.
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow is an immutable DAG and implements cron.Job.
func (*Workflow) Execute ¶ added in v0.5.3
Execute runs the DAG once. At most the configured number of steps run at the same time.
func (*Workflow) WithOnComplete ¶
WithOnComplete returns a copy that calls cb before Execute returns.