Documentation ¶
Overview ¶
* Description : workflow engine v3.1 Author : dayunzhangyunfeng@didiglobal.com Date : 2021-05-14
*
Description : workflow v3.0 with branch Author : dayunzhangyunfeng@didiglobal.com Date : 2021-05-14
Index ¶
- Constants
- func GetLatestVersionFromFile(path string) (string, error)
- func LoadSceneModuleMapFromFile(path string) (map[int64]*SceneModule, error)
- func LoadWorkflowFromApollo(configParams map[string]string) (map[int64]*Workflow, error)
- func LoadWorkflowFromFile(dirPath string, smMap map[int64]*SceneModule) (map[int64]*Workflow, error)
- type Action
- type CondExecutors
- type Condition
- func (c *Condition) EQ(itra, itrb interface{}) (string, error)
- func (c *Condition) GE(itra, itrb interface{}) (string, error)
- func (c *Condition) GT(itra, itrb interface{}) (string, error)
- func (c *Condition) LE(itra, itrb interface{}) (string, error)
- func (c *Condition) LT(itra, itrb interface{}) (string, error)
- func (c *Condition) NE(itra, itrb interface{}) (string, error)
- func (c *Condition) SW(itra interface{}) (string, error)
- type FlowSelector
- type GroupSelector
- type IModelBase
- type ModelBase
- type ModuleObjBase
- type Param
- type RandomSelector
- type SceneModule
- type TimeWaiter
- type Workflow
- type WorkflowBranch
- type WorkflowChart
- type WorkflowEngine
- func NewWorkflowEngine(sceneModuleMap map[int64]*SceneModule, workflowMap map[int64]*Workflow, ...) (*WorkflowEngine, error)
- func NewWorkflowEngineFromConfig(moduleObj ModuleObjBase, configParams map[string]string) (*WorkflowEngine, error)
- func NewWorkflowEngineFromFile(moduleObj ModuleObjBase, configPath string) (*WorkflowEngine, error)
- func NewWorkflowEngineFromKV(moduleObj ModuleObjBase, sceneModuleMapString, workflowMapStr, version string) (*WorkflowEngine, error)
- func (w *WorkflowEngine) GetVersion() string
- func (w *WorkflowEngine) GetWorkflow(workflowId int64) (*Workflow, bool)
- func (w *WorkflowEngine) RegisterCondExecutor(conditionName string, executor interface{})
- func (w *WorkflowEngine) Run(ctx context.Context, sc *model.StrategyContext)
- func (w *WorkflowEngine) SelectWorkflow(ctx context.Context, sc *model.StrategyContext) (*Workflow, error)
- func (w *WorkflowEngine) SetCustomFlowSelector(flowSelector FlowSelector)
Constants ¶
View Source
const ( YES = "Y" NO = "N" )
View Source
const ( RedisKeySceneModule = "scene_module_app_" RedisKeyWorkflow = "workflow_app_" RedisKeyVersion = "version_app_" )
View Source
const ( ActionTypeTask = "task" ActionTypeCond = "condition" ActionTypeFlow = "flow" ActionTypeTimeout = "timeout" BranchKeyDefault = "default" BranchKeyJoiner = "_" )
View Source
const (
ErrNoUnknown = 1000
)
Variables ¶
This section is empty.
Functions ¶
func LoadSceneModuleMapFromFile ¶
func LoadSceneModuleMapFromFile(path string) (map[int64]*SceneModule, error)
func LoadWorkflowFromApollo ¶
func LoadWorkflowFromFile ¶
Types ¶
type Action ¶
type Action struct { ActionType string `json:"action_type"` ActionId string `json:"action_id"` ActionName string `json:"action_name"` Params []*Param `json:"params"` NextActionIds []string `json:"next_action_ids"` NextConditions []string `json:"next_conditions"` PrevActionIds []string `json:"prev_action_ids"` Timeout int64 `json:"timeout"` TimeoutAsync bool `json:"timeout_async"` TimeoutDynamic bool `json:"timeout_dynamic"` RefWorkflowId int64 `json:"ref_workflow_id"` Description string `json:"description"` }
type CondExecutors ¶
func GetCondExecutors ¶
func GetCondExecutors() *CondExecutors
func (CondExecutors) Execute ¶
func (c CondExecutors) Execute(actionName string, paramValues []interface{}) (string, error)
func (CondExecutors) RegisterCondExecutor ¶
func (c CondExecutors) RegisterCondExecutor(conditionName string, cdt interface{})
type Condition ¶
type Condition struct{}
type FlowSelector ¶
type FlowSelector interface {
SelectWorkflowId(sc *model.StrategyContext, sceneModule *SceneModule) (int64, string, error)
}
* there are 3 flow selector:
1: random 2: custom 3: apollo (apollo platform in didi)
type GroupSelector ¶
type GroupSelector struct {
FlowSelector
}
func (*GroupSelector) SelectWorkflowId ¶
func (a *GroupSelector) SelectWorkflowId(sc *model.StrategyContext, sceneModule *SceneModule) (int64, string, error)
* apollo分流, 如果出现error,就取缺省分桶,同时返回error信息
type IModelBase ¶
type IModelBase interface { DoAction(context.Context, *model.StrategyContext) interface{} OnTimeout(context.Context, *model.StrategyContext) SetName(string) GetName() string }
type ModelBase ¶
type ModelBase struct { IModelBase Name string }
func (*ModelBase) DoAction ¶
func (m *ModelBase) DoAction(context.Context, *model.StrategyContext) interface{}
type ModuleObjBase ¶
type ModuleObjBase interface {
NewObj(moduleName string) IModelBase
}
type RandomSelector ¶
type RandomSelector struct {
FlowSelector
}
func (*RandomSelector) SelectWorkflowId ¶
func (r *RandomSelector) SelectWorkflowId(sc *model.StrategyContext, sceneModule *SceneModule) (int64, string, error)
在线随机分流
type SceneModule ¶
type SceneModule struct { Id int64 `json:"id"` Name string `json:"name"` AppId int64 `json:"appid"` BucketType int `json:"bucket_type"` SlotMap map[int]int64 `json:"slots"` UpdateTime time.Time `json:"update_time"` FlowType int `json:"flow_type"` GroupWorkflowMap map[string]int64 `json:"group_workflows"` DefaultWorkflowId int64 `json:"default_workflow_id"` DispatchExperimentName string `json:"dispatch_experiment_name"` }
func (*SceneModule) GetWorkflowId ¶
func (this *SceneModule) GetWorkflowId(groupName string) (int64, error)
type TimeWaiter ¶
type TimeWaiter struct {
// contains filtered or unexported fields
}
func NewTimeWaiter ¶
func NewTimeWaiter(timeOut int64) *TimeWaiter
func (*TimeWaiter) AddTimeout ¶
func (t *TimeWaiter) AddTimeout(timeout int64)
func (*TimeWaiter) Done ¶
func (t *TimeWaiter) Done()
func (*TimeWaiter) Wait ¶
func (t *TimeWaiter) Wait() bool
type Workflow ¶
type Workflow struct { Id int64 `json:"id"` DimensionId int64 `json:"dimension_id"` SceneId int64 `json:"scene_id"` FlowChart string `json:"flow_chart"` FlowCharts *WorkflowChart `json:"flow_charts"` FlowBranch *WorkflowBranch `json:"flow_branch"` IsDefault int `json:"is_default"` Range1 string `json:"range1"` Range2 string `json:"range2"` Remark string `json:"remark"` UpdateTime time.Time `json:"update_time"` GroupName string `json:"group_name"` }
func (*Workflow) GetWorkflowChart ¶
func (w *Workflow) GetWorkflowChart() *WorkflowChart
type WorkflowBranch ¶
type WorkflowChart ¶
type WorkflowChart struct { FirstActionId string `json:"first_action_id"` LastActionId string `json:"last_action_id"` HashCondition bool `json:"has_condition"` ActionMap map[string]*Action `json:"actions"` }
func NewWorkflowChart ¶
func NewWorkflowChart(flowChartStr string) (*WorkflowChart, error)
func (*WorkflowChart) CreateWaitMap ¶
func (w *WorkflowChart) CreateWaitMap() (map[string]*sync.WaitGroup, map[string]*TimeWaiter)
type WorkflowEngine ¶
type WorkflowEngine struct { FlowSelectors map[int]FlowSelector `json:"flow_selectors"` // contains filtered or unexported fields }
func NewWorkflowEngine ¶
func NewWorkflowEngine(sceneModuleMap map[int64]*SceneModule, workflowMap map[int64]*Workflow, version string, moduleObj ModuleObjBase) (*WorkflowEngine, error)
func NewWorkflowEngineFromConfig ¶
func NewWorkflowEngineFromConfig(moduleObj ModuleObjBase, configParams map[string]string) (*WorkflowEngine, error)
func NewWorkflowEngineFromFile ¶
func NewWorkflowEngineFromFile(moduleObj ModuleObjBase, configPath string) (*WorkflowEngine, error)
func NewWorkflowEngineFromKV ¶
func NewWorkflowEngineFromKV(moduleObj ModuleObjBase, sceneModuleMapString, workflowMapStr, version string) (*WorkflowEngine, error)
func (*WorkflowEngine) GetVersion ¶
func (w *WorkflowEngine) GetVersion() string
func (*WorkflowEngine) GetWorkflow ¶
func (w *WorkflowEngine) GetWorkflow(workflowId int64) (*Workflow, bool)
func (*WorkflowEngine) RegisterCondExecutor ¶
func (w *WorkflowEngine) RegisterCondExecutor(conditionName string, executor interface{})
func (*WorkflowEngine) Run ¶
func (w *WorkflowEngine) Run(ctx context.Context, sc *model.StrategyContext)
func (*WorkflowEngine) SelectWorkflow ¶
func (w *WorkflowEngine) SelectWorkflow(ctx context.Context, sc *model.StrategyContext) (*Workflow, error)
func (*WorkflowEngine) SetCustomFlowSelector ¶
func (w *WorkflowEngine) SetCustomFlowSelector(flowSelector FlowSelector)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.