go-activiti

command module
v0.0.0-...-8b75618 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

Go语言流程引擎go-activiti

项目传送门go-activiti

参考Activiti实现,满足部分功能。项目还在完善中,欢迎activiti爱好者加入,Go语言她不香么。

现有能力

  • 节点类型,支持用户审批节点、排他网关、包容网关、并行网关
  • 流程功能,支持流程部署、流程发起、流程审批,流程驳回
  • 支持历史数据回溯
  • 全局事务
  • 全局事件监听,现支持节点事件处理
  • 节点事件回调

BPMN文件解析,先使用的是JSON库,使用方便,但存在缺陷,不支持扩展后续完善件process

全局事务

参考activiti设计模式,依赖命令模式和责任链模式,使用gorm的事务能力,不需要关注事务。

defer db.ClearTXDB()
db.GORM_DB.Transaction(func(tx *gorm.DB) error {
	db.InitTXDB(tx)
	value, err = transactionContextInterceptor.Next.Execute(command)
	return err
 })

*流程事件监听

需实现ActivitiEventListener,将实现类加入配置文件

type ActivitiListener struct {
	name string
}

func (act ActivitiListener) OnEvent(event event.ActivitiEvent) error {
	fmt.Println(event)
	return nil
}
	configuration := behavior.GetProcessEngineConfiguration()
	eventListeners := make([]event.ActivitiEventListener, 0)
	eventListeners = append(eventListeners, ActivitiListener{})
	configuration.AddEventListeners(eventListeners)

节点事件回调

需实现IActiviti,注册构造器,参考iActivitiDemo.go文件

func init() {
	RegisterConstructor("userAuto", NewTestIActiviti)
}

func NewTestIActiviti(entity ExecutionEntity) IActiviti {
	return &TestIActiviti{
		Entity: entity,
	}
}

后续计划:

  • 支持更多节点类型
  • bpmn解析完善,可扩展
  • 流程能力支持:流程跳转,撤销等等
  • 日志打印(优先)
  • 数据库默认值处理
  • 项目结构调整

期待您的加入。

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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