Documentation
¶
Overview ¶
Package step provides the abstract definition of an Arcaflow workflow step. Implementations of this package provide the actual implementation of how the step types are run, such as the "plugin" kind, which executes plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrProviderNotFound ¶
ErrProviderNotFound is an error indicating that a provider kind was not found.
func (ErrProviderNotFound) Error ¶
func (e ErrProviderNotFound) Error() string
Error returns the error message.
type Lifecycle ¶
type Lifecycle[StageType lifecycleStage] struct { // InitialStage contains the first stage this step enters. InitialStage string // Stages contains the list of stages for this provider. Stages []StageType }
Lifecycle describes the lifecycle of a step. Each stage in the lifecycle can, but is not required to have an input schema and an output schema. The stage can also declare the next possible stages.
This lifecycle information is used to build the dependency tree of this step.
type LifecycleStage ¶
type LifecycleStage struct { // ID uniquely identifies the stage within the current provider. ID string // WaitingName describes this stage when waiting for input. WaitingName string // RunningName describes this stage when it is running. RunningName string // FinishedName specifies how to call this stage once it is complete. FinishedName string // InputFields provides the set of fields containing the input data of this stage. This must match the later // lifecycle with schema. InputFields map[string]struct{} // NextStages describes the possible next stages. The provider advances to one of these stages automatically and // will pause if there is no input available. // It will automatically create a DAG node between the current and the described next stages to ensure // that it is running in order. NextStages []string // Fatal indicates that this stage should be treated as fatal unless handled by the workflow. Fatal bool }
LifecycleStage is the description of a single stage within a step lifecycle.
func (LifecycleStage) Identifier ¶
func (l LifecycleStage) Identifier() string
Identifier is a helper function for getting the ID.
func (LifecycleStage) NextStageIDs ¶
func (l LifecycleStage) NextStageIDs() []string
NextStageIDs is a helper function that returns the next possible stages.
type LifecycleStageWithSchema ¶
type LifecycleStageWithSchema struct { LifecycleStage // InputSchema describes the schema for the required input of the current stage. This may be nil if the stage // requires no input. InputSchema map[string]*schema.PropertySchema Outputs map[string]*schema.StepOutputSchema }
LifecycleStageWithSchema contains information about the possible outputs of a lifecycle stage. This is available after the step lifecycle has started.
type Provider ¶
type Provider interface { // Kind returns the identifier that uniquely identifies this provider. // e.g. "plugin" Kind() string // Lifecycle describes the lifecycle of the step implemented by this provider. Lifecycle() Lifecycle[LifecycleStage] // ProviderSchema provides the basic schema of the provider that needs to be fulfilled in order to load the schema // itself. The returned value must provide the names of fields and their partial properties. ProviderSchema() map[string]*schema.PropertySchema // RunProperties provides the names of properties needed to run the step. The properties are provided as a set to // limit conflicts, but must, nevertheless, not conflict any fields in the ProviderSchema or any lifecycle stage. RunProperties() map[string]struct{} // LoadSchema prompts this provider to load its schema and return a step that can actually be run. The provided // inputs are guaranteed to match the schema returned by ProviderSchema. LoadSchema(inputs map[string]any, workflowContext map[string][]byte) (RunnableStep, error) }
Provider is the description of an item that fits in a workflow. Its implementation provide the basis for workflow execution.
type Registry ¶
type Registry interface { // Schema provides a generic schema for all steps. Schema() *schema.OneOfSchema[string] // SchemaByKind returns the schema of a single provider. SchemaByKind(kind string) (schema.Object, error) // GetByKind returns a provider by its kind value, or GetByKind(kind string) (Provider, error) // List returns a map of all step providers mapped by their kind values. List() map[string]Provider }
Registry holds the providers for possible steps in workflows. The registry must call Register() on each Provider immediately after creation.
type RunnableStep ¶
type RunnableStep interface { // Lifecycle describes the lifecycle of this step. The data provided is guaranteed to match the RunSchema. Lifecycle(input map[string]any) (Lifecycle[LifecycleStageWithSchema], error) // RunSchema provides a schema that describes the properties that are required to run the step provided by this // provider. These fields must match the RunProperties from the Provider. RunSchema() map[string]*schema.PropertySchema // Start begins the step execution. This does not necessarily mean that any action is happening, but the step // lifecycle will begin and enter its first stage, possibly waiting for input. The provided input is guaranteed to // match the RunSchema. Start( input map[string]any, runID string, stageChangeHandler StageChangeHandler, ) (RunningStep, error) }
RunnableStep is a step that already has a schema and can be run.
type RunningStep ¶
type RunningStep interface { // ProvideStageInput gives you the opportunity to provide input for a stage so that it may continue. // The ProvideStageInput must ensure that it only returns once the provider has transitioned to the next // stage based on the input, otherwise race conditions may happen. ProvideStageInput(stage string, input map[string]any) error // CurrentStage returns the stage the step provider is currently in, no matter if it is finished or not. CurrentStage() string // State returns information about the current step. State() RunningStepState // Close shuts down the step and cleans up the resources associated with the step. Close() error // ForceClose shuts down the step forcefully. ForceClose() error }
RunningStep is the representation of a step that is currently executing.
type RunningStepState ¶
type RunningStepState string
RunningStepState is the state any running step can be in.
const ( // RunningStepStateStarting indicates that the step hasn't processed its first stage yet. RunningStepStateStarting RunningStepState = "starting" // RunningStepStateWaitingForInput indicates that the step is currently blocked because it is missing input. RunningStepStateWaitingForInput RunningStepState = "waiting_for_input" // RunningStepStateRunning indicates that the step is working. RunningStepStateRunning RunningStepState = "running" // RunningStepStateFinished indicates that the step has finished, including failure cases. RunningStepStateFinished RunningStepState = "finished" )
type StageChangeHandler ¶
type StageChangeHandler interface { // OnStageChange is the callback that notifies the handler of the fact that the previous stage has finished with // the specified output. It indicates which next stage the provider moved to, and if it is waiting for input to // be provided via ProvideStageInput. // // The previous stage may be nil if the callback is called on the first stage the provider enters. The output of the // previous stage may also be nil if the stage did not declare any outputs. OnStageChange( step RunningStep, previousStage *string, previousStageOutputID *string, previousStageOutput *any, newStage string, inputAvailable bool, wg *sync.WaitGroup, ) // OnStepComplete is called when the step has completed a final stage in its lifecycle and communicates the output. // The previous output may be nil if the previous stage did not declare any outputs. OnStepComplete( step RunningStep, previousStage string, previousStageOutputID *string, previousStageOutput *any, wg *sync.WaitGroup, ) }
StageChangeHandler is a callback hook for reacting to changes in stages. The calling party will be notified of the provider advancing stages with this hook.
Directories
¶
Path | Synopsis |
---|---|
Package dummy is a step provider that just says hello.
|
Package dummy is a step provider that just says hello. |
Package foreach provides the ability to loop over items.
|
Package foreach provides the ability to loop over items. |
Package plugin provides a step provider that executes container-based Arcaflow plugins using deployers.
|
Package plugin provides a step provider that executes container-based Arcaflow plugins using deployers. |
Package registry provides the step registry, joining the step providers together.
|
Package registry provides the step registry, joining the step providers together. |