Giter VIP home page Giter VIP logo

nitram509 / lib-bpmn-engine Goto Github PK

View Code? Open in Web Editor NEW
229.0 19.0 55.0 2.37 MB

A BPMN engine, meant to be embedded in Go applications with minimal hurdles, and a pleasant developer experience using it. This approach can increase transparency for non-developers.

Home Page: https://nitram509.github.io/lib-bpmn-engine/

License: MIT License

Go 100.00%
golang go bpmn bpmn2 bpmn-engine hacktoberfest workflow workflow-engine workflows workflow-engine-bpmn

lib-bpmn-engine's Introduction

lib-bpmn-engine

Build status

go test status codecov Documentation Status Go Report Card

Project status

  • still "beta" status - with the upcoming 0.3.0-final release, the beta status will end
  • not yet recommended to use in production
  • breaking API changes expected
  • contributors welcome

Documentation

Full documentation with examples:
https://nitram509.github.io/lib-bpmn-engine/

GoDoc:
https://pkg.go.dev/github.com/nitram509/lib-bpmn-engine/pkg/bpmn_engine

There's an experimental online playground https://nitram509.github.io/lib-bpmn-engine-js/ available, which leverages the great power of cross-compiling to WASM.

Requirements

Go v1.19+

I'm supporting the latest and second-latest version of Go, similar to how Go itself handles releases.

BPMN Modelling

All these examples are build with Camunda Modeler Community Edition. I would like to send a big "thank you", to Camunda for providing such tool.

Implementation notes

IDs (process definition, process instance, job, events, etc.)

This engine does use an implementation of Twitter's Snowflake algorithm which combines some advantages, like it's time based and can be sorted, and it's collision free to a very large extend. So you can rely on larger IDs were generated later in time, and they will not collide with IDs, generated on e.g. other nodes of your application in a multi-node installation.

The IDs are structured like this ...

+-----------------------------------------------------------+
| 41 Bit Timestamp |  10 Bit NodeID  |   12 Bit Sequence ID |
+-----------------------------------------------------------+

The NodeID is generated out of a hash-function which reads all environment variables. As a result, this approach allows 4096 unique IDs per node and per millisecond.

Development of this library and contribution

For development hints and notes, please check DEVELOPMENT.md

For information on contribution, please check CONTRIBUTING.md

Community fun: stargazers over time

Stargazers over time

lib-bpmn-engine's People

Contributors

actions-user avatar averyyan avatar dependabot[bot] avatar godsboss avatar nitram509 avatar peterfromthehill avatar rhzs avatar ryzheboka avatar stoovon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lib-bpmn-engine's Issues

support for backwards

Do we have any plan to support backwards ?

Problem: Assume that we allow user to repay the order instead of creating a new order when user choose to refund before confirm-receipt, it can handle confirm-recepit event and go to send-bill again.
But it can't handle the next flow becasue of some event had already trigged. I can't clear or reset the processInfo either.

The order repay flow may sound weird, but it's common for me to desigin flows like that.

I'm trying to design a workflow that user can handle an event then supervisor recheck it.
If the event handled before has some wrong, the supervisor can turn the flow to previous flow again. so that the previous user can handle it again until the supervisor recheck pass.

At now, I can't archive this goal graceful without backwards support.
Do you have some suggestions?

image

support handlers being registered for (task definition) types

motivation

currently, task handlers only can be registered for single Ids, which means just one element.
it would be a great extension, to allow a single task handler to be used for multiple types.
This would also increase compatibility with Zeebe.

acceptance criteria

  • task handler can be defined for ID
  • task handler can be defined for Type (as in extension taskDefinition)
  • in case of overlapping task handler (id and type would match), the more specific one has precedence == ID first
  • in case of overlapping task handler (id and/or type would match), only the first matching one is executed
  • documentation describes details of how multiple task handlers are treated/executed

links

  • was inspired by #57

implement active fail/complete control for jobs

as in zeebe client, jobs workers should be able to signal done or fail

Note:

func ha(client worker.JobClient, job entities.Job) {
	client.NewCompleteJobCommand()
	client.NewFailJobCommand()
}

fix data house keeping / cleanup

motivation

Internal data structures (slices, maps, etc) do grow over time and occupy memory.
Hence, all objects shall be removed, once no more needed.

consider introducing different scope for variable mapping

motivation

To be compatible with other BPMN runtimes, we need to introduce different scopes for variable mapping which means input mapping should be defined in the local scope, while the output mapping may be merged into the parent scope.

Doc: https://docs.camunda.io/docs/components/concepts/variables/#inputoutput-variable-mappings

business background

image

Considering sending msg in different situations, the send_notice service task will face variable conflict or overwrite if input mapping does not define in local scope.

If we change and introduce a local scope for input mapping, it will help a lot.

add feature to export and import BPMN state, incl. resume capability

it would be awesome for use cases where long-running processes and are implemented in short living microservices,
if lib-bpmn-engine would be able to export and import+resume it's internal state.

  • must: the data must be represented as ASCII-save string, to allow maximum compatibility and avoid codepage/unicode issues
  • could: the data format should be human readable, e.g. JSON
  • optional: data compression
  • optional: base64 encoding
  • must: the feature must be agnostic to library upgrades and for example allowing schema changes (optional: split this into another feature)
    • e.g. version info in the serialized file
  • documentation is up to date

provide WASM artefacts for lib-bpmn-engine

motivation

lib-bpmn-engine is meant to be an embedded engine.
The architectural guidelines focus on core BPMN execution capability.
There is no support for databases or other external IO.
Also, due to Go's compact and powerful syntax, the code base is just a few hundred lines of code
and so very attractive to be transpiled into WASM.
This would enable a broud range of

This is an experiment as well, to learn if there's a need/demand for such a piece of technology.

Admitting, this is kind of an extra playground :)

acceptance criteria

  • the engine is available as wasm artifact (likely a .JS file)
  • Github actions are in place, to build wasm artifacts on every release automatically
  • npm package registry is considered/evaluated to be used as release hub -- vs. a Github one
  • an example implementation is available at the GH pages documentation
  • some marketing is made: e.g. is there some special site, listing "interesting" WASM projects? (like e.g. npm is the number one for JS based projects ... if there's some similar go-to place for WASM, this lib should be listed there)

support adding variables along with publishing messages

motivation

As documented, https://docs.camunda.io/docs/components/modeler/bpmn/message-events/
when publishing a message, variables shall be possible to be added

acceptance criteria

  • documentation exists & examples are updated
  • variables can be passed with message publishing
  • exciter: "variable mapping", as defined in Camunda's documentation works as well

hint: "exciter" means this is not required to complete/finish this issue, but would be really awesome, if present/included
all other criteria are mandatory

improve error handling while timer creation

motivation

internal errors should be categorized and bubble up to the application developer.

acceptance criteria

  • error "classes" shall be defined - e.g. "BpmnValidationError" (as shown in #36)
  • documentation shows how to filter/log/react on BPMN validation errors
  • errors in 'createNewTimer()' do bubble up so they can be tested with assertions
  • process instance status is set to not-active, but "FAILED"

fix colliding IDs by using Twitter's Snowflake algorithm

Issue: currently, IDs for instances etc are generated from system clock - which has not always full nano-seconds resolution and thus collides.
The 'TestLoadingTheSameProcessWithModificationWillCreateNewVersion'
does run well on Linux, but fails on Windows.

document how to use timers

  • provide example code to create background ticker/timer
  • explain architectural idea
  • optional: provide simple worker code in standard package?

timer event don't trigger properly

At now the timer is only checked while the engine is running.

If I want to check whether the timer was trigger, I need to write a cron job or a timer to run the engine.

It's awkward , I want a timer event but I still have to use another timer to check timer event.

Maybe the engine could do this work by using a gorontine ito check timers every seconds or some other periods?

support FEEL expression language (BPMN standard)

motivation

Implementing FEEL (Friendly Enough Expression Language; one part of the DMN specification)
would be a great step towards compatibility with other BPMN runtimes.
The current 'expr' language has known differences (see also #18).

The FEEL language is designed to write expressions for decision tables and literal expressions in a way that is easily understood by business professionals and developers.

Ideally, this FEEL implementation is not part of the engine, but rather an individual project.

Persist Paused Process

Hi,

I am interested to take a challenge persisting the Process to DB. What's the best approach that should I take?

  1. Persisting in JSON
  2. Persisting in Binary using Gob
  3. Others

Also mentioned in:

And what is the storage preferences?
I can do the persistence in Redis / SQLite for starter, later can be MySQL / Postgres, etc

Thank you.

implement expression language support

initially, I thought to implement FEEL (from DMN) as Camunda does - I still believe it's a good idea -
but in order to speed up delivery and focus on BPMN, I will use https://github.com/antonmedv/expr language.
This one seems to cover most of my use cases and might be compatible to FEEL to a great extent.

Acceptance Criteria

  • lib is included and works for conditions (exclusive gateways)
  • documentation exists, to show usage and outline differences/compatibility
  • exclusive gateways and defaults can be handled
  • #28

document user task handling: pause and continue

motivation

the documentation should make the difference between user tasks and services tasks explicit.
moreover, the difference as introduced in #49 must be documented

acceptance criteria

  • the difference between user task and service task is documented
  • the handling of user tasks is given by example (code)

support assignee and candidateGroups for user tasks

motivation

supporting assignee and candidateGroups enriches not only the integration option for lib-bpmn-engine users,
but also increases compatibility with Zeebe

acceptance criteria

  • task handler can be set to assignee or group
  • documentation is there describing the details

refactor publish events towards engine scope

motivation

being more compatible with BPMN standard

acceptance criteria

  • published messages are 'global' on the engine (not on the instance)
  • method is renamed
  • documentation is extended, minimum mentioned, that IDs of messages must be unique in order to match the right process
    • tbc. what's the matching order? first come first served?
    • tbc. how to deal with different versions of a process

buggy message catching event handling

Compared to Zeebe == the BPMN spec, these test events do not behave as expected...

  • completion state is not always correct
  • wrong path is chosen on event-based gateway

Screenshot 2022-08-31 at 11 29 27

Screenshot 2022-08-31 at 11 29 23

Screenshot 2022-08-31 at 11 29 19

Screenshot 2022-09-02 at 18 42 05

add timer event capabilities

add the feature of BPMN timer elements to be supported.
thus workflow instances could be paused, until a given timer event happens.

Consider to replace ActivatedJob struct to interface

Hi,

Passing heavy object passing during service task execution ActivatedJob is caught by Go Critic linter https://go-critic.com/overview.html#hugeParam-ref

This suggests performance will degrade over time. I don't have benchmark yet how degraded. Maybe if we have 10,000 service tasks in one flow, this will start to degrade.

Can we consider passing function interface or pointer? My suggestion is to change the existing struct copying with function interface passing. We can do better mocking as well when function interface is passed.

Rework engine-name to be optional

motivation

the name of the engine should be optional

hint: engine instances are supposed to have a name, to differentiate multiple instances - e.g. during logging.

acceptance criteria

  • the name for the bpmn engine is optional, means an engine can be created straight, without providing a name
  • a default name per engine is created, when no explicit name is provided

gopher art/logo for lib-bpmn-engine (similar like golang gopher)

motivation

It would be cool to have a Gopher like art/logo for this library,
to strengthen the community :)

  • a logo, similar like (google for images, with keyword: ) golang gopher
  • SVG preferred
  • PNG files in various common logo/thumbnail sizes would be cool to have
  • an additional banner would be awesome

implement event publisher (a.k.a. Zeebe exporter)

the engine is meant to be embedded.
that said, there's a need/appetite to bring transparency into the engine, by allowing users to have a "view" on their processes and states.

One of the initial ideas/goals of this project is to emit the same events, as the popular Camunda Cloud a.k.a. Zeebe BPMN Engine.
Zeebe uses a protobuf based exporter protocol.

The idea for this library is, to provide an optional module so that developers can opt-in to emit events like Zeebe does with the ultimate goal to use their Simple Monitor.

Acceptance Criteria

  • can send events to Hazelcast, so that Zeebe Simple Monitor will display them
  • basic support for Start, End, ServiceTask, and Flow events required
  • ability to configure Hazelcast client
  • documentation for setup and how to use

improve documentation for supported elements

motivation

the bullet items of supported elements is quite compact and not easy to digest for beginners.
so, the main idea is to improve documentation for beginners

acceptance criteria

  • pictures/symbols for each elements are shown
  • short element description is available
  • relevant caveats (compared to other engines) are described

allow multiple instances per workflow

by BPMN definition, a workflow can have multiple instances.
currently, that's not implemented but is required.

is considered a relatively small task, should be possible <4h

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.