Documentation
¶
Index ¶
- Constants
- Variables
- func NewGoStepsLogger(out io.Writer, loggerOpts *LoggerOpts) goStepsLogger
- type Branch
- type BranchName
- type Branches
- type GoStepsContext
- type GoStepsCtx
- func (ctx GoStepsCtx) GetData(key string) interface{}
- func (ctx GoStepsCtx) GetProgress(step StepName) StepProgress
- func (c *GoStepsCtx) Log(message string, levels ...LogLevel)
- func (ctx *GoStepsCtx) SetCurrentStep(step StepName) GoStepsCtx
- func (ctx GoStepsCtx) SetData(key string, value interface{})
- func (ctx *GoStepsCtx) SetProgress(step StepName, stepResult StepResult) GoStepsCtx
- func (ctx *GoStepsCtx) Use(args ...interface{}) GoStepsContext
- func (ctx GoStepsCtx) WithData(data map[string]interface{})
- type GoStepsCtxData
- type LogLevel
- type LoggerOpts
- type ResolverFn
- type Step
- type StepFn
- type StepName
- type StepOpts
- type StepProgress
- type StepResult
- type StepRunProgress
- type StepState
- type Steps
Constants ¶
const ( // to avoid infinite runs due to the MaxAttempts not being set, we're keeping the default attempts to 100 // if required, import and use the MaxMaxAttempts in the step.MaxAttempts field DefaultMaxAttempts = 100 // the Max value is 9223372036854775807, which is not infinite but a huge number of attempts MaxMaxAttempts = math.MaxInt )
Variables ¶
var ( // Log Level of GoSteps Logger implementation of zerolog.Level DebugLevel = LogLevel(zerolog.DebugLevel) InfoLevel = LogLevel(zerolog.InfoLevel) WarnLevel = LogLevel(zerolog.WarnLevel) ErrorLevel = LogLevel(zerolog.ErrorLevel) )
Functions ¶
func NewGoStepsLogger ¶ added in v1.1.0
func NewGoStepsLogger(out io.Writer, loggerOpts *LoggerOpts) goStepsLogger
NewGoStepsLogger returns a new instance of the GoStepsLogger
output: is of type io.Writer, example os.Stdout, for more options refer to zerolog documentation: https://github.com/rs/zerolog?tab=readme-ov-file#multiple-log-output
loggerOpts: is of type *LoggerOpts, if nil, default options are used to enable step level logging, set StepLoggingEnabled to true
Types ¶
type Branch ¶
type Branch struct {
BranchName BranchName `json:"branchName"`
Steps Steps `json:"steps"`
}
Branch type defines a unique step-chain, of the step-tree Branches can be used to define different steps to be executed based on a resolver function
func NewStepChain ¶
NewStepChain creates a new root branch of the step-chain Soon to be deprecated in favor of NewStepsProcessor
func NewStepsProcessor ¶ added in v1.1.0
NewStepsProcessor creates a new root branch of the step-chain
func (*Branch) Execute ¶
func (branch *Branch) Execute(c GoStepsContext)
Execute a branch with the context provided
type Branches ¶
type Branches struct {
Branches []Branch `json:"branches"`
Resolver ResolverFn `json:"-"`
}
Branches type defines a list of branches with a resolver function to determine the branch to execute
type GoStepsContext ¶
type GoStepsContext interface {
Use(args ...interface{}) GoStepsContext
Log(message string, levels ...LogLevel)
SetData(key string, value interface{})
GetData(key string) interface{}
WithData(data map[string]interface{})
SetProgress(step StepName, stepResult StepResult) GoStepsCtx
SetCurrentStep(step StepName) GoStepsCtx
// contains filtered or unexported methods
}
GoStepsContext interface defines the methods for the context
func NewGoStepsContext ¶
func NewGoStepsContext() GoStepsContext
GoStepsCtx type defines the context for the step-chain
type GoStepsCtx ¶
type GoStepsCtx struct {
// contains filtered or unexported fields
}
GoStepsCtx type defines the context for the step-chain
func (GoStepsCtx) GetData ¶
func (ctx GoStepsCtx) GetData(key string) interface{}
GetData gets the data from the context
func (GoStepsCtx) GetProgress ¶
func (ctx GoStepsCtx) GetProgress(step StepName) StepProgress
GetProgress gets the progress of the step
func (*GoStepsCtx) Log ¶ added in v1.1.0
func (c *GoStepsCtx) Log(message string, levels ...LogLevel)
Log logs the message with the step name and the log level, if provided. The log level is the first argument in the args.
func (*GoStepsCtx) SetCurrentStep ¶ added in v1.1.0
func (ctx *GoStepsCtx) SetCurrentStep(step StepName) GoStepsCtx
SetCurrentStep sets the current step
func (GoStepsCtx) SetData ¶
func (ctx GoStepsCtx) SetData(key string, value interface{})
SetData sets the data in the context
func (*GoStepsCtx) SetProgress ¶
func (ctx *GoStepsCtx) SetProgress(step StepName, stepResult StepResult) GoStepsCtx
SetProgress sets the progress of the step
func (*GoStepsCtx) Use ¶ added in v1.1.0
func (ctx *GoStepsCtx) Use(args ...interface{}) GoStepsContext
Handles adding handlers to the context
func (GoStepsCtx) WithData ¶
func (ctx GoStepsCtx) WithData(data map[string]interface{})
WithData sets the data in the context
type GoStepsCtxData ¶
type GoStepsCtxData map[string]interface{}
GoStepsCtxData type defines the data stored in the context
type LoggerOpts ¶ added in v1.1.0
type LoggerOpts struct {
StepLoggingEnabled bool
}
type ResolverFn ¶
type ResolverFn func(ctx GoStepsCtx) BranchName
ResolverFn defines the Resolver Function to determine the branch to execute
type Step ¶
type Step struct {
Name StepName `json:"name"`
Function StepFn `json:"-"`
StepOpts StepOpts `json:"stepConfig"`
Branches *Branches `json:"branches"`
StepArgs map[string]interface{} `json:"stepArgs"`
// contains filtered or unexported fields
}
Step type defines a step with all configurations for the step
type StepOpts ¶
type StepOpts struct {
ErrorsToRetry []error `json:"errorsToRetry"`
ErrorPatternsToRetry []regexp.Regexp `json:"errorPatternsToRetry"`
RetryAllErrors bool `json:"retryAllErrors"`
MaxRunAttempts int `json:"maxAttempts"`
RetrySleep time.Duration `json:"retrySleep"`
}
StepOpts type defines the configuration for the step
type StepProgress ¶
type StepProgress struct {
StepName StepName `json:"stepName"`
StepResult StepResult `json:"stepResult"`
}
StepProgress type defines the progress of the step
type StepResult ¶
type StepResult struct {
StepData GoStepsCtxData `json:"stepData"` // stores the data from a step, if any
StepState StepState `json:"stepState"` // state of the step
StepMessage *string `json:"stepMessage"` // message from the step execution, if any
StepError error `json:"stepError,omitempty"` // error from the step execution, if any
}
StepResult type defines the result of the step
func MarkStateComplete ¶
func MarkStateComplete() StepResult
MarkStateComplete marks the state of the step as complete
func MarkStateError ¶
func MarkStateError() StepResult
MarkStateError marks the state of the step as error
func MarkStateFailed ¶
func MarkStateFailed() StepResult
MarkStateFailed marks the state of the step as failed
func MarkStatePending ¶
func MarkStatePending() StepResult
MarkStatePending marks the state of the step as pending
func MarkStateSkipped ¶
func MarkStateSkipped() StepResult
MarkStateSkipped marks the state of the step as skipped
func (StepResult) WithData ¶
func (sr StepResult) WithData(data GoStepsCtxData) StepResult
WithData sets the data for the step
func (StepResult) WithError ¶ added in v1.1.0
func (sr StepResult) WithError(stepErr error) StepResult
WithStepError sets the GoSteps - StepError for the step
func (StepResult) WithMessage ¶
func (sr StepResult) WithMessage(message string) StepResult
WithMessage sets the message for the step
type StepRunProgress ¶
type StepRunProgress struct {
// contains filtered or unexported fields
}
stepRunProgress type defines the progress of the step it contains the run/execution count of each step
type StepState ¶
type StepState string
StepState type defines the state of the step after execution
const ( StepStateComplete StepState = "StepStateComplete" // step completed successfully [non-retriable] StepStateFailed StepState = "StepStateFailed" // step failed to complete, without error [non-retriable] StepStateSkipped StepState = "StepStateSkipped" // step was skipped [non-retriable] StepStatePending StepState = "StepStatePending" // step is pending, should be retried [retriable] StepStateError StepState = "StepStateError" // step failed to complete, with error [retriable] )
