Documentation
¶
Index ¶
- Constants
- func EventStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel)
- type Action
- type ActionDataFilter
- type ActionMode
- type BaseDataCondition
- type BaseEventCondition
- type BaseState
- func (s *BaseState) GetCompensatedBy() string
- func (s *BaseState) GetEnd() *End
- func (s *BaseState) GetID() string
- func (s *BaseState) GetMetadata() *Metadata
- func (s *BaseState) GetName() string
- func (s *BaseState) GetOnErrors() []Error
- func (s *BaseState) GetStateDataFilter() *StateDataFilter
- func (s *BaseState) GetTransition() *Transition
- func (s *BaseState) GetType() StateType
- func (s *BaseState) GetUsedForCompensation() bool
- type BaseSwitchState
- type BaseWorkflow
- type Branch
- type CallbackState
- type Common
- type CompletionType
- type Correlation
- type Cron
- type DataBasedSwitchState
- type DataCondition
- type DefaultDef
- type DelayState
- type End
- type EndDataCondition
- type EndEventCondition
- type Error
- type Event
- type EventBasedSwitchState
- type EventCondition
- type EventDataFilter
- type EventKind
- type EventRef
- type EventState
- type ExecTimeout
- type ForEachState
- type Function
- type FunctionRef
- type FunctionType
- type InjectState
- type Metadata
- type OnEvents
- type OperationState
- type ParallelState
- type ProduceEvent
- type Repeat
- type Retry
- type Schedule
- type Start
- type State
- type StateDataFilter
- type StateType
- type SubFlowRef
- type Transition
- type TransitionDataCondition
- type TransitionEventCondition
- type Workflow
Constants ¶
const ( //StateTypeDelay ... StateTypeDelay = "delay" // StateTypeEvent ... StateTypeEvent = "event" // StateTypeOperation ... StateTypeOperation = "operation" // StateTypeParallel ... StateTypeParallel = "parallel" // StateTypeSwitch ... StateTypeSwitch = "switch" // StateTypeForEach ... StateTypeForEach = "foreach" // StateTypeInject ... StateTypeInject = "inject" // StateTypeCallback ... StateTypeCallback = "callback" // CompletionTypeAnd .. CompletionTypeAnd = "and" // CompletionTypeXor ... CompletionTypeXor = "xor" // CompletionTypeNOfM ... CompletionTypeNOfM = "n_of_m" )
Variables ¶
This section is empty.
Functions ¶
func EventStructLevelValidation ¶
func EventStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel)
EventStructLevelValidation custom validator for event kind consumed
Types ¶
type Action ¶
type Action struct {
// Unique action definition name
Name string `json:"name,omitempty"`
FunctionRef FunctionRef `json:"functionRef,omitempty"`
// References a 'trigger' and 'result' reusable event definitions
EventRef EventRef `json:"eventRef,omitempty"`
// References a sub-workflow to be executed
SubFlowRef SubFlowRef `json:"subFlowRef,omitempty"`
// Time period to wait for function execution to complete
Timeout string `json:"timeout,omitempty"`
// Action data filter
ActionDataFilter ActionDataFilter `json:"actionDataFilter,omitempty"`
}
Action ...
type ActionDataFilter ¶
type ActionDataFilter struct {
// Workflow expression that selects state data that the state action can use
FromStateData string `json:"fromStateData,omitempty"`
// Workflow expression that filters the actions data results
Results string `json:"results,omitempty"`
// Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified, denote, the top-level state data element
ToStateData string `json:"toStateData,omitempty"`
}
ActionDataFilter ...
type ActionMode ¶
type ActionMode string
ActionMode ...
const ( // DefaultExpressionLang ... DefaultExpressionLang = "jq" // ActionModeSequential ... ActionModeSequential ActionMode = "sequential" // ActionModeParallel ... ActionModeParallel ActionMode = "parallel" )
type BaseDataCondition ¶
type BaseDataCondition struct {
// Data condition name
Name string `json:"name,omitempty"`
// Workflow expression evaluated against state data. Must evaluate to true or false
Condition string `json:"condition" validate:"required"`
Metadata Metadata `json:"metadata,omitempty"`
}
BaseDataCondition ...
func (*BaseDataCondition) GetCondition ¶
func (b *BaseDataCondition) GetCondition() string
GetCondition ...
func (*BaseDataCondition) GetMetadata ¶
func (b *BaseDataCondition) GetMetadata() Metadata
GetMetadata ...
type BaseEventCondition ¶
type BaseEventCondition struct {
// Event condition name
Name string `json:"name,omitempty"`
// References an unique event name in the defined workflow events
EventRef string `json:"eventRef" validate:"required"`
// Event data filter definition
EventDataFilter EventDataFilter `json:"eventDataFilter,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
}
BaseEventCondition ...
func (*BaseEventCondition) GetEventDataFilter ¶
func (e *BaseEventCondition) GetEventDataFilter() EventDataFilter
GetEventDataFilter ...
func (*BaseEventCondition) GetEventRef ¶
func (e *BaseEventCondition) GetEventRef() string
GetEventRef ...
func (*BaseEventCondition) GetMetadata ¶
func (e *BaseEventCondition) GetMetadata() Metadata
GetMetadata ...
type BaseState ¶
type BaseState struct {
// Unique State id
ID string `json:"id,omitempty" validate:"omitempty,min=1"`
// State name
Name string `json:"name" validate:"required"`
// State type
Type StateType `json:"type" validate:"required"`
// States error handling and retries definitions
OnErrors []Error `json:"onErrors,omitempty" validate:"omitempty,dive"`
// Next transition of the workflow after the time delay
Transition *Transition `json:"transition,omitempty"`
// State data filter
StateDataFilter *StateDataFilter `json:"stateDataFilter,omitempty"`
// Unique Name of a workflow state which is responsible for compensation of this state
CompensatedBy string `json:"compensatedBy,omitempty" validate:"omitempty,min=1"`
// If true, this state is used to compensate another state. Default is false
UsedForCompensation bool `json:"usedForCompensation,omitempty"`
// State end definition
End *End `json:"end,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
}
BaseState ...
func (*BaseState) GetCompensatedBy ¶
GetCompensatedBy ...
func (*BaseState) GetStateDataFilter ¶
func (s *BaseState) GetStateDataFilter() *StateDataFilter
GetStateDataFilter ...
func (*BaseState) GetUsedForCompensation ¶
GetUsedForCompensation ...
type BaseSwitchState ¶
type BaseSwitchState struct {
BaseState
// Default transition of the workflow if there is no matching data conditions. Can include a transition or end definition
Default DefaultDef `json:"default,omitempty"`
}
BaseSwitchState ...
type BaseWorkflow ¶
type BaseWorkflow struct {
// Workflow unique identifier
ID string `json:"id" validate:"required"`
// Workflow name
Name string `json:"name" validate:"required"`
// Workflow description
Description string `json:"description,omitempty"`
// Workflow version
Version string `json:"version" validate:"required"`
Start *Start `json:"start" validate:"required"`
// Serverless Workflow schema version
SchemaVersion string `json:"schemaVersion,omitempty" validate:"omitempty,min=1"`
// Identifies the expression language used for workflow expressions. Default is 'jq'
ExpressionLang string `json:"expressionLang,omitempty" validate:"omitempty,min=1"`
ExecTimeout *ExecTimeout `json:"execTimeout,omitempty"`
// If 'true', workflow instances is not terminated when there are no active execution paths. Instance can be terminated via 'terminate end definition' or reaching defined 'execTimeout'
KeepActive bool `json:"keepActive,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
}
BaseWorkflow describes the partial Workflow definition that does not rely on generic interfaces to make it easy for custom unmarshalers implementations to unmarshal the common data structure.
type Branch ¶
type Branch struct {
// Branch name
Name string `json:"name" validate:"required"`
// Actions to be executed in this branch
Actions []Action `json:"actions,omitempty"`
}
Branch Definition
type CallbackState ¶
type CallbackState struct {
BaseState
// Defines the action to be executed
Action Action `json:"action" validate:"required"`
// References an unique callback event name in the defined workflow events
EventRef string `json:"eventRef" validate:"required"`
// Time period to wait for incoming events (ISO 8601 format)
Timeout string `json:"timeout" validate:"required"`
// Event data filter
EventDataFilter EventDataFilter `json:"eventDataFilter,omitempty"`
}
CallbackState ...
type Common ¶
type Common struct {
// Metadata information
Metadata Metadata `json:"metadata,omitempty"`
}
Common schema for Serverless Workflow specification
type CompletionType ¶
type CompletionType string
CompletionType Option types on how to complete branch execution.
type Correlation ¶
type Correlation struct {
// CloudEvent Extension Context Attribute name
ContextAttributeName string `json:"contextAttributeName" validate:"required"`
// CloudEvent Extension Context Attribute value
ContextAttributeValue string `json:"contextAttributeValue,omitempty"`
}
Correlation ...
type Cron ¶
type Cron struct {
// Repeating interval (cron expression) describing when the workflow instance should be created
Expression string `json:"expression" validate:"required"`
// Specific date and time (ISO 8601 format) when the cron expression invocation is no longer valid
ValidUntil string `json:"validUntil,omitempty"`
}
Cron ...
func (*Cron) UnmarshalJSON ¶
UnmarshalJSON custom unmarshal function for Cron
type DataBasedSwitchState ¶
type DataBasedSwitchState struct {
BaseSwitchState
DataConditions []DataCondition `json:"dataConditions" validate:"required,min=1,dive"`
}
DataBasedSwitchState Permits transitions to other states based on data conditions
func (*DataBasedSwitchState) UnmarshalJSON ¶
func (j *DataBasedSwitchState) UnmarshalJSON(data []byte) error
UnmarshalJSON implementation for json Unmarshal function for the Databasedswitch type
type DataCondition ¶
DataCondition ...
type DefaultDef ¶
type DefaultDef struct {
Transition Transition `json:"transition,omitempty"`
End End `json:"end,omitempty"`
}
DefaultDef Can be either a transition or end definition
type DelayState ¶
type DelayState struct {
BaseState
// Amount of time (ISO 8601 format) to delay
TimeDelay string `json:"timeDelay" validate:"required"`
}
DelayState Causes the workflow execution to delay for a specified duration
type End ¶
type End struct {
// If true, completes all execution flows in the given workflow instance
Terminate bool `json:"terminate,omitempty"`
// Defines events that should be produced
ProduceEvents []ProduceEvent `json:"produceEvents,omitempty"`
// If set to true, triggers workflow compensation. Default is false
Compensate bool `json:"compensate,omitempty"`
}
End definition
type EndDataCondition ¶
type EndDataCondition struct {
BaseDataCondition
// Workflow end definition
End End `json:"end" validate:"required"`
}
EndDataCondition ...
type EndEventCondition ¶
type EndEventCondition struct {
BaseEventCondition
// Explicit transition to end
End End `json:"end" validate:"required"`
}
EndEventCondition Switch state data event condition
type Error ¶
type Error struct {
// Domain-specific error name, or '*' to indicate all possible errors
Error string `json:"error" validate:"required,min=1"`
// Error code. Can be used in addition to the name to help runtimes resolve to technical errors/exceptions. Should not be defined if error is set to '*'
Code string `json:"code,omitempty" validate:"omitempty,min=1"`
// References a unique name of a retry definition.
RetryRef string `json:"retryRef,omitempty" validate:"omitempty,min=1"`
// Transition to next state to handle the error. If retryRef is defined, this transition is taken only if retries were unsuccessful.
Transition Transition `json:"transition,omitempty"`
// End workflow execution in case of this error. If retryRef is defined, this ends workflow only if retries were unsuccessful.
End End `json:"end,omitempty"`
}
Error ...
type Event ¶
type Event struct {
Common
// Unique event name
Name string `json:"name" validate:"required"`
// CloudEvent source
Source string `json:"source,omitempty"`
// CloudEvent type
Type string `json:"type" validate:"required"`
// Defines the CloudEvent as either 'consumed' or 'produced' by the workflow. Default is 'consumed'
Kind EventKind `json:"kind,omitempty"`
// CloudEvent correlation definitions
Correlation []Correlation `json:"correlation,omitempty" validate:"omitempty,dive"`
}
Event ...
type EventBasedSwitchState ¶
type EventBasedSwitchState struct {
BaseSwitchState
// Defines conditions evaluated against events
EventConditions []EventCondition `json:"eventConditions" validate:"required,min=1,dive"`
}
EventBasedSwitchState Permits transitions to other states based on events
func (*EventBasedSwitchState) UnmarshalJSON ¶
func (j *EventBasedSwitchState) UnmarshalJSON(data []byte) error
UnmarshalJSON implementation for json Unmarshal function for the Eventbasedswitch type
type EventCondition ¶
type EventCondition interface {
GetName() string
GetEventRef() string
GetEventDataFilter() EventDataFilter
GetMetadata() Metadata
}
EventCondition ...
type EventDataFilter ¶
type EventDataFilter struct {
// Workflow expression that filters of the event data (payload)
Data string `json:"data,omitempty"`
// Workflow expression that selects a state data element to which the event payload should be added/merged into. If not specified, denotes, the top-level state data element.
ToStateData string `json:"toStateData,omitempty"`
}
EventDataFilter ...
type EventRef ¶
type EventRef struct {
// Reference to the unique name of a 'produced' event definition
TriggerEventRef string `json:"triggerEventRef" validate:"required"`
// Reference to the unique name of a 'consumed' event definition
ResultEventRef string `json:"resultEventRef" validate:"required"`
// TODO: create StringOrMap structure
// If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'triggerEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'triggerEventRef'.
Data interface{} `json:"data,omitempty"`
// Add additional extension context attributes to the produced event
ContextAttributes map[string]interface{} `json:"contextAttributes,omitempty"`
}
EventRef ...
type EventState ¶
type EventState struct {
BaseState
// If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed
Exclusive bool `json:"exclusive,omitempty"`
// Define the events to be consumed and optional actions to be performed
OnEvents []OnEvents `json:"onEvents" validate:"required,min=1,dive"`
// Time period to wait for incoming events (ISO 8601 format)
Timeout string `json:"timeout,omitempty"`
}
EventState This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel
func (*EventState) UnmarshalJSON ¶
func (e *EventState) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ExecTimeout ¶
type ExecTimeout struct {
// Timeout duration (ISO 8601 duration format)
Duration string `json:"duration" validate:"required"`
// If `false`, workflow instance is allowed to finish current execution. If `true`, current workflow execution is abrupted.
Interrupt bool `json:"interrupt,omitempty"`
// Name of a workflow state to be executed before workflow instance is terminated
RunBefore string `json:"runBefore,omitempty" validate:"omitempty,min=1"`
}
ExecTimeout ...
type ForEachState ¶
type ForEachState struct {
BaseState
// Workflow expression selecting an array element of the states data
InputCollection string `json:"inputCollection" validate:"required"`
// Workflow expression specifying an array element of the states data to add the results of each iteration
OutputCollection string `json:"outputCollection,omitempty"`
// Name of the iteration parameter that can be referenced in actions/workflow. For each parallel iteration, this param should contain an unique element of the inputCollection array
IterationParam string `json:"iterationParam" validate:"required"`
// Specifies how upper bound on how many iterations may run in parallel
Max intstr.IntOrString `json:"max,omitempty"`
// Actions to be executed for each of the elements of inputCollection
Actions []Action `json:"actions,omitempty"`
}
ForEachState ...
type Function ¶
type Function struct {
Common
// Unique function name
Name string `json:"name" validate:"required"`
// If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `expression`, defines the workflow expression.
Operation string `json:"operation" validate:"required"`
// Defines the function type. Is either `rest`, `rpc`, `expression` or `graphql`. Default is `rest`
Type FunctionType `json:"type,omitempty"`
}
Function ...
type FunctionRef ¶
type FunctionRef struct {
// Name of the referenced function
RefName string `json:"refName" validate:"required"`
// Function arguments
Arguments map[string]interface{} `json:"arguments,omitempty"`
// String containing a valid GraphQL selection set
SelectionSet string `json:"selectionSet,omitempty"`
}
FunctionRef ...
func (*FunctionRef) UnmarshalJSON ¶
func (f *FunctionRef) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type FunctionType ¶
type FunctionType string
FunctionType ...
const ( // FunctionTypeREST ... FunctionTypeREST FunctionType = "rest" // FunctionTypeRPC ... FunctionTypeRPC FunctionType = "rpc" // FunctionTypeExpression ... FunctionTypeExpression FunctionType = "expression" // FunctionTypeGraphQL ... FunctionTypeGraphQL FunctionType = "graphql" )
type InjectState ¶
type InjectState struct {
BaseState
// JSON object which can be set as states data input and can be manipulated via filters
Data map[string]interface{} `json:"data" validate:"required,min=1"`
}
InjectState ...
type OnEvents ¶
type OnEvents struct {
// References one or more unique event names in the defined workflow events
EventRefs []string `json:"eventRefs" validate:"required,min=1"`
// Specifies how actions are to be performed (in sequence of parallel)
ActionMode ActionMode `json:"actionMode,omitempty"`
// Actions to be performed if expression matches
Actions []Action `json:"actions,omitempty" validate:"omitempty,dive"`
// Event data filter
EventDataFilter EventDataFilter `json:"eventDataFilter,omitempty"`
}
OnEvents ...
type OperationState ¶
type OperationState struct {
BaseState
// Specifies whether actions are performed in sequence or in parallel
ActionMode ActionMode `json:"actionMode,omitempty"`
// Actions to be performed
Actions []Action `json:"actions" validate:"required,min=1,dive"`
}
OperationState Defines actions be performed. Does not wait for incoming events
type ParallelState ¶
type ParallelState struct {
BaseState
// Branch Definitions
Branches []Branch `json:"branches" validate:"required,min=1,dive"`
// Option types on how to complete branch execution.
CompletionType CompletionType `json:"completionType,omitempty"`
// Used when completionType is set to 'n_of_m' to specify the 'N' value
N intstr.IntOrString `json:"n,omitempty"`
}
ParallelState Consists of a number of states that are executed in parallel
type ProduceEvent ¶
type ProduceEvent struct {
// References a name of a defined event
EventRef string `json:"eventRef" validate:"required"`
// TODO: add object or string data type
// If String, expression which selects parts of the states data output to become the data of the produced event. If object a custom object to become the data of produced event.
Data interface{} `json:"data,omitempty"`
// Add additional event extension context attributes
ContextAttributes map[string]interface{} `json:"contextAttributes,omitempty"`
}
ProduceEvent ...
type Repeat ¶
type Repeat struct {
// Expression evaluated against SubFlow state data. SubFlow will repeat execution as long as this expression is true or until the max property count is reached
Expression string `json:"expression,omitempty"`
// If true, the expression is evaluated before each repeat execution, if false the expression is evaluated after each repeat execution
CheckBefore bool `json:"checkBefore,omitempty"`
// Sets the maximum amount of repeat executions
Max int `json:"max,omitempty"`
// If true, repeats executions in a case unhandled errors propagate from the sub-workflow to this state
ContinueOnError bool `json:"continueOnError,omitempty"`
// List referencing defined consumed workflow events. SubFlow will repeat execution until one of the defined events is consumed, or until the max property count is reached
StopOnEvents []string `json:"stopOnEvents,omitempty"`
}
Repeat ...
type Retry ¶
type Retry struct {
// Unique retry strategy name
Name string `json:"name" validate:"required"`
// Time delay between retry attempts (ISO 8601 duration format)
Delay string `json:"delay,omitempty"`
// Maximum time delay between retry attempts (ISO 8601 duration format)
MaxDelay string `json:"maxDelay,omitempty"`
// Static value by which the delay increases during each attempt (ISO 8601 time format)
Increment string `json:"increment,omitempty"`
// Numeric value, if specified the delay between retries is multiplied by this value.
Multiplier floatstr.Float32OrString `json:"multiplier,omitempty" validate:"omitempty,min=0"`
// Maximum number of retry attempts.
MaxAttempts intstr.IntOrString `json:"maxAttempts" validate:"required,min=0"`
// If float type, maximum amount of random time added or subtracted from the delay between each retry relative to total delay (between 0 and 1). If string type, absolute maximum amount of random time added or subtracted from the delay between each retry (ISO 8601 duration format)
Jitter floatstr.Float32OrString `json:"jitter,omitempty" validate:"omitempty,min=0,max=1"`
}
Retry ...
type Schedule ¶
type Schedule struct {
// Time interval (must be repeating interval) described with ISO 8601 format. Declares when workflow instances will be automatically created.
Interval string `json:"interval,omitempty"`
Cron *Cron `json:"cron,omitempty"`
// Timezone name used to evaluate the interval & cron-expression. (default: UTC)
Timezone string `json:"timezone,omitempty"`
}
Schedule ...
func (*Schedule) UnmarshalJSON ¶
UnmarshalJSON ...
type Start ¶
type Start struct {
StateName string `json:"stateName" validate:"required"`
Schedule *Schedule `json:"schedule,omitempty" validate:"omitempty"`
}
Start definition
type State ¶
type State interface {
GetID() string
GetName() string
GetType() StateType
GetOnErrors() []Error
GetTransition() *Transition
GetStateDataFilter() *StateDataFilter
GetCompensatedBy() string
GetUsedForCompensation() bool
GetEnd() *End
GetMetadata() *Metadata
}
State definition for a Workflow state
type StateDataFilter ¶
type StateDataFilter struct {
// Workflow expression to filter the state data input
Input string `json:"input,omitempty"`
// Workflow expression that filters the state data output
Output string `json:"output,omitempty"`
}
StateDataFilter ...
type SubFlowRef ¶
type SubFlowRef struct {
// Sub-workflow unique id
WorkflowID string `json:"workflowId" validate:"required"`
// Sub-workflow version
Version string `json:"version,omitempty"`
}
SubFlowRef ...
type Transition ¶
type Transition struct {
// Name of state to transition to
NextState string `json:"nextState" validate:"required,min=1"`
// Array of events to be produced before the transition happens
ProduceEvents []ProduceEvent `json:"produceEvents,omitempty" validate:"omitempty,dive"`
// If set to true, triggers workflow compensation when before this transition is taken. Default is false
Compensate bool `json:"compensate,omitempty"`
}
Transition ...
func (*Transition) UnmarshalJSON ¶
func (t *Transition) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type TransitionDataCondition ¶
type TransitionDataCondition struct {
BaseDataCondition
// Workflow transition if condition is evaluated to true
Transition Transition `json:"transition" validate:"required"`
}
TransitionDataCondition ...
type TransitionEventCondition ¶
type TransitionEventCondition struct {
BaseEventCondition
// Next transition of the workflow if there is valid matches
Transition Transition `json:"transition" validate:"required"`
}
TransitionEventCondition Switch state data event condition
type Workflow ¶
type Workflow struct {
BaseWorkflow
States []State `json:"states" validate:"required,min=1"`
Events []Event `json:"events,omitempty"`
Functions []Function `json:"functions,omitempty"`
Retries []Retry `json:"retries,omitempty"`
}
Workflow base definition
func (*Workflow) UnmarshalJSON ¶
UnmarshalJSON implementation for json Unmarshal function for the Workflow type