Documentation ¶
Index ¶
- Constants
- Variables
- func NewDuplicateIDPropError(prop, value, next string) error
- func Sanitize(input string) string
- type DuplicateIDPropError
- type Option
- func WithBlock(val string) Option
- func WithBlockID(val string) Option
- func WithElement(val string) Option
- func WithElementID(val string) Option
- func WithIgnoredError(err string) Option
- func WithMaxAttempts(attempts int32) Option
- func WithMod(val string) Option
- func WithModID(val string) Option
- func WithParent(parent workflow.Context) Option
- func WithProp(key, val string) Option
- type Options
Constants ¶
const (
RetryForever int32 = 0 // Default workflow max Attempts. 0 means forever.
)
Variables ¶
var ( // ErrParentNil is returned when the parent workflow context is nil. ErrParentNil = errors.New("parent workflow context is nil") )
Functions ¶
func NewDuplicateIDPropError ¶
Types ¶
type DuplicateIDPropError ¶
type DuplicateIDPropError struct {
// contains filtered or unexported fields
}
func (*DuplicateIDPropError) Error ¶
func (e *DuplicateIDPropError) Error() string
type Option ¶
Option sets the specified options.
func WithIgnoredError ¶
WithIgnoredError adds an error to the list of errors that are ok to ignore for the workflow.
func WithMaxAttempts ¶
WithMaxAttempts sets the max attempts for the workflow.
func WithParent ¶
WithParent sets the parent workflow context.
type Options ¶
type Options interface { IsChild() bool // IsChild returns true if the workflow id is a child workflow id. ParentWorkflowID() string // ParentWorkflowID returns the parent workflow id. IDSuffix() string // IDSuffix santizes the suffix of the workflow id and then formats it as a string. MaxAttempts() int32 // MaxAttempts returns the max attempts for the workflow. IgnoredErrors() []string // IgnoredErrors returns the list of errors that are ok to ignore. }
Options defines the interface for creating workflow options.
func NewOptions ¶
NewOptions sets workflow options required to run a workflow like workflow id, max attempts, etc.
The idempotent workflow ID Sometimes we need to signal the workflow from a completely disconnected part of the application. For us, it is important to arrive at the same workflow ID regardless of the conditions. We try to follow the block, element, modifier pattern popularized by advocates of maintainable CSS. For more info, https://getbem.com/.
Example: For the block github with installation id 123, the element being the repository with id 456, and the modifier being the pull request with id 789, we would call
opts := NewOptions( WithBlock("github"), WithBlockID("123"), WithElement("repository"), WithElementID("456"), WithModifier("repository"), WithModifierID("789"), // Sometimes we need to over-ride max attempts. The default is workflows.RetryForever. WithMaxAttempts(3), // If we want to ignore an error, we can do so. WithIgnoredError("SomeError"), ) id := opts.ID()
NOTE: The design is work in progress and may change in future.