fuzzy-logic / jflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jflow

why ANOTHER workflow solution?

I agree, but after spending hours evaluating just a small fraction of solutions I found two common themes:

  1. The space is dominated by over engineered GUI driven workflows for non developers
  2. Developers still actually have to do the tricky stuff and now the APIs are corrupted by the compromises of point 1
  3. Nothing has been designed from the ground up to help deal with devloper quality of life issues

WHat is JFLOW

In any software system, epsecially a microservices system, at some point you're going to have to orchestrate a bunch of calls, transform some data, and make some decisions as to what steps to perform next depending on the returned data.

This is the bread and butter of day to day coders in real life, it's not particularly glamourous, but it must be done. Bascially, JFlow is an if-this-then-that for the enterprise. All to often the code decends in a typical state of lazy anarchy (think mad max) rather than ordered civility (err, does that actually exist yet?), object models are generated, code is shared, modules are coupled, and develoeprs play whack a mole with side effects. You've now inadvertantly falled in to the complexity doamin.

This is where jflow was imaculately conceived from...

JFlow is a lightweight simple api to compose actions as easily decoupled steps in a wider logically branching workflow just for developers. There's no gui driven workflows, there's no non technical interface. It's programmed for programmers.

Example

Action<String, String> startStep = Action.sync("start step", i -> i);
        Action<String, String> nextStep = Action.sync("next step", i -> i);
        Action<String, String> emphasise = Action.sync("emphasise", i -> i + "!");
        Action<String, String> sayComeAgainAnother = Action.sync("rainy step", i -> i + " - rain, rain, go away!");
        Action<String, String> sayHello = Action.sync("hello step", i -> "Hello, I love " + i);
        Predicate<String> isRainy = Predicate.sync("rainy test", i -> i.contains("rainy"));
        Predicate<String> isWinter = Predicate.sync("winter test", i -> i.contains("winter"));
        Action<String, String> sayGoAway = Action.sync("go away step", i -> "Please go away, " + i);

        Flow<String, String> flow = Flow.of(startStep)
                .add(nextStep)
                .add(Flow.branch(isWinter,
                        Flow.of(sayGoAway),
                        Flow.of(sayHello)
                                .add(Flow.branch(isRainy,
                                        Flow.of(sayComeAgainAnother),
                                        Flow.of(emphasise)))));

        System.out.println(flow.describe());

        String result1 = flow.run("winter").get();
        assertEquals("Please go away, winter",  result1 );

        String result2 = flow.run("summer").get();
        assertEquals("Hello, I love summer!",  result2 );

        String result3 = flow.run("rainy summer").get();
        assertEquals("Hello, I love rainy summer - rain, rain, go away!",  result3);

About


Languages

Language:Java 100.0%