Code Monkey home page Code Monkey logo

wfnet's Introduction

wfnet - Embedded work flow engine for Erlang applications

Erlang CI

Note: This project is the continuation of the entry for the Spawnfest 2023 competition: wfnet1.

wfnet provides a configuration based workflow enactment engine within an Erlang application.

About workflows

Here a workflow is an arrangement of tasks (activities) where each task is only activated when, depending on the task type, one or all of its predecessor(s) have terminated.

The concept, and implementation, of workflows here follows those described on the Workflow patterns web site, more specifically the basic control flow patterns.

Effectively, the workflow is a directed graph of tasks of one of the following types:

wftask: Within wfnet tasks are Erlang functions, either an {Mod, Fun, Args} triple, or a function expression.

  • when enabled, the function is called, and the result obtained on completion.
  • when terminated, its successor task is enabled.
  • A task can only have one predecessor and one successor.

The special tasks are internally defined pseudo-tasks as follows:

  • wfenter: this is the first task of the workflow, it has no predecessor. When enabled, it will intialise the workflow data and enable its successor.

  • wfexit: this is the last task of the workflow, it has no successors. When enabled, it will clean up and return the data from the workflow

  • wfands: this is an AND-split, aka parallel-split, it has a single predecessor, and one or more successors. When enabled, it will enable all its successors.

  • wfandj: This is an AND-join, aka synchronization. It will only be enabled when ALL of its predecessors have terminated. When enabled, it will enable its successor.

  • wfxors: This is an XOR-split, aka exclusive choice. When enabled, it will enable only one of its successors. The successor is chosen based on the termination result of its predecessor.

  • wfxorj: This is an XOR-join, aka simple merge. It has one or more predecessors, and one successor. It is enabled as soon as one of its predecessors terminates.

Build

$ rebar3 compile
$ rebar3 dialyzer

Running with the sample workflows

$ rebar3 shell
> wfnet:start().
> wfnet:load("Examples/sample1.dat").
> wfnet:run_wf().
> wfnet:stop().

The above can also be run with sample2.dat to see the function execution. See the Examples directory for some explanation.

The Command Line Interface

A CLI command (escript) is available. Use rebar3 to create the command:

$ rebar3 escriptize

It provides a number of subcommands, with new ones being added:

$ _build/default/bin/wfnet_cli -h
Version "0.1.0".
Usage: wfnet_cli [-h] [-v] [-l [<loglevel>]] command ...

  -h, --help      Print help.
  -v, --version   Print version.
  -l, --loglevel  Set log level. [default: notice]
  command         command to execute, e.g. graph, info ...

       graph  Generate GraphViz DOT file
        info  Print information about workflow FILE

Use info to get a summary of a workflow file:

$ _build/default/bin/wfnet_cli info Examples/sample1.wf
Workflow: "Examples/sample1.wf"
   Tasks: 13

Use graph to generate a GraphViz dot file, and view it:

$ _build/default/bin/wfnet_cli graph Examples/sample1.wf >sample1-graph.dot
$ xdot sample1-graph.dot

or

$ _build/default/bin/wfnet_cli graph Examples/sample1.wf | xdot -

wfnet's People

Contributors

fredyouhanaie avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.