Workflow Core
WorkflowCore is under development, the codebase is unoptimized and has many bad practices, I may do breaking changes even force pushing to master branch.
In short, it's not ready yet, but I realize that a workflow engine is complicated to design and it needs a long term to done well, so I decide to open source at early stage.
Any way, feedbacks and suggestions are highly welcome!
A Rails engine which providing essential infrastructure of workflow.
It's based on Workflow Net technique.
The gem provides:
- Models to describe workflow nets
- Models to describe workflow instances
- Interfaces to define transitions
Why “core”
Because it's not aim to "out-of-box", some gem like Devise giving developer an out-of-box experience, that's awesome, but on the other hand, it also introducing a very complex abstraction that may hard to understanding how it works, especially when you attempting to customize it.
I believe that the gem is tightly coupled with features that face to end users directly, so having a good customizability and easy to understanding are of the most concern, so I just wanna give you a domain framework that you can build your own that just fitting your need, and you shall have fully control and without any unnecessary abstraction.
BTW, the dummy app is a full-featured app with production level codebase that you can freely to reference it.
Todo
- Make sure transit must be an atomic operation, and help developers to avoiding Rails' nested transaction pitfalls.
- Consider consequences of changing the Net, well handle Net changes. e.g: what about running instances?
- Stabilizing interfaces.
- Evaluate that can supporting async, scheduled and event-based transition properly.
- Efficiency (especially on database).
- Easy to use.
- Transforming to graph representation for visualization and other usages (e.g proving Soundness).
- Polish codebase.
- Continually improving dummy app.
Requirements
- MRI 2.3+
- Rails 5.0+
Usage
See demo for now.
Installation
Add this line to your Gemfile:
gem 'workflow_core'
Or you may want to include the gem directly from GitHub:
gem 'workflow_core', github: 'rails-engine/workflow_core'
And then execute:
$ bundle
Copy migrations
$ bin/rails workflow_core:install:migrations
Then do migrate
$ bin/rails db:migrate
Demo
Demo is also under development.
The dummy app integrates with Form Core and Script Core shows an Approving Manage System.
Features
Importing workflow definitions from a BPMN2 xml,
Because there isn't have a easy-to-use web-based flowchart designer, I implement a stupid BPMN2 importer, it have many restrictions:
- Only supports
Sequence
,Start event
,End event
,Parallel gateway
andExclusive gateway
- Using gateway to fork flows must have corresponding join (or merge) gateway
- Only read
name
property, other such ascondition expression
must configure on the dummy app
You can check _samples
folder, or you can try a BPMN2 designer (e.g Camunda modeler).
Defining form
You can defining a dynamic form for a workflow.
In transition's options, you can configure field's accessibility
Exclusive choice configuration supports Ruby expression
Exclusive choice is a special transition that needs to configure conditions that determine how to transit to a branch.
The condition is a Ruby expression, and running in a mRuby sandbox (powered by ScriptCore but it's also undone yet), and you can access form data through @input[:payload]
, for example, there is a field named approved
, we can check the field checked by @input[:payload]["approved"]
Run a workflow
That should make sense.
Usage
Clone the repository.
$ git clone https://github.com/rails-engine/workflow_core.git
Change directory
$ cd workflow_core
Run bundler
$ bundle install
Preparing database
$ bin/rails db:migrate
Start the Rails server
$ bin/rails s
Open your browser, and visit http://localhost:3000
Contributing
Bug report or pull request are welcome.
Make a pull request
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Please write unit test with your code if necessary.
License
The gem is available as open source under the terms of the MIT License.