CabloyJS Basic introduction of built-in workflow engine
1. origin
as everyone knows ,NodeJS As a back-end development language and running environment , Support high concurrency 、 High development efficiency , enjoy great popularity among the people , But mostly used for data CRUD management
、 Middle layer aggregation
and Middle agent
Other tool scenarios , Rarely go deep into the core of the business field . There are many uses NodeJS Developed Minimum available products (MVP)
Eventually, it will start anew and restructure , This is one of the reasons
The root of it ,NodeJS As a business development platform , There are still many core basic components missing ,NodeJS Workflow engine
One of them .CabloyJS from 4.0 Since version , Focus on the development of NodeJS Workflow engine , And as a built-in basic core module ( It's also open source 、 free ), It has been further expanded NodeJS Application scenarios in the back end , In order to further develop various business logic , Provides the foundation support
2. characteristic
- Easier configuration : use
JSON
Configure the process definition , a farewellXML
Miscellaneous configuration files - Clearer Architecture : be based on
Layering mechanism
Adopt multiple core modules to build the architecture of workflow engine , Make workflow no longer mysterious , The source code is no longer stacked
The concept and implementation of boundary event
1. Activiti Boundary events
stay Activiti
In the process engine , Can pass Boundary event
towards Process nodes
Add processing logic for specific purposes . such as , towards Process nodes
Add one more Timer boundary event
, If the node does not complete execution within the specified time , Will trigger automatically Boundary event
2. CabloyJS Node behavior of
because Boundary event
The essence of is to Process nodes
Attach specific Behavior
. therefore ,CabloyJS use Node behavior
Mechanism to achieve something similar Activiti
in Boundary event
The function of
CabloyJS by Node behavior
Designed a unified development specification , Allow third parties to develop customized Node behavior
type .CabloyJS The system itself will also be based on the actual needs and priorities of the business , Continuously increase the built-in Node behavior
type
3. The difference between boundary events and node behavior
Simple configuration
:- stay Activiti in ,
Boundary event
Separate XML Node configuration , And withActive node
Establishing a connection - stay CabloyJS in , Directly in
Active node
Of JSON Add in configurationBehavior
To configure , Make the process definition file more concise 、 compact
- stay Activiti in ,
Easy to develop
:- stay Activiti in , There are several built-in
Boundary event
, Most scenarios are based on these built-inBoundary event
Do development , But few people try to develop customizedBoundary event
- stay CabloyJS in , It provides a very clear programming interface , Not only built-in common
Node behavior
, And it allows third parties to easily develop customizedNode behavior
type
- stay Activiti in , There are several built-in
demonstration
The following diagram shows :
- towards
Audit node
increaseTimeout behavior
, The system automatically assigns a color , Used to distinguish between differentBehavior
- Set up
Behavior
Configuration of :The duration of the
- from
Behavior
Pull out oneTransfer line
, Point toDrafting node
- effect : When the audit is not completed after the specified time , Will automatically turn
Drafting node
If you want to further study how to create a complete Process definition
, Please see the :
JSON standard
For support Node behavior
, Based on the original process definition , At the same time, it expands Active node JSON standard
and Transfer line JSON standard
, See :
1. Active node JSON standard
In the regular Active node JSON standard
Added in behaviors
attribute . Due to a node
You can attach multiple Behavior
, therefore behaviors
Is an array
{
id: 'activity_1',
name: 'Review',
type: 'activityUserTask',
options: {
assignees: {
vars: 'flowUser',
},
},
behaviors: [
{
id: 'behavior_1',
name: 'Overtime',
type: 'overtime',
color: '#FF3B30',
options: {
cancelActivity: true,
timeDuration: 3000,
},
},
],
},
- behavior
name | explain |
---|---|
id | Unique identification of behavior |
name | The name of the act |
type | Type of behavior |
color | Behavior color . because Behavior It can also lead to Transfer line , Therefore, it can be distinguished by different colors |
options | Behavior configuration , Corresponding to different behavior types |
2. Transfer line JSON standard
In the regular Transfer line JSON standard
Added in behavior
attribute , Used to identify the Transfer line
The corresponding Behavior Id
{
id: 'edge_3',
source: 'activity_1',
target: 'startEvent_1',
behavior: 'behavior_1',
},
name | explain |
---|---|
behavior | Corresponding Behavior Id , If it is not set, it is node By itself Transfer line |
Related links
- CabloyJS Website : https://cabloy.com/
- NodeJS Workflow engine documents :https://cabloy.com/zh-cn/arti...
- GitHub Source warehouse : https://github.com/zhennann/c...