engine

package
v0.0.0-...-738d89c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserTaskClaimChannel  = "ClaimChannel"
	UserTaskReviewChannel = "ReviewChannel"
)

Variables

This section is empty.

Functions

func AsFloat

func AsFloat(in interface{}) (float64, error)

func AsInt

func AsInt(in interface{}) (int64, error)

func AsStr

func AsStr(val interface{}) interface{}

func CompletionCondition

func CompletionCondition(input string, total, undone, agree int32) (bool, error)

func DefaultActivityOption

func DefaultActivityOption() workflow.ActivityOptions

func RegistryGlobalHandler

func RegistryGlobalHandler(name string, fun HandlerFunc)

Types

type BPMN

type BPMN struct {
	// worker id
	Id          string
	Exporter    api.Exporter
	Handlers    *HandlerFuncMap
	Activity    *BpmnActivity
	ResourceDir string
}

BPMN is a workflow engine for bpmn

func NewBPMN

func NewBPMN(opts ...Option) *BPMN

func (*BPMN) Start

func (bp *BPMN) Start(ctx workflow.Context, pi *api.InstanceRequest, loader *BpmnLoader) (err error)

func (*BPMN) StartInstance

func (bp *BPMN) StartInstance(loader *BpmnLoader, pi *api.InstanceRequest) (*Iterator, error)

type BpmnActivity

type BpmnActivity struct {
	Engine *BPMN
}

func (*BpmnActivity) BusinessRuleTaskActivity

func (a *BpmnActivity) BusinessRuleTaskActivity(ctx context.Context, req api.BusinessRuleTaskActivityRequest) (vars.Mapping, error)

func (*BpmnActivity) CreateUserTaskActivity

func (a *BpmnActivity) CreateUserTaskActivity(ctx context.Context, req api.UserTaskActivityRequest) (*ent.Task, error)

CreateUserTaskActivity 创建用户任务,将任务信息返回到工作流引擎中.

func (*BpmnActivity) HttpServiceTaskActivity

func (a *BpmnActivity) HttpServiceTaskActivity(ctx context.Context, req api.ServiceTaskActivityRequest) (vars.Mapping, error)

func (*BpmnActivity) ServiceTaskActivity

func (a *BpmnActivity) ServiceTaskActivity(ctx context.Context, req api.ServiceTaskActivityRequest) (vars.Mapping, error)

type BpmnLoader

type BpmnLoader struct {
	Id   string
	Name string
	Spec *bpmn.Definitions
}

func (*BpmnLoader) FindMessage

func (ld *BpmnLoader) FindMessage(id string) *bpmn.Message

func (*BpmnLoader) FindProcess

func (ld *BpmnLoader) FindProcess(id string) *bpmn.Process

func (*BpmnLoader) FindSignal

func (ld *BpmnLoader) FindSignal(ref string) *bpmn.Signal

func (*BpmnLoader) GetId

func (ld *BpmnLoader) GetId() string

func (*BpmnLoader) GetName

func (ld *BpmnLoader) GetName() string

func (*BpmnLoader) Load

func (ld *BpmnLoader) Load(data []byte) error

func (*BpmnLoader) LoadFromFile

func (ld *BpmnLoader) LoadFromFile(path string) error

func (*BpmnLoader) Validator

func (ld *BpmnLoader) Validator() error

Validator 一致化输入数据,由于bpmn的扩展性,有些输入源是一致的.可以提前处理

type DMN

type DMN struct {
	Id string
}

func NewDMN

func NewDMN(id string) *DMN

func (*DMN) EvaluateDecision

func (d *DMN) EvaluateDecision(loader *DMNLoader, did string, ctxMap vars.Mapping) ([]vars.Mapping, error)

func (*DMN) EvaluateTable

func (d *DMN) EvaluateTable(did string, dt *dmn.DecisionTable, input vars.Mapping) (output []vars.Mapping, err error)

EvaluateTable evaluate decision table

IF THE COLLECT HIT POLICY IS USED WITH AN AGGREGATOR, THE DECISION TABLE CAN ONLY HAVE ONE OUTPUT.

func (*DMN) Result

func (d *DMN) Result(final *dmn.DecisionTable, input []vars.Mapping) (output any, err error)

Result handle the result of decision DRG dt is final decision table

func (*DMN) StartInstance

func (d *DMN) StartInstance(loader *DMNLoader, task *bpmn.BusinessRuleTask, pi *api.InstanceRequest) (vars.Mapping, error)

StartInstance start a dmn instance,return a single feel value

type DMNLoader

type DMNLoader struct {
	Id   string
	Spec *dmn.Definitions
}

func NewDMNLoader

func NewDMNLoader(id string) *DMNLoader

func (*DMNLoader) FindDecision

func (dl *DMNLoader) FindDecision(id string) *dmn.Decision

func (*DMNLoader) GetId

func (dl *DMNLoader) GetId() string

func (*DMNLoader) GetName

func (dl *DMNLoader) GetName() string

func (*DMNLoader) Load

func (dl *DMNLoader) Load(data []byte) error

func (*DMNLoader) LoadFromFile

func (dl *DMNLoader) LoadFromFile(path string) error

func (*DMNLoader) Validator

func (dl *DMNLoader) Validator() error

Validator 一致化输入数据,由于bpmn的扩展性,有些输入源是一致的.可以提前处理

type EventListen

type EventListen struct {
	// contains filtered or unexported fields
}

func (*EventListen) DoneIntermediateCatchEvent

func (elsn *EventListen) DoneIntermediateCatchEvent(ele *bpmn.IntermediateCatchEvent, vars map[string]any, cancel workflow.CancelFunc) error

func (*EventListen) MultiEventListen

func (elsn *EventListen) MultiEventListen(ctx workflow.Context)

type HandlerFunc

type HandlerFunc func(ctx context.Context, input vars.Mapping) (vars.Mapping, error)

type HandlerFuncMap

type HandlerFuncMap struct {
	// contains filtered or unexported fields
}

func NewHandlerFuncMap

func NewHandlerFuncMap(id string) *HandlerFuncMap

func (*HandlerFuncMap) RegistryHandler

func (h *HandlerFuncMap) RegistryHandler(name string, fun HandlerFunc)

func (*HandlerFuncMap) RunHandler

func (h *HandlerFuncMap) RunHandler(ctx context.Context, name string, input vars.Mapping) (vars.Mapping, error)

type Iterator

type Iterator struct {
	Request *api.InstanceRequest
	// 针对当前节点的处理函数
	CurrentHandler func(it *Iterator, ele bpmn.Elementor) (err error)
	// 针对当前队列中的全部元素的处理函数,一般用于消息型网关
	QueueHandler func(it *Iterator, subs []bpmn.Elementor) (next bpmn.Elementor, err error)
	// contains filtered or unexported fields
}

func (*Iterator) Err

func (it *Iterator) Err() error

func (*Iterator) Loader

func (it *Iterator) Loader() *BpmnLoader

func (*Iterator) Next

func (it *Iterator) Next() (exist bool)

Next 获取下一个节点.

消息型网关需要等待外部重置当前队列.

type Option

type Option func(*BPMN)

func WithExporter

func WithExporter(exporter api.Exporter) Option

WithExporter 指定外部相关接口实现.

func WithID

func WithID(id string) Option

func WithResourceDir

func WithResourceDir(dir string) Option

WithResourceDir 指定资源目录,在工作流中必须指定

type UserTaskListen

type UserTaskListen struct {
	// contains filtered or unexported fields
}

UserTaskListen listen user task signal

task.MemberCount = instances count, task.UnfinishedCount = unfinished instances count, task.AgreeCount = agree count

func (*UserTaskListen) CheckComplete

func (ul *UserTaskListen) CheckComplete(ctx context.Context, taskEle *bpmn.UserTask) (cp bool, err error)

CheckComplete 检查任务是否完成. 如果任务有多实例, 则检查多实例的完成条件

func (*UserTaskListen) Listen

func (ul *UserTaskListen) Listen(ctx workflow.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL