Documentation ¶
Index ¶
Constants ¶
const NoTimeout = time.Duration(0)
Variables ¶
This section is empty.
Functions ¶
func CreateMermaidStepFlowchart ¶
CreateMermaidStepFlowchart creates a Mermaid flowchart from the given steps' dependencies.
Types ¶
type Step ¶
type Step struct { // Name is the name of the step. It must be unique within the release step graph. Name string // Timeout defines the deadline that should be set up for the ctx passed to Func. // If NoTimeout (zero), no deadline is set. Timeout time.Duration // Func is the implementation of the step. It is executed when the step is run. // It is run in its own goroutine and may block on network calls, retries, etc. // It shouldn't wait for another step to complete: this should be done using DependsOn. Func StepFunc // DependsOn is a list of steps that must all complete before Func is run. DependsOn []*Step }
Step represents a step in the release. Just enough information is represented in Step to allow status to be reported, otherwise state is internal to Func.
func NewIndicatorStep ¶
NewIndicatorStep creates a new step with the given name and no implementation. An indicator step generally helps a release runner understand the step graph more easily by indicating what it means for a set of steps to complete, and clarify what other steps take a dependency on.
func NewRootStep ¶
NewRootStep creates a new step with the given name, implementation, and no dependencies.
func NewStep ¶
NewStep creates a new step with the given name, implementation, and dependencies. dependsOn must contain at least one step or NewStep will panic.
If there are no dependencies, use NewRootStep instead. These funcs are separate to prevent accidentally creating a root step by omitting dependencies.
func (*Step) Then ¶
func (s *Step) Then(name string, timeout time.Duration, f StepFunc, dependsOnAdditional ...*Step) *Step
Then creates a new step that depends on s and returns the new step. This can be used when defining a step graph to chain a sequence of steps together without as much syntactic clutter.
func (*Step) TransitiveDependencies ¶
TransitiveDependencies returns all the steps s transitively depends on. Returns an error if a cycle is detected.
The slice is topologically sorted: for each step x in the slice, every step y that x depends on precedes x. This means the topologically sorted list would be a valid order to run the steps one at a time. However, we expect to run the steps in parallel, so the execution order is not predictable in practice. The order may be useful for text representations of the graph, but in most use cases it is not relevant.
The result is reproducible for a given slice of steps and their dependency slices.
type StepRunner ¶
type StepRunner struct {
// contains filtered or unexported fields
}
func (*StepRunner) Execute ¶
func (r *StepRunner) Execute(ctx context.Context, steps []*Step) error
Execute runs a group of steps, blocking until all are complete.
If any step fails, returns the first error that occurred. If a step panics, it is recovered, wrapped as a stepPanicErr, and treated as an error.
If any step depends on a step that doesn't exist in steps, returns an error without executing.
type StepStatus ¶
type StepStatus int
const ( StepStatusWaiting StepStatus = iota StepStatusRunning StepStatusSucceeded StepStatusFailed )