Documentation ¶
Index ¶
- Variables
- func ExecutePredicate(context BaseState, predicate Predicate, dep Dependency) (bool, error)
- func ExecuteReshaper(context BaseState, reshaper Reshaper) (schema.Schema, error)
- func GetRunID(state State) string
- func NewMachine(di Dependency, state State) *machine.Machine[Command, State]
- func ToStrExpr(expr Expr, depth int) string
- func ToStrPredicate(predicate Predicate, depth int) string
- func ToStrReshaper(reshaper Reshaper, depth int) string
- func ToStrSchema(x schema.Schema, depth int) string
- func ToStrWorkflow(workflow Worflow, depth int) string
- type And
- type Apply
- type ApplyAwaitOptions
- type Assign
- type Await
- type BaseState
- type Callback
- type Choose
- type Compare
- type DI
- type DelayRun
- type Dependency
- type Done
- type End
- type Error
- type Execution
- type Flow
- type FlowRef
- type Function
- type FunctionInput
- type FunctionOutput
- type GetValue
- type NextOperation
- type Not
- type Or
- type ResumeOptions
- type ResumeSchedule
- type Run
- type ScheduleRun
- type ScheduleStopped
- type Scheduled
- type SetValue
- type StopSchedule
- type TryRecover
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyStarted = errors.New("already started") ErrCallbackNotMatch = errors.New("callback not match") ErrInvalidStateTransition = errors.New("invalid state transition") ErrExpressionHasResult = errors.New("expression has result") ErrStateReachEnd = errors.New("cannot apply commands, when workflow is completed") ErrMaxRetriesReached = errors.New("max retries reached") ErrFlowNotFound = errors.New("flow not found") ErrFlowNotSet = errors.New("flow not set") ErrIntervalParse = errors.New("failed to parse interval") ErrRunIDNotMatch = errors.New("run id not match") )
Functions ¶
func ExecutePredicate ¶
func ExecutePredicate(context BaseState, predicate Predicate, dep Dependency) (bool, error)
func ExecuteReshaper ¶
func NewMachine ¶
func NewMachine(di Dependency, state State) *machine.Machine[Command, State]
func ToStrPredicate ¶
func ToStrReshaper ¶
func ToStrWorkflow ¶
ToStrWorkflow returns string representation of workflow AST, a string is a meta program code, similar to go code, just declarative. Example:
func FlowHelloWorld(input string) string { var res string res = concat("hello ", input) return res }
Types ¶
type Apply ¶
type Apply struct { ID string Name string Args []Reshaper Await *ApplyAwaitOptions }
type ApplyAwaitOptions ¶
type ApplyAwaitOptions struct {
Timeout int64
}
type BaseState ¶
type BaseState struct { Flow Worflow // Flow is a reference to the flow that describes execution RunID string // RunID is a unique identifier of the execution StepID string // StepID is a unique identifier of the step in the execution Variables map[string]schema.Schema ExprResult map[string]schema.Schema // Default values DefaultMaxRetries int64 RunOption RunOption }
func GetBaseState ¶
func GetBaseState(status State) BaseState
type DI ¶
type DI struct { FindFunctionF func(funcID string) (Function, error) FindWorkflowF func(flowID string) (*Flow, error) GenerateCallbackIDF func() string GenerateRunIDF func() string // Defaults DefaultMaxRetries int64 MockTimeNow *time.Time }
func (*DI) GenerateCallbackID ¶
func (*DI) GenerateRunID ¶
func (*DI) MaxRetries ¶
type Dependency ¶
type Function ¶
type Function func(args *FunctionInput) (*FunctionOutput, error)
type FunctionInput ¶
type FunctionInput struct { // Name acts as unique function ID Name string // CallbackID is used to identify callback function, and when its set // it means that function is async, and should return result by calling callback endpoint with CallbackID CallbackID string Args []schema.Schema }
FunctionDef struct { Name string Input schema.ShapeDef Output schema.ShapeDef }
type FunctionOutput ¶
type NextOperation ¶
type ResumeOptions ¶
type ResumeOptions struct {
Timeout int64
}
type ResumeSchedule ¶
type ResumeSchedule struct {
ParentRunID string
}
type Run ¶
func ScheduleNext ¶
func ScheduleNext(x State, dep Dependency) *Run
type ScheduleRun ¶
type ScheduleRun struct { // CRON like definition Interval string }
type ScheduleStopped ¶
type Scheduled ¶
type Scheduled struct { // ExpectedRunTimestamp is server timestamp + DelayBySeconds ExpectedRunTimestamp int64 // ParentRunID is a reference to the original run, that scheduled this run and any between // ParentRunID is used to track history of the execution, and is stable reference to the original run ParentRunID string BaseState BaseState }
Scheduled is a state that is used to schedule execution of the flow, once or periodically
type StopSchedule ¶
type StopSchedule struct { // ParentRunID can be stopped by user, or by system ParentRunID string }
type TryRecover ¶
type TryRecover struct{}
Click to show internal directories.
Click to hide internal directories.