A scala Workflow - Engine and DSL Subscribe

Consolidated older post - originally posted in Sep, 2010

I've been meaning to write a workflow engine/language for sometime and recently, some scala DSL discussions gave me the motive. I know there's tons of workflow products but none complete and to my liking.

I started in May, worked on it a few hours here and there, for a few weeks and then didn't find the time to complete, so this is still work-in-progress, a snail-pace kind of progress. Since the basic ideas are in place, I figured it's worth advertising, maybe attract some converts and start a religion!

The project is over at http://github.com/razie/gremlins

Manifesto

This is not really meant to be a full-blown BPEL or BPMN environment, but a tiny, extensible but sweet and easily embedable workflow framework, that one can use to automate things inside the house, study the behavior of certain grains of sand or write more readable and interactive complex algorithms.

There's more details in the vision page http://github.com/razie/gremlins/blob/master/Gremlins.markdown, but these are the basic principles behind this project:

  • A workflow is just a graph of activities through which an engine carves one or more concurrent paths
  • The workflow has many views: text DSL, scala DSL, graphical etc
  • There's only a small set of base/core activities.
  • Complex activities are built as patterns from lower-level activities
  • There's a gremlin distribution API, uniformly implemented by all engines and components in a cloud
  • Branches (sections of the graph) of a bigger workflow could run on multiple devices/agents
  • Distributed branches, wherever they run, can be related back and managed as a unit

Since these are all plain graphs, certain graph transformations should be able to turn a state machine into a workflow or a PI into a BPEL or whatever you want into something you'd like...

So far, 1-4 are prototyped and 5-8 are "in progress": a basic concurrent engine and DSL are in place... I didn't get to the distributed part yet.

Examples

The magic of a scala DSL makes this simple CSP style workflow possible:

v(c) (c ? P | c ! Q)

Doesn't look like scala code? Well... it is and it's proof of why scala is scalable! Of course, this comes with one of those "don't do this at home" annotations.

More complex examples include a scala version:

import razie.wfs._
val workflow = wfs strict seq {    
  par {      
    seq {      
      println ("he he - definition time")
      later { _ + "runtime-a" }
      }
    later { _ + "runtime-b" }
    }
    sort[String] (_ < _)
    matchLater { case x : List[String] => x mkString "," }  
  }

or a text version:

  def wpar6 = """
par {
  seq {
     inc
     log($0)
     }
  seq {
    inc
    log($0)
    }
  }"""

If you'd like to stay up-to-date, follow me on http://twitter.com/coolscala - among boring tweets of mine or interesting re-tweets of others, you may find some updates on my projects.

Enjoy!

By: Razie | 2014-09-27 .. 2016-05-16 | Tags: post , scala , dsl , workflow , programming |


See more in: Cool Scala Subscribe

Viewed 1217 times ( | Print ) this page.


This content is Copyrighted, all rights reserved.

You need to log in to post a comment!