Documentation ¶
Index ¶
- Constants
- Variables
- func CopyProperties(src, dst interface{})
- func CopyPropertiesSkipNotEmpty(src, dst interface{})
- func CreateStruct[T any](src any) (target T)
- func GetFuncName(f interface{}) string
- func GetStructName(obj any) string
- func NewProcessConfig() *processConfig
- func SetIdGenerator(method func() string)
- type BasicInfo
- type BasicInfoI
- type Callback
- type CallbackChain
- type Configuration
- func (pc Configuration) AddAfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
- func (pc Configuration) AddAfterStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *Callback[*StepInfo]
- func (pc Configuration) AddBeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
- func (pc Configuration) AddBeforeStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *Callback[*StepInfo]
- func (pc Configuration) AddStepRetry(retry int) *processConfig
- func (pc Configuration) AddStepTimeout(timeout time.Duration) *processConfig
- type Context
- type Controller
- type Feature
- type FlowConfig
- type FlowController
- type FlowInfo
- type FlowMeta
- func (fm *FlowMeta) AddProcess(name string) *ProcessMeta
- func (fm *FlowMeta) AddProcessWithConf(name string, conf *processConfig) *ProcessMeta
- func (fm *FlowMeta) AddRegisterProcess(name string)
- func (fm *FlowMeta) BuildRunFlow(input map[string]any) *RunFlow
- func (fm *FlowMeta) NotUseDefault() *FlowMeta
- type ProcessInfo
- type ProcessMeta
- func (pc ProcessMeta) AddAfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
- func (pc ProcessMeta) AddAfterStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *Callback[*StepInfo]
- func (pc ProcessMeta) AddBeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
- func (pc ProcessMeta) AddBeforeStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *Callback[*StepInfo]
- func (pm *ProcessMeta) AddStep(run func(ctx *Context) (any, error), depends ...any) *StepMeta
- func (pc ProcessMeta) AddStepRetry(retry int) *processConfig
- func (pc ProcessMeta) AddStepTimeout(timeout time.Duration) *processConfig
- func (pm *ProcessMeta) AddStepWithAlias(alias string, run func(ctx *Context) (any, error), depends ...any) *StepMeta
- func (pm *ProcessMeta) AddWaitAll(alias string, run func(ctx *Context) (any, error)) *StepMeta
- func (pm *ProcessMeta) AddWaitBefore(alias string, run func(ctx *Context) (any, error)) *StepMeta
- func (pm *ProcessMeta) Merge(name string)
- func (pm *ProcessMeta) NotUseDefault()
- type ResultI
- type RunFlow
- func (rf *RunFlow) Done() map[string]*Feature
- func (rf *RunFlow) FailFeatures() map[string]*Feature
- func (rf *RunFlow) Features() map[string]*Feature
- func (rf *RunFlow) Flow() map[string]*Feature
- func (rf *RunFlow) ListProcess() []string
- func (rf *RunFlow) Pause()
- func (rf *RunFlow) ProcessController(name string) Controller
- func (rf *RunFlow) Resume()
- func (rf *RunFlow) SkipFinishedStep(name string, result any) error
- func (rf *RunFlow) Stop()
- type RunProcess
- func (pc RunProcess) AddAfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
- func (pc RunProcess) AddAfterStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *Callback[*StepInfo]
- func (pc RunProcess) AddBeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
- func (pc RunProcess) AddBeforeStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *Callback[*StepInfo]
- func (pc RunProcess) AddStepRetry(retry int) *processConfig
- func (pc RunProcess) AddStepTimeout(timeout time.Duration) *processConfig
- func (rp *RunProcess) Pause()
- func (rp *RunProcess) Resume()
- func (rp *RunProcess) SkipFinishedStep(name string, result any)
- func (rp *RunProcess) Stop()
- type RunStep
- type Set
- type Status
- type StatusEnum
- type StatusI
- type StepConfig
- type StepInfo
- type StepMeta
Constants ¶
const ( InternalPrefix = "::" WorkflowCtx = "Flow::" ProcessCtx = "Proc::" )
these constants are used to indicate the scope of the context
const ( Before = "Before" After = "After" )
Variables ¶
var ( End = &StatusEnum{0b1, "End"} Head = &StatusEnum{0b1 << 1, "Head"} HasNext = &StatusEnum{0b1 << 2, "HasNext"} Merged = &StatusEnum{0b1 << 3, "Merged"} )
these constants are used to indicate the position of the process
var ( Pending = &StatusEnum{0, "Pending"} Running = &StatusEnum{0b1, "Running"} Pause = &StatusEnum{0b1 << 1, "Pause"} Success = &StatusEnum{0b1 << 15, "Success"} NormalMask = &StatusEnum{0b1<<16 - 1, "NormalMask"} Cancel = &StatusEnum{0b1 << 16, "Cancel"} Timeout = &StatusEnum{0b1 << 17, "Timeout"} Panic = &StatusEnum{0b1 << 18, "Panic"} Error = &StatusEnum{0b1 << 19, "Error"} Stop = &StatusEnum{0b1 << 20, "Stop"} Failed = &StatusEnum{0b1 << 31, "Failed"} // AbnormalMask An abnormal step status will cause the cancellation of dependent unexecuted steps. AbnormalMask = &StatusEnum{NormalMask.flag << 16, "AbnormalMask"} )
these variable are used to indicate the status of the unit
Functions ¶
func CopyProperties ¶
func CopyProperties(src, dst interface{})
func CopyPropertiesSkipNotEmpty ¶ added in v1.10.0
func CopyPropertiesSkipNotEmpty(src, dst interface{})
func CreateStruct ¶
func GetFuncName ¶
func GetFuncName(f interface{}) string
GetFuncName function retrieves the stepName of a provided function. If the provided function is anonymous function, it panics.
func GetStructName ¶ added in v1.9.0
func NewProcessConfig ¶ added in v1.11.0
func NewProcessConfig() *processConfig
func SetIdGenerator ¶ added in v1.7.1
func SetIdGenerator(method func() string)
Types ¶
type BasicInfoI ¶ added in v1.11.0
type Callback ¶ added in v1.10.0
type Callback[T BasicInfoI] struct { // contains filtered or unexported fields }
func (*Callback[T]) Exclude ¶ added in v1.10.0
func (c *Callback[T]) Exclude(status ...*StatusEnum) *Callback[T]
func (*Callback[T]) When ¶ added in v1.10.0
func (c *Callback[T]) When(status ...*StatusEnum) *Callback[T]
type CallbackChain ¶ added in v1.10.0
type CallbackChain[T BasicInfoI] struct { // contains filtered or unexported fields }
func (*CallbackChain[T]) AddCallback ¶ added in v1.10.0
func (*CallbackChain[T]) CopyChain ¶ added in v1.10.0
func (cc *CallbackChain[T]) CopyChain() []*Callback[T]
type Configuration ¶ added in v1.10.0
type Configuration struct { *FlowConfig // contains filtered or unexported fields }
func CreateDefaultConfig ¶ added in v1.11.0
func CreateDefaultConfig() *Configuration
func (Configuration) AddAfterProcess ¶ added in v1.10.0
func (pc Configuration) AddAfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
func (Configuration) AddAfterStep ¶ added in v1.10.0
func (Configuration) AddBeforeProcess ¶ added in v1.10.0
func (pc Configuration) AddBeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
func (Configuration) AddBeforeStep ¶ added in v1.10.0
func (Configuration) AddStepRetry ¶ added in v1.11.0
func (pc Configuration) AddStepRetry(retry int) *processConfig
func (Configuration) AddStepTimeout ¶ added in v1.11.0
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) Exposed ¶ added in v1.9.0
Exposed method exposes a key-value pair to the scope, so that units within the scope (steps in the process) can access it.
func (*Context) Get ¶
Get method retrieves the value associated with the given key from the context path. The method first checks the priority context, then own context, finally parents context. Returns the value associated with the key (if found) and a boolean indicating its presence.
func (*Context) GetCtxName ¶ added in v1.11.0
func (*Context) GetStepResult ¶
GetStepResult method retrieves the result of a step's execution. Each time a step is executed, its execution result is saved in the context of the process. Use this method to retrieve the execution result of a step.
type Controller ¶ added in v1.9.0
type Controller interface { Resume() Pause() Stop() }
type FlowConfig ¶ added in v1.10.0
type FlowConfig struct { *CallbackChain[*FlowInfo] }
func (*FlowConfig) AddAfterFlow ¶ added in v1.10.0
func (*FlowConfig) AddBeforeFlow ¶ added in v1.10.0
type FlowController ¶ added in v1.10.0
type FlowController interface { Controller ResultI Done() map[string]*Feature ListProcess() []string ProcessController(name string) Controller }
func AsyncArgs ¶ added in v1.9.0
func AsyncArgs(name string, args ...any) FlowController
type FlowMeta ¶ added in v1.9.0
type FlowMeta struct { *FlowConfig // contains filtered or unexported fields }
func RegisterFlow ¶ added in v1.9.0
func (*FlowMeta) AddProcess ¶ added in v1.9.0
func (fm *FlowMeta) AddProcess(name string) *ProcessMeta
func (*FlowMeta) AddProcessWithConf ¶ added in v1.10.0
func (fm *FlowMeta) AddProcessWithConf(name string, conf *processConfig) *ProcessMeta
func (*FlowMeta) AddRegisterProcess ¶ added in v1.9.0
func (*FlowMeta) BuildRunFlow ¶ added in v1.10.0
func (*FlowMeta) NotUseDefault ¶ added in v1.10.0
type ProcessInfo ¶
type ProcessMeta ¶ added in v1.9.0
type ProcessMeta struct {
// contains filtered or unexported fields
}
func (ProcessMeta) AddAfterProcess ¶ added in v1.11.0
func (pc ProcessMeta) AddAfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
func (ProcessMeta) AddAfterStep ¶ added in v1.11.0
func (ProcessMeta) AddBeforeProcess ¶ added in v1.11.0
func (pc ProcessMeta) AddBeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
func (ProcessMeta) AddBeforeStep ¶ added in v1.11.0
func (ProcessMeta) AddStepRetry ¶ added in v1.11.0
func (pc ProcessMeta) AddStepRetry(retry int) *processConfig
func (ProcessMeta) AddStepTimeout ¶ added in v1.11.0
func (*ProcessMeta) AddStepWithAlias ¶ added in v1.9.0
func (*ProcessMeta) AddWaitAll ¶ added in v1.9.0
func (*ProcessMeta) AddWaitBefore ¶ added in v1.9.0
AddWaitBefore method treats the last added step as a dependency
func (*ProcessMeta) Merge ¶ added in v1.9.0
func (pm *ProcessMeta) Merge(name string)
func (*ProcessMeta) NotUseDefault ¶ added in v1.10.0
func (pm *ProcessMeta) NotUseDefault()
type ResultI ¶ added in v1.10.0
type ResultI interface { BasicInfoI Features() map[string]*Feature FailFeatures() map[string]*Feature }
type RunFlow ¶ added in v1.9.0
func (*RunFlow) FailFeatures ¶ added in v1.10.0
func (*RunFlow) Flow ¶ added in v1.10.0
Flow function asynchronous execute process of workflow and return immediately.
func (*RunFlow) ListProcess ¶ added in v1.9.0
func (*RunFlow) ProcessController ¶ added in v1.10.0
func (rf *RunFlow) ProcessController(name string) Controller
func (*RunFlow) SkipFinishedStep ¶ added in v1.9.0
type RunProcess ¶ added in v1.9.0
type RunProcess struct { *ProcessMeta *Context *Status // contains filtered or unexported fields }
func (RunProcess) AddAfterProcess ¶ added in v1.11.0
func (pc RunProcess) AddAfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
func (RunProcess) AddAfterStep ¶ added in v1.11.0
func (RunProcess) AddBeforeProcess ¶ added in v1.11.0
func (pc RunProcess) AddBeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *Callback[*ProcessInfo]
func (RunProcess) AddBeforeStep ¶ added in v1.11.0
func (RunProcess) AddStepRetry ¶ added in v1.11.0
func (pc RunProcess) AddStepRetry(retry int) *processConfig
func (RunProcess) AddStepTimeout ¶ added in v1.11.0
func (*RunProcess) Pause ¶ added in v1.9.0
func (rp *RunProcess) Pause()
func (*RunProcess) Resume ¶ added in v1.9.0
func (rp *RunProcess) Resume()
func (*RunProcess) SkipFinishedStep ¶ added in v1.9.0
func (rp *RunProcess) SkipFinishedStep(name string, result any)
func (*RunProcess) Stop ¶ added in v1.9.0
func (rp *RunProcess) Stop()
type Set ¶ added in v1.9.0
type Set[T comparable] struct { // contains filtered or unexported fields }
func CreateFromSliceFunc ¶ added in v1.9.0
func CreateFromSliceFunc[T any, K comparable](src []T, transfer func(T) K) *Set[K]
func NewRoutineUnsafeSet ¶ added in v1.9.0
func NewRoutineUnsafeSet[T comparable]() *Set[T]
type Status ¶ added in v1.10.0
type Status int64
func (*Status) Append ¶ added in v1.11.0
func (s *Status) Append(enum *StatusEnum) bool
func (*Status) Contain ¶ added in v1.10.0
func (s *Status) Contain(enum *StatusEnum) bool
func (*Status) Exceptions ¶ added in v1.10.0
Exceptions return contain exception's message
func (*Status) ExplainStatus ¶ added in v1.10.0
ExplainStatus function explains the status represented by the provided bitmask. The function checks the status against predefined abnormal and normal flags, and returns a slice of strings containing the names of the matching flags. Parameter status is the bitmask representing the status. The returned slice contains the names of the matching flags in the layer they were found. If abnormal flags are found, normal flags will be ignored.
func (*Status) Pop ¶ added in v1.10.0
func (s *Status) Pop(enum *StatusEnum) bool
Pop function pops a status bit from the specified address. The function checks if the specified status bit exists in the current value. If it exists, it removes the status bit, and returns true indicating successful removal of the status bit. Otherwise, it returns false.
type StatusEnum ¶ added in v1.10.0
type StatusEnum struct {
// contains filtered or unexported fields
}
func (*StatusEnum) Contained ¶ added in v1.10.0
func (s *StatusEnum) Contained(explain ...string) bool
func (*StatusEnum) Message ¶ added in v1.10.0
func (s *StatusEnum) Message() string
type StatusI ¶ added in v1.10.0
type StatusI interface { Contain(enum *StatusEnum) bool Success() bool Exceptions() []string }
type StepConfig ¶
type StepInfo ¶
type StepMeta ¶ added in v1.9.0
type StepMeta struct { *Status *StepConfig // contains filtered or unexported fields }
func (*StepMeta) AddConfig ¶ added in v1.9.0
func (meta *StepMeta) AddConfig(config *StepConfig)
AddConfig allow step not using process's config