Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRunFlow(name string, input map[string]any) *runFlow
- 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 SetIdGenerator(method func() string)
- type BasicInfoI
- type Context
- type Controller
- type FlowConfig
- type FlowController
- type FlowInfo
- func (vc FlowInfo) ContextName() string
- func (vc FlowInfo) Get(key string) (value any, exist bool)
- func (vc FlowInfo) GetAll(key string) map[string]any
- func (bi FlowInfo) GetId() string
- func (bi FlowInfo) GetName() string
- func (vc FlowInfo) GetResult(key string) (value any, exist bool)
- func (vc FlowInfo) Set(key string, value any)
- type FlowMeta
- type Future
- type Handler
- type ProcessConfig
- func (pc *ProcessConfig) AfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *callback[*ProcessInfo]
- func (pc *ProcessConfig) AfterStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *callback[*StepInfo]
- func (pc *ProcessConfig) BeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *callback[*ProcessInfo]
- func (pc *ProcessConfig) BeforeStep(must bool, callback func(*StepInfo) (keepOn bool, err error)) *callback[*StepInfo]
- func (pc *ProcessConfig) NotUseDefault()
- func (pc *ProcessConfig) ProcessTimeout(timeout time.Duration) *ProcessConfig
- func (pc *ProcessConfig) StepsRetry(retry int) *ProcessConfig
- func (pc *ProcessConfig) StepsTimeout(timeout time.Duration) *ProcessConfig
- type ProcessInfo
- func (pi *ProcessInfo) ContextName() string
- func (vc ProcessInfo) Get(key string) (value any, exist bool)
- func (vc ProcessInfo) GetAll(key string) map[string]any
- func (bi *ProcessInfo) GetId() string
- func (bi *ProcessInfo) GetName() string
- func (vc ProcessInfo) GetResult(key string) (value any, exist bool)
- func (vc ProcessInfo) Set(key string, value any)
- type ProcessMeta
- func (pm *ProcessMeta) AliasStep(run func(ctx Context) (any, error), alias string, depends ...any) *StepMeta
- func (pm *ProcessMeta) Merge(name string)
- func (pm *ProcessMeta) Step(run func(ctx Context) (any, error), depends ...any) *StepMeta
- func (pm *ProcessMeta) Tail(run func(ctx Context) (any, error), alias string) *StepMeta
- type ResultI
- type Set
- type Status
- type StatusEnum
- type StatusI
- type StepConfig
- type StepInfo
- func (vc StepInfo) ContextName() string
- func (si *StepInfo) Error() error
- func (vc StepInfo) Get(key string) (value any, exist bool)
- func (vc StepInfo) GetAll(key string) map[string]any
- func (bi StepInfo) GetId() string
- func (bi StepInfo) GetName() string
- func (vc StepInfo) GetResult(key string) (value any, exist bool)
- func (vc StepInfo) Set(key string, value any)
- type StepMeta
- func (meta *StepMeta) Next(run func(ctx Context) (any, error), alias ...string) *StepMeta
- func (meta *StepMeta) Priority(priority map[string]any)
- func (meta *StepMeta) Retry(retry int) *StepMeta
- func (meta *StepMeta) Same(run func(ctx Context) (any, error), alias ...string) *StepMeta
- func (meta *StepMeta) Timeout(timeout time.Duration) *StepMeta
Constants ¶
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"} CallbackFail = &StatusEnum{0b1 << 21, "CallbackFail"} 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 BuildRunFlow ¶
func CopyProperties ¶
func CopyProperties(src, dst interface{})
func CopyPropertiesSkipNotEmpty ¶
func CopyPropertiesSkipNotEmpty(src, dst interface{})
CopyPropertiesSkipNotEmpty will skip field contain`skip` tag value
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 ¶
func SetIdGenerator ¶
func SetIdGenerator(method func() string)
Types ¶
type BasicInfoI ¶
type Controller ¶
type Controller interface { Resume() Pause() Stop() }
type FlowConfig ¶
type FlowConfig struct { Handler[*FlowInfo] `flow:"skip"` ProcessConfig `flow:"skip"` }
func CreateDefaultConfig ¶
func CreateDefaultConfig() *FlowConfig
func (*FlowConfig) BeforeFlow ¶
type FlowController ¶
type FlowController interface { Controller ResultI Done() []*Future ListProcess() []string ProcessController(name string) Controller }
func AsyncArgs ¶
func AsyncArgs(name string, args ...any) FlowController
type FlowInfo ¶
type FlowInfo struct {
// contains filtered or unexported fields
}
func (FlowInfo) ContextName ¶
func (vc FlowInfo) ContextName() string
type FlowMeta ¶
type FlowMeta struct { FlowConfig // contains filtered or unexported fields }
func RegisterFlow ¶
func (*FlowMeta) CloneProcess ¶
func (fm *FlowMeta) CloneProcess(name string) *ProcessMeta
func (*FlowMeta) NoUseDefault ¶
func (*FlowMeta) Process ¶
func (fm *FlowMeta) Process(name string) *ProcessMeta
type Future ¶
type Future struct { *Status // contains filtered or unexported fields }
type Handler ¶
type Handler[T BasicInfoI] struct { // contains filtered or unexported fields }
type ProcessConfig ¶
type ProcessConfig struct { StepConfig ProcTimeout time.Duration ProcNotUseDefault bool // contains filtered or unexported fields }
func (*ProcessConfig) AfterProcess ¶
func (pc *ProcessConfig) AfterProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *callback[*ProcessInfo]
func (*ProcessConfig) BeforeProcess ¶
func (pc *ProcessConfig) BeforeProcess(must bool, callback func(*ProcessInfo) (keepOn bool, err error)) *callback[*ProcessInfo]
func (*ProcessConfig) BeforeStep ¶
func (*ProcessConfig) NotUseDefault ¶
func (pc *ProcessConfig) NotUseDefault()
func (*ProcessConfig) ProcessTimeout ¶
func (pc *ProcessConfig) ProcessTimeout(timeout time.Duration) *ProcessConfig
func (*ProcessConfig) StepsRetry ¶
func (pc *ProcessConfig) StepsRetry(retry int) *ProcessConfig
func (*ProcessConfig) StepsTimeout ¶
func (pc *ProcessConfig) StepsTimeout(timeout time.Duration) *ProcessConfig
type ProcessInfo ¶
type ProcessInfo struct { FlowId string // contains filtered or unexported fields }
func (*ProcessInfo) ContextName ¶
func (pi *ProcessInfo) ContextName() string
Fix ContextName return first step name
type ProcessMeta ¶
type ProcessMeta struct { ProcessConfig // contains filtered or unexported fields }
func (*ProcessMeta) Merge ¶
func (pm *ProcessMeta) Merge(name string)
Merge will not merge config, because has not effective design to not use merged config.
type ResultI ¶
type ResultI interface { BasicInfoI Futures() []*Future Fails() []*Future }
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func CreateSetBySliceFunc ¶
func CreateSetBySliceFunc[T any, K comparable](src []T, transfer func(T) K) *Set[K]
func NewRoutineUnsafeSet ¶
func NewRoutineUnsafeSet[T comparable]() *Set[T]
type Status ¶
type Status int64
func (*Status) Append ¶
func (s *Status) Append(enum *StatusEnum) bool
func (*Status) Contain ¶
func (s *Status) Contain(enum *StatusEnum) bool
func (*Status) Exceptions ¶
Exceptions return contain exception's message
func (*Status) ExplainStatus ¶
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 ¶
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 ¶
type StatusEnum struct {
// contains filtered or unexported fields
}
func (*StatusEnum) Contained ¶
func (s *StatusEnum) Contained(explain ...string) bool
func (*StatusEnum) Message ¶
func (s *StatusEnum) Message() string
type StatusI ¶
type StatusI interface { Contain(enum *StatusEnum) bool Success() bool Exceptions() []string }
type StepConfig ¶
type StepInfo ¶
type StepInfo struct { ProcessId string FlowId string Start time.Time End time.Time Err error // contains filtered or unexported fields }
func (StepInfo) ContextName ¶
func (vc StepInfo) ContextName() string