Documentation ¶
Overview ¶
* Description : workflow engine v3.1 Author : dayunzhangyunfeng@didiglobal.com Date : 2021-05-14
* Description : flow splitter 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 FlowByApollo(sc *model.StrategyContext, sceneModule *SceneModule) (int64, string, error)
- func FlowByOnlineRandom(sc *model.StrategyContext, sceneModule *SceneModule) (int64, int)
- func GetLatestVersionFromApollo(namespace, configName string) (string, error)
- func GetLatestVersionFromFile(path string) (string, error)
- func GetLatestVersionFromRedis(appId int64) (string, error)
- func LoadSceneModuleMap(appId int64) (map[int64]*SceneModule, error)
- func LoadSceneModuleMapFromFile(path string) (map[int64]*SceneModule, error)
- func LoadWorkflow(appId int64, smMap map[int64]*SceneModule) (map[int64]*Workflow, 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 ActionCounter
- 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 IModelBase
- type ModelBase
- type ModuleObjBase
- type Param
- type SceneModule
- type TimeWaiter
- type Workflow
- type WorkflowBranch
- type WorkflowChart
- type WorkflowEngine
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 FlowByApollo ¶
func FlowByApollo(sc *model.StrategyContext, sceneModule *SceneModule) (int64, string, error)
FlowByApollo apollo分流
func FlowByOnlineRandom ¶
func FlowByOnlineRandom(sc *model.StrategyContext, sceneModule *SceneModule) (int64, int)
在线随机分流
func LoadSceneModuleMap ¶
func LoadSceneModuleMap(appId int64) (map[int64]*SceneModule, error)
func LoadSceneModuleMapFromFile ¶
func LoadSceneModuleMapFromFile(path string) (map[int64]*SceneModule, error)
func LoadWorkflow ¶
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 ActionCounter ¶
type ActionCounter struct {
// contains filtered or unexported fields
}
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 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, vMap map[string]string) IModelBase
}
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 {
// contains filtered or unexported fields
}
func NewWorkflowEngine ¶
func NewWorkflowEngine(moduleObj ModuleObjBase, appId int64) (*WorkflowEngine, error)
func NewWorkflowEngineFromApollo ¶
func NewWorkflowEngineFromApollo(moduleObj ModuleObjBase, namespace, configName string) (*WorkflowEngine, error)
func NewWorkflowEngineFromFile ¶
func NewWorkflowEngineFromFile(moduleObj ModuleObjBase, configPath string) (*WorkflowEngine, error)
func (*WorkflowEngine) GetVersion ¶
func (w *WorkflowEngine) GetVersion() string
func (*WorkflowEngine) RegisterCondExecutor ¶
func (w *WorkflowEngine) RegisterCondExecutor(conditionName string, executor interface{})
func (*WorkflowEngine) Run ¶
func (w *WorkflowEngine) Run(ctx context.Context, sc *model.StrategyContext)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.