Documentation
¶
Overview ¶
Package states implements the State behavior for the workflow states are the basic step in the workflow, they can be combined to form a complex workflow
Index ¶
- Variables
- func DecodeMapToStruct(input map[string]interface{}, output interface{}) error
- func DecodeStructToMap(input interface{}) (map[string]interface{}, error)
- func Encoder(v interface{}) ([]byte, error)
- func HasIntersection(x []string, y []string) bool
- func InitBaseState(bs *BaseState, data map[string]interface{}) error
- func InitChoiceBodyByMap(body *ChoiceBody, data map[string]interface{}) error
- func InitFailBodyByMap(body *FailBody, data map[string]interface{}) error
- func InitParallelBodyByMap(body *ParallelBody, data map[string]interface{}, depth int) error
- func InitPassBodyByMap(body *PassBody, data map[string]interface{}) error
- func InitStateMachineBodyByMap(smb *StateMachineBody, data map[string]any) (err error)
- func InitStateMachineHeaderByMap(header *StateMachineHeader, data map[string]interface{}) error
- func InitTaskBodyByMap(body *TaskBody, data map[string]interface{}) error
- func InitWaitBodyByMap(body *WaitBody, data map[string]interface{}) (err error)
- func IsExecutableStateType(stype string) bool
- func MapUpdate(i map[string]interface{}, toi map[string]interface{})
- func ParserStateMachine(definition string) error
- func RegisterResource(resource string)
- func StringToMap(s string) (map[string]interface{}, error)
- func ToString(v interface{}) (string, error)
- func ValidateStateFieldOptional(data map[string]any) error
- type BaseBone
- type BaseState
- func (s *BaseState) GenParameters(input any) (any, error)
- func (s *BaseState) GetBone() StateBone
- func (bs *BaseState) GetDefinition() (string, error)
- func (s *BaseState) GetInput(input any) (any, error)
- func (s *BaseState) GetName() string
- func (s *BaseState) GetNext() []string
- func (s *BaseState) GetNextState(input any, output any) (NextState, error)
- func (s *BaseState) GetOutput(input any, output any) (any, error)
- func (s *BaseState) GetOutputWithPath(input any, output any, resultpath string, outputpath string) (any, error)
- func (s *BaseState) GetParametersInput(input any) (any, error)
- func (s *BaseState) GetType() string
- func (s *BaseState) Init() error
- func (s *BaseState) IsEnd() bool
- func (s *BaseState) RenderParameters(input any, parameters any) (any, error)
- func (s *BaseState) SetName(name string)
- func (s *BaseState) Validate() error
- type ChoiceBody
- type ChoiceBranch
- type ChoiceState
- func (choice *ChoiceState) ChoiceNextState(input any) string
- func (choice *ChoiceState) GetBaseState() *BaseState
- func (choice *ChoiceState) GetBone() StateBone
- func (choice *ChoiceState) GetDefinition() (string, error)
- func (choice *ChoiceState) GetNextState(input any) (NextState, error)
- func (choice *ChoiceState) IsEnd() bool
- type FailBody
- type FailData
- type FailState
- type FieldError
- type FiledPathError
- type NextState
- type ParallelBody
- type ParallelState
- type PassBody
- type PassState
- type QueryLanguageType
- type ResourceURI
- type State
- type StateBone
- type StateFieldRequired
- type StateMachine
- type StateMachineBody
- func (smb *StateMachineBody) AddState(newstate State)
- func (s *StateMachineBody) GetBone() StateMachineBone
- func (smb *StateMachineBody) GetGroupStates(startGroupID int) ([]StateMachineGroupState, error)
- func (smb *StateMachineBody) Init() (err error)
- func (smb *StateMachineBody) SetNewStateFunc(f func(data map[string]any, depth int) (State, error))
- func (s *StateMachineBody) SetStartAt(name string)
- func (s *StateMachineBody) Validate() error
- type StateMachineBone
- type StateMachineGroupState
- type StateMachineHeader
- type StateMachineTimeout
- type StateType
- type SubGroupState
- type SucceedState
- type SuspendState
- type TaskBody
- type TaskCatchNode
- type TaskRetryNode
- type TaskSendData
- type TaskState
- func (t *TaskState) GetBaseState() *BaseState
- func (t *TaskState) GetBone() StateBone
- func (t *TaskState) GetDefinition() (string, error)
- func (t *TaskState) GetNextState(input any, taskdata TaskSendData) (*NextState, error)
- func (t *TaskState) GetTaskTimeout() (TaskTimeout, error)
- func (t *TaskState) Init() error
- func (t *TaskState) Validate() error
- type TaskTimeout
- type WaitBody
- type WaitState
Constants ¶
This section is empty.
Variables ¶
var ( ErrorLackOfRequiredField = errors.New("lack of required field") ErrorInvalidStateType = errors.New("invalid state type") ErrorInvalidFiledContent = errors.New("field content is invalid") ErrorFiledDenied = errors.New("field is dentied") ErrorFiledRequired = errors.New("field is required") ErrorInvalidData = errors.New("invalid data") ErrorInvalidField = errors.New("invalid field") )
ErrorLackOfRequiredField ...
var ChoiceFieldNames = struct { Choices string Default string }{ Choices: "Choices", Default: "Default", }
ChoiceFieldNames
var CommonFields = []string{ StateFieldNames.Comment, StateFieldNames.InputPath, StateFieldNames.OutputPath, StateFieldNames.Parameters, StateFieldNames.ResultPath, }
CommonFields common fields
var DefaultCatchNode = TaskCatchNode{ ErrorEquals: []string{}, Next: "", ResultPath: "$", }
DefaultCatchNode default catch config for task
var DefaultRetryNode = TaskRetryNode{ ErrorEquals: []string{}, IntervalSeconds: 1, MaxAttempts: 3, BackoffRate: 1.5, }
DefaultRetryNode default retry config for task
var DefaultTaskBody = TaskBody{ Block: false, Resource: "", TimeoutSeconds: 0, HeartbeatSeconds: 0, Retry: []TaskRetryNode{}, Catch: []TaskCatchNode{}, }
DefaultTaskBody ...
var FiledRequiredLevel = struct { Allowed int Required int Deny int }{ Allowed: 0, Required: 1, Deny: 2, }
FiledRequiredLevel field required level
var HeaderFieldNames = struct { Version string Type string Comment string QueryLanguage string TimeoutSeconds string AbortTimeoutSeconds string ExecutionInfoPath string DefaultInput string }{ Version: "Version", Type: "Type", Comment: "Comment", QueryLanguage: "QueryLanguage", TimeoutSeconds: "TimeoutSeconds", AbortTimeoutSeconds: "AbortTimeoutSeconds", ExecutionInfoPath: "ExecutionInfoPath", DefaultInput: "DefaultInput", }
HeaderFieldNames ...
var MaxDepth = 3
StateMachine最大深度,防止流程图过度复杂 MaxDepth 最大深度, 默认为3
var ParserQuota = config.DefaultQuota
var QueryLanguages = struct { JSONPath QueryLanguageType JSONata QueryLanguageType }{ JSONPath: "JSONPath", JSONata: "JSONata", }
QueryLanguages ...
var ResourceSeparator = ":"
ResourceSeparator ...
var ResourceType = struct { Builtin string Activity string Kubernetes string K8s string }{ Activity: "activity", Builtin: "builtin", Kubernetes: "kubernetes", K8s: "k8s", }
ResourceType 资源类型
var StartDepth = 1
StartDepth 最外层的Depth ,默认为1
var StartGroupID = 1
StartGroupID 最外层的Group ID, 默认为 1
var StateFieldNames = struct { Type string Comment string InputPath string OutputPath string Parameters string ResultPath string Next string End string Resource string Retry string Catch string TimeoutSeconds string HeartbeatSeconds string }{ Type: "Type", Comment: "Comment", InputPath: "InputPath", OutputPath: "OutputPath", Parameters: "Parameters", ResultPath: "ResultPath", Next: "Next", End: "End", Resource: "Resource", Retry: "Retry", Catch: "Catch", TimeoutSeconds: "TimeoutSeconds", HeartbeatSeconds: "HeartbeatSeconds", }
StateFieldNames common field names
var StateFieldRequiredMap = map[StateType]StateFieldRequired{ StateTypes.Task: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Required, }, StateTypes.Parallel: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Required, }, StateTypes.Map: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Required, }, StateTypes.Pass: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Required, Retry: FiledRequiredLevel.Deny, Catch: FiledRequiredLevel.Deny, }, StateTypes.Wait: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Required, ResultPath: FiledRequiredLevel.Deny, Parameters: FiledRequiredLevel.Deny, Retry: FiledRequiredLevel.Deny, Catch: FiledRequiredLevel.Deny, }, StateTypes.Choice: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Deny, ResultPath: FiledRequiredLevel.Deny, Parameters: FiledRequiredLevel.Deny, Retry: FiledRequiredLevel.Deny, Catch: FiledRequiredLevel.Deny, }, StateTypes.Succeed: { Type: FiledRequiredLevel.Required, NextEnd: FiledRequiredLevel.Deny, ResultPath: FiledRequiredLevel.Deny, Parameters: FiledRequiredLevel.Deny, Retry: FiledRequiredLevel.Deny, Catch: FiledRequiredLevel.Deny, }, StateTypes.Fail: { Type: FiledRequiredLevel.Required, InputPath: FiledRequiredLevel.Deny, OutputPath: FiledRequiredLevel.Deny, NextEnd: FiledRequiredLevel.Deny, ResultPath: FiledRequiredLevel.Deny, Parameters: FiledRequiredLevel.Deny, Retry: FiledRequiredLevel.Deny, Catch: FiledRequiredLevel.Deny, }, StateTypes.Suspend: { Type: FiledRequiredLevel.Required, InputPath: FiledRequiredLevel.Deny, OutputPath: FiledRequiredLevel.Deny, NextEnd: FiledRequiredLevel.Deny, ResultPath: FiledRequiredLevel.Deny, Parameters: FiledRequiredLevel.Deny, Retry: FiledRequiredLevel.Deny, Catch: FiledRequiredLevel.Deny, }, StateTypes.StateGroup: {}, }
StateFieldRequiredMap field required map
var StateMachineFieldNames = struct { StartAt string States string }{ StartAt: "StartAt", States: "States", }
var StateMachineType = "statemachine"
StateMachineType ...
var StateTypes = struct { Task StateType Choice StateType Fail StateType Succeed StateType Wait StateType Pass StateType Parallel StateType Map StateType Suspend StateType // 子流程类型, Parallel/Map 生成的中间步骤 StateGroup StateType }{ Task: "Task", Choice: "Choice", Fail: "Fail", Succeed: "Succeed", Wait: "Wait", Pass: "Pass", Parallel: "Parallel", Map: "Map", Suspend: "Suspend", StateGroup: "StateGroup", }
StateTypes constant State type define here
var TimeFormatCommon = "2006-01-02 15:04:05"
var TimeFormatList = []string{TimeFormatCommon, time.RFC3339}
var VariablePrefix = "$."
VariablePrefix 变量字段的前缀
Functions ¶
func DecodeMapToStruct ¶
func DecodeStructToMap ¶
func HasIntersection ¶
HasIntersection return if x and y have common elements
func InitBaseState ¶
func InitChoiceBodyByMap ¶
func InitChoiceBodyByMap(body *ChoiceBody, data map[string]interface{}) error
InitByMap Initialize ChoiceState Content
func InitFailBodyByMap ¶
InitByMap Initialize Fail Content
func InitParallelBodyByMap ¶
func InitParallelBodyByMap(body *ParallelBody, data map[string]interface{}, depth int) error
func InitPassBodyByMap ¶
InitPassBodyByMap Initialize PassBody Content
func InitStateMachineBodyByMap ¶
func InitStateMachineBodyByMap(smb *StateMachineBody, data map[string]any) (err error)
InitByMap Use map to init StateMachineBody content
func InitStateMachineHeaderByMap ¶
func InitStateMachineHeaderByMap(header *StateMachineHeader, data map[string]interface{}) error
InitByMap 通过Map类型初始化
func InitTaskBodyByMap ¶
InitByMap Initialize TaskState Content
func InitWaitBodyByMap ¶
InitByMap Inititalize Wait Content
func IsExecutableStateType ¶
IsExecutableStateType 是否是可执行的步骤类型
func ValidateStateFieldOptional ¶
ValidateStateFieldOptional validate state field optional
Types ¶
type BaseBone ¶
type BaseBone struct {
Type string `json:"Type"`
Name string `json:"Name"`
Next []string `json:"Next"`
End bool `json:"End"`
Comment string `json:"Comment"`
}
BaseBone common state type bone
type BaseState ¶
type BaseState struct {
Name string `json:"Name,omitempty"`
Type string `json:"Type,omitempty"`
Comment string `json:"Comment,omitempty"`
InputPath string `json:"InputPath,omitempty"`
OutputPath string `json:"OutputPath,omitempty"`
ResultPath string `json:"ResultPath,omitempty"`
Parameters any `json:"Parameters,omitempty"`
MaxExecuteTimes int `json:"MaxExecuteTimes,omitempty"`
End bool `json:"End,omitempty"`
Next string `json:"Next,omitempty"`
Retry any `json:"Retry,omitempty"`
Catch any `json:"Catch,omitempty"`
}
BaseState is a struct that defines the base state of a state machine, with default values
func NewBaseStateFromMap ¶
NewBaseStateFromMap NewState from MapData
func NewBaseStateFromString ¶
NewBaseStateFromString New State From String
func NewDefaultBaseState ¶
func NewDefaultBaseState() *BaseState
func (*BaseState) GenParameters ¶
GenParameters calculate parameters by input data and parameters @input input state origin input return parameters
func (*BaseState) GetDefinition ¶
func (*BaseState) GetInput ¶
GetInput Get State Real Input by InputData input , origin input, output state input using inputpath , parameters
func (*BaseState) GetNextState ¶
GetNextState get next state info generate final output using inputpath parameters resultpath outputpath @input state origin input @output state produce data return next state info
func (*BaseState) GetOutput ¶
GetOutput calculate task output cautions: 1. return nil if outputpath is empty 2. return output is not a copy of input, it will reference data from input and output, which is defined in resultpath and outputpath @input input state origin input @output output state produce data return output state produce data
func (*BaseState) GetOutputWithPath ¶
func (s *BaseState) GetOutputWithPath(input any, output any, resultpath string, outputpath string) (any, error)
GetOutputWithPath calculate output with resultpath and outputpath cautions: 1. return nil if outputpath is empty 2. return output is not a copy of input, it will reference data from input and output, which is defined in resultpath and outputpath @input input state origin input @output output state produce data @resultpath resultpath @outputpath outputpath
func (*BaseState) GetParametersInput ¶
GetParametersInput get state parameters input input , origin input, output state input using inputpath , parameters
func (*BaseState) RenderParameters ¶
RenderParameters render parameters @input input state origin input @parameters parameters field parameters return parameters
type ChoiceBody ¶
type ChoiceBody struct {
Choices []ChoiceBranch `mapstructure:"Choices"`
Default string `mapstructure:"Default" validate:"gte=0"`
}
ChoiceBody ...
func NewChoiceBodyFromMap ¶
func NewChoiceBodyFromMap(data map[string]interface{}) (*ChoiceBody, error)
type ChoiceBranch ¶
type ChoiceBranch struct {
Condition expression.BooleanExpression
Next string `mapstructure:"Next" validate:"required,gt=0"`
}
type ChoiceState ¶
type ChoiceState struct {
*BaseState
*ChoiceBody
// contains filtered or unexported fields
}
ChoiceState ...
func NewChoiceStateFromMap ¶
func NewChoiceStateFromMap(data map[string]interface{}) (state *ChoiceState, err error)
NewChoiceStateFromMap NewChoiceStateFromMap
func NewChoiceStateFromString ¶
func NewChoiceStateFromString(definition string) (state *ChoiceState, err error)
NewChoiceStateFromString NewChoiceStateFromString
func (*ChoiceState) ChoiceNextState ¶
func (choice *ChoiceState) ChoiceNextState(input any) string
ChoiceNextState
func (*ChoiceState) GetBaseState ¶
func (choice *ChoiceState) GetBaseState() *BaseState
func (*ChoiceState) GetBone ¶
func (choice *ChoiceState) GetBone() StateBone
GetBone get choice bone
func (*ChoiceState) GetDefinition ¶
func (choice *ChoiceState) GetDefinition() (string, error)
func (*ChoiceState) GetNextState ¶
func (choice *ChoiceState) GetNextState(input any) (NextState, error)
GetNextState Get Next State input state origin input
func (*ChoiceState) IsEnd ¶
func (choice *ChoiceState) IsEnd() bool
IsEnd check if choice is end, return false always, choice is not end state
type FailBody ¶
type FailBody struct {
Abort bool `mapstructure:"Abort"`
Cause string `mapstructure:"Cause"`
Error string `mapstructure:"Error"`
}
func NewFailBodyFromMap ¶
type FailState ¶
FailState 失败节点
func NewFailStateFromMap ¶
NewFailStateFromMap Create New Fail State
func NewFailStateFromString ¶
NewFailStateFromString NewFailStateFromString
func (*FailState) GetBaseState ¶
func (*FailState) GetDefinition ¶
func (*FailState) GetFailData ¶
GetFailData return fail state data
type FieldError ¶
type FieldError struct {
// The error that occurred
RawError error
Line int64
Column int64
Offset int64
Paths []string
}
FieldError is an error that occurred in a field at a specific path or line number and column number or offset in the file. FieldError is final state error for FieldPathError.
func NewFieldPathError ¶
func NewFieldPathError(err error, paths ...string) *FieldError
NewFieldPathError ...
type FiledPathError ¶
FiledPathError FieldPathError is an error that occurred in a field at a specific path.
type NextState ¶
type NextState struct {
Name string // Next State Name
Output any // State Output as the input of the next state
Delay time.Duration // Delay delay duration from current state to next state
Retry bool // Whether to trigger retry
RetryIndex int // Which Indexed Retry strategy hit
}
NextState next state info
type ParallelBody ¶
type ParallelBody struct {
Branches []map[string]interface{} `mapstructure:"Branches" validate:"required,gt=0"`
// contains filtered or unexported fields
}
func NewParallelBodyFromMap ¶
func NewParallelBodyFromMap(data map[string]interface{}, depth int) (*ParallelBody, error)
NewParallelBodyFromMap NewParallelBodyFromMap
type ParallelState ¶
type ParallelState struct {
*BaseState `json:",inline"`
*ParallelBody `json:",inline"`
// contains filtered or unexported fields
}
ParallelState 并行状态
func NewParallelStateFromMap ¶
func NewParallelStateFromMap(data map[string]interface{}, depth int) (*ParallelState, error)
NewParallelStateFromMap NewParallelStateFromMap
func NewParallelStateFromString ¶
func NewParallelStateFromString(definition string, depth int) (*ParallelState, error)
NewParallelStateFromString NewParallelStateFromString
func (*ParallelState) GetBaseState ¶
func (s *ParallelState) GetBaseState() *BaseState
func (*ParallelState) GetBranches ¶
func (s *ParallelState) GetBranches() []*StateMachineBody
GetBranches 返回多个分支的statemachine
func (*ParallelState) GetDefinition ¶
func (s *ParallelState) GetDefinition() (string, error)
func (*ParallelState) GetDepth ¶
func (s *ParallelState) GetDepth() int
func (*ParallelState) SetDepth ¶
func (s *ParallelState) SetDepth(depth int)
type PassState ¶
PassState ...
func NewPassStateFromMap ¶
NewPassStateFromMap Create New Pass State From Map
func NewPassStateFromString ¶
NewPassStateFromString Create New Pass State From String
func (*PassState) GetBaseState ¶
func (*PassState) GetDefinition ¶
func (*PassState) GetNextState ¶
GetNextState Get Next State
type ResourceURI ¶
ResourceURI resource uri defintion
func ParseResource ¶
func ParseResource(resource string) (uri *ResourceURI, err error)
ParseResource parser path to ResourceURI
type State ¶
type State interface {
Validate() error
GetName() string
SetName(name string)
GetType() string
GetBone() StateBone
IsEnd() bool
GetNext() []string
GetBaseState() *BaseState
GetDefinition() (string, error)
}
State ...
type StateBone ¶
type StateBone struct {
BaseBone
*StateMachineBone
Branches []StateBone `json:"Branches"`
}
StateBone for map /parallel state bone
type StateFieldRequired ¶
type StateFieldRequired struct {
Comment int
Type int
InputPath int
OutputPath int
Parameters int
ResultPath int
NextEnd int
Retry int
Catch int
}
StateFieldRequired state field required
type StateMachine ¶
type StateMachine struct {
*StateMachineHeader
*StateMachineBody
}
StateMachine ...
func NewStateMachineFromMap ¶
func NewStateMachineFromMap(data map[string]interface{}) (*StateMachine, error)
func NewStateMachineFromString ¶
func NewStateMachineFromString(data string) (*StateMachine, error)
func (*StateMachine) GetGroupStates ¶
func (sm *StateMachine) GetGroupStates() ([]StateMachineGroupState, error)
func (StateMachine) GetInput ¶
func (sm StateMachine) GetInput(input any, executioninfo any) (any, error)
GetInput GetInput
func (*StateMachine) Init ¶
func (sm *StateMachine) Init() (err error)
type StateMachineBody ¶
type StateMachineBody struct {
StartAt string `mapstructure:"StartAt" validate:"required,gt=0"`
States map[string]any `mapstructure:"States" validate:"required,gt=0"`
// contains filtered or unexported fields
}
StateMachineBody statemachine 的body 定义
func NewDefaultStateMachineBody ¶
func NewDefaultStateMachineBody(depth int) StateMachineBody
func NewStateMachineBodyFromMap ¶
func NewStateMachineBodyFromMap(data map[string]any, depth int) (smb *StateMachineBody, err error)
NewStateMachineBodyFromMap Parse data to StateMachine
func NewStateMachineBodyFromString ¶
func NewStateMachineBodyFromString(definition string, depth int) (smb *StateMachineBody, err error)
func (*StateMachineBody) AddState ¶
func (smb *StateMachineBody) AddState(newstate State)
AddState 添加状态机中的状态
func (*StateMachineBody) GetBone ¶
func (s *StateMachineBody) GetBone() StateMachineBone
func (*StateMachineBody) GetGroupStates ¶
func (smb *StateMachineBody) GetGroupStates(startGroupID int) ([]StateMachineGroupState, error)
GetGroupStates 生成状态机中所有的state的group信息,并且拉平
func (*StateMachineBody) Init ¶
func (smb *StateMachineBody) Init() (err error)
func (*StateMachineBody) SetNewStateFunc ¶
func (*StateMachineBody) SetStartAt ¶
func (s *StateMachineBody) SetStartAt(name string)
type StateMachineBone ¶
type StateMachineBone struct {
Version string `json:"Version"`
StartAt string `json:"StartAt"`
States map[string]StateBone `json:"States"`
}
StateMachineBone StateMachineBone
type StateMachineGroupState ¶
type StateMachineGroupState struct {
GroupID int //自身的所处的group
GroupIndex int // 自身所在的GroupIndex
Depth int //节点所在的 深度
Name string // StateName
State State //State
SubGroup *SubGroupState //子group列表
}
StateMachineGroupState statemachine
type StateMachineHeader ¶
type StateMachineHeader struct {
Version string `json:"Version" mapstructure:"Version" ` // 语法版本, 默认1.0
Type string `json:"Type" mapstructure:"Type"`
Comment string `json:"Comment" mapstructure:"Comment"`
QueryLanguage string `json:"QueryLanguage" mapstructure:"QueryLanguage"`
// 任务执行超时时间, 过期自动设置任务状态为失败状态
TimeoutSeconds int `json:"TimeoutSeconds" mapstructure:"TimeoutSeconds" validate:"gte=0"`
// 任务执行超时终止时间,找过指定时间后,如果任务状态为非Success,任务自动终止并且设置为 Abort状态
AbortTimeoutSeconds int `json:"AbortTimeoutSeconds" mapstructure:"AbortTimeoutSeconds" validate:"gte=0"`
// Execution 的信息路径
ExecutionInfoPath string `json:"ExecutionInfoPath" mapstructure:"ExecutionInfoPath"`
// 默认input参数
DefaultInput map[string]interface{} `json:"DefaultInput" mapstructure:"DefaultInput"`
// contains filtered or unexported fields
}
StateMachineHeader statemachine的header 定义
func NewDefaultStateMachineHeader ¶
func NewDefaultStateMachineHeader() StateMachineHeader
func NewStateMachineHeaderFromMap ¶
func NewStateMachineHeaderFromMap(data map[string]interface{}) (*StateMachineHeader, error)
NewStateMachineHeaderFromMap NewStateMachineHeaderFromMap
func NewStateMachineHeaderFromString ¶
func NewStateMachineHeaderFromString(definition string) (*StateMachineHeader, error)
NewStateMachineHeaderFromString NewStateMachineHeaderFromString
func (StateMachineHeader) GetDefinition ¶
func (h StateMachineHeader) GetDefinition() string
GetDefinition returan header definition
func (StateMachineHeader) GetInput ¶
func (h StateMachineHeader) GetInput(input interface{}, executioninfo interface{}) (interface{}, error)
GetInput 计算新的输入
func (StateMachineHeader) GetTimeout ¶
func (h StateMachineHeader) GetTimeout() StateMachineTimeout
GetTimeout return statemachine timeout
type StateMachineTimeout ¶
type StateMachineTimeout struct {
Timeout time.Duration
TaskTimeout time.Duration
AbortTimeout time.Duration
}
StateMachineTimeout StateMachine 超时的结构
type SubGroupState ¶
type SubGroupState struct {
MasterGroupID int
MasterName string
SubGroupID int `json:"group_id"`
SubStartAt string `json:"start_at"`
}
SubGroupState statemachine中的子组
type SucceedState ¶
type SucceedState struct {
*BaseState `json:",inline"`
}
SucceedState 失败节点
func NewSucceedStateFromMap ¶
func NewSucceedStateFromMap(data map[string]interface{}) (state *SucceedState, err error)
NewSucceedStateFromMap Create New Succeed State
func NewSucceedStateFromString ¶
func NewSucceedStateFromString(definition string) (state *SucceedState, err error)
NewSucceedStateFromString NewSucceedStateFromString
func (*SucceedState) GetBaseState ¶
func (s *SucceedState) GetBaseState() *BaseState
func (*SucceedState) GetDefinition ¶
func (s *SucceedState) GetDefinition() (string, error)
type SuspendState ¶
type SuspendState struct {
*BaseState
}
SuspendState suspend state
func NewSuspendStateFromMap ¶
func NewSuspendStateFromMap(data map[string]interface{}) (state *SuspendState, err error)
NewSucceedStateFromMap Create New Succeed State
func NewSuspendStateFromString ¶
func NewSuspendStateFromString(definition string) (state *SuspendState, err error)
NewSuspendStateFromString NewSuspendStateFromString
func (*SuspendState) GetBaseState ¶
func (s *SuspendState) GetBaseState() *BaseState
type TaskBody ¶
type TaskBody struct {
// Block : if block execution for task, default false
// if true, the task will block the workflow execution until the manual call to resume the task
// if false, the task will be executed automatically
Block bool `mapstructure:"Block"`
Resource string `mapstructure:"Resource" validate:"required,gt=0"`
TimeoutSeconds uint `mapstructure:"TimeoutSeconds" validate:"gte=0"`
HeartbeatSeconds uint `mapstructure:"HeartbeatSeconds" validate:"gte=0"`
// Retry for decode
Retry []TaskRetryNode `mapstructure:"Retry"`
// Catch for decode
Catch []TaskCatchNode `mapstructure:"Catch"`
}
TaskBody ...
func NewTaskBodyFromMap ¶
NewTaskBodyFromMap NewTaskBodyFromMap
type TaskCatchNode ¶
type TaskCatchNode struct {
ErrorEquals []string `mapstructure:"ErrorEquals"`
Next string `mapstructure:"Next"`
ResultPath string `mapstructure:"ResultPath"`
}
TaskCatchNode struct for catch
type TaskRetryNode ¶
type TaskRetryNode struct {
ErrorEquals []string `mapstructure:"ErrorEquals"`
IntervalSeconds uint `mapstructure:"IntervalSeconds"`
MaxAttempts uint `mapstructure:"MaxAttempts"`
BackoffRate float64 `mapstructure:"BackoffRate"`
}
TaskRetryNode struct for retry
type TaskSendData ¶
type TaskSendData struct {
Success bool // is task submit success
Retry []int // current retry times, index is retry times for each Retry branch
Errors []string // send error list
Output any // task state execute output
}
TaskSendData task state execute and send data
type TaskState ¶
TaskState ...
func NewTaskStateFromMap ¶
NewTaskStateFromMap NewTaskStateFromMap
func NewTaskStateFromString ¶
NewTaskStateFromString Create New Wait State
func (*TaskState) GetBaseState ¶
func (*TaskState) GetDefinition ¶
func (*TaskState) GetNextState ¶
func (t *TaskState) GetNextState(input any, taskdata TaskSendData) (*NextState, error)
GetNextState get task next state @input state input data @taskdata task send data return next state
func (*TaskState) GetTaskTimeout ¶
func (t *TaskState) GetTaskTimeout() (TaskTimeout, error)
GetTaskTimeout return task timeout
type TaskTimeout ¶
TaskTimeout Describe Task Timeout demand
type WaitBody ¶
type WaitBody struct {
Seconds uint `mapstructure:"Seconds" validate:"gte=0"`
Timestamp string `mapstructure:"Timestamp" validate:"gte=0"`
SecondsPath string `mapstructure:"SecondsPath" validate:"gte=0"`
TimestampPath string `mapstructure:"TimestampPath" validate:"gte=0"`
}
WaitBody ...
func NewWaitBodyFromMap ¶
func (*WaitBody) GetWakeupTime ¶
GetWakeupTime Get Wait State Wake up time
type WaitState ¶
WaitState ...
func NewWaitStateFromMap ¶
NewWaitStateFromMap Create New Wait State
func NewWaitStateFromString ¶
NewWaitStateFromString Create New Wait State
func (*WaitState) GetBaseState ¶
func (*WaitState) GetDefinition ¶
func (*WaitState) GetNextState ¶
GetNextState Get Next State