[v0.1.0-beta] GoSteps Initial Library
GoSteps
GoSteps is a go library that helps in running functions as steps and reminds you to step out and get active (kidding!).
The idea behind gosteps
is to define set of functions as steps-chain (kind of a linked list) and execute them in a sequential fashion by piping output (other than error) from previous step, as arguments, into the next steps (not necessarily using the args).
Usage
The Step
type contains the requirments to execute a step function and move to next one.
type Step struct {
Name StepName
Function interface{}
AdditionalArgs []interface{}
NextSteps []Step
NextStepResolver interface{}
ErrorsToRetry []error
StrictErrorCheck bool
SkipRetry bool
MaxAttempts int
RetrySleep time.Duration
}
Field | Description |
---|---|
Name | Name of step |
Function | The function to execute |
AdditionalArgs | any additional arguments need to pass to te step |
NextSteps | Candidate functions for next step (multiple next steps in-case of condition based execution) |
NextStepResolver | A function that returns the step name, based on conditions, that is used to pick the nextStep from NextSteps |
ErrorsToRetry | A list of error to retry step for |
StrictErrorCheck | If set to true exact error is matched, else only presence of error is checked |
SkipRetry | If set to true step is not retried for any error |
MaxAttempts | Max attempts are the number of times the step is tried (first try + subsequent retries). If not set, it'll run 100 times |
RetrySleep | Sleep duration (type time.Duration) between each re-attempts |