2017 © Pedro Peláez
 

library nodalflow

A PHP Nodal WorkFlow

image

fab2s/nodalflow

A PHP Nodal WorkFlow

  • Thursday, May 31, 2018
  • by fab2s
  • Repository
  • 2 Watchers
  • 2 Stars
  • 2,472 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 17 % Grown

The README.md

NodalFlow

Documentation Status CI QA Total Downloads Monthly Downloads Latest Stable Version Code Climate Scrutinizer Code Quality PRs Welcome License, (*1)

NodalFlow is a generic Workflow that can execute chained tasks. It is designed around simple interfaces that specifies a flow composed of executable Nodes and Flows. Nodes can be executed or traversed. They accept a single parameter as argument and can be set to pass or not their result as an argument for the next node. Flows also accept one argument and may be set to pass their result to be used or not as an argument for their first Node., (*2)

+--------------------------+Flow Execution+----------------------------->

+-----------------+        +------------------+         +---------------+
|   scalar node   +--------> trarersable node +--------->   next node   +-------->...
+-----------------+        +------------------+         +---------------+
                                              |
                                              |         +---------------+
                                              +--------->   next node   +-------->...
                                              |         +---------------+
                                              |
                                              |         +---------------+
                                              +--------->   next node   +-------->...
                                              |         +---------------+
                                              |
                                              +--------->...

Nodes are linked together by the fact they return a value or not. When a node is returning a value (by declaration), it will be used as argument to the next node (but not necessarily used by it). When it doesn't, the current parameter (if any) will be used as argument by the next node, and so on until one node returns a result intended to be used as argument to the next node., (*3)

+--------+ Result 1 +--------+ Result 3
| Node 1 +----+-----> Node 3 +--------->...
+--------+    |     +--------+
              |
              |
         +----v---+
         | Node 2 |
         +--------+

In this flow, as node 2 (which may as well be a whole flow or branch) is not returning a value, it is executed "outside" of the main execution line., (*4)

In other words, NodalFlow implements a directed graph structure in the form of a tree composed of nodes that can be, but not always are, branches or leaves., (*5)

NodalFlow also goes beyond that by allowing any Flow or Node to send whatever parameter to any part of any Flow alive within the same PHP process. The feature shares similarities with the Generator's sendTo() method and makes it possible to turn Flows into executable networks of Nodes (and Flows)., (*6)

+-------------------------+-------+----------+
|               |-->      |       |          |
+-+Node1+->tNode|-->Node3+> bNode +-->NodeN+->
|FlowA       ^  |-->      |   |   |          |
+------------|----------------|--------------+
             |            |   v   |
             |            | Node1 |
             |            |   |   |
             |            |   v   |
             +---sendTo()-+ Node2 |
                          | +-+-+ |
                          | | | | |
                          | v v v |
                          | Node3 |
                          +---|--------------+
                          |   v   |          |
                          | bNode +-->Node1+->
                          |   |   |     |    |
                          +---|--------------+
                          |   |   |     |
                          +---v---+     |
                                        |
               +-------sendTo()---------+
               |
 +-------------|----------------+
 |             v                |
 +--Node1-->Node2-->NodeN--...+->
 |  FlowB                       |
 +------------------------------+

NodalFlow aims at organizing and simplifying data processing workflow's where arbitrary amount of data may come from various generators, pass through several data processors and / or end up in various places and formats. But it can as well be the foundation to organizing pretty much any sequence of tasks (NodalFlow could easily become Turing complete after all). It makes it possible to dynamically configure and execute complex scenario in an organized and repeatable manner (NodalFlow is serializable). And even more important, to write Nodes that will be reusable in any other workflow you may think of., (*7)

NodalFlow enforces minimalistic requirements upon nodes. This means that in most cases, you should extend NodalFlow to implement the required constraints and grammar for your use case., (*8)

YaEtl is an example of a more specified workflow build upon NodalFlow., (*9)

NodalFlow shares conceptual similarities with Transducers (if you are interested, also have a look at Transducers PHP) as it allow basic interaction chaining, especially when dealing with ExecNodes, but the comparison diverges quickly., (*10)

NodalFlow Documentation

Documentation Status Documentation can be found at ReadTheDocs, (*11)

Installation

NodalFlow can be installed using composer:, (*12)

composer require "fab2s/nodalflow"

If you want to specifically install the php >=7.2.0 version, use:, (*13)

composer require "fab2s/nodalflow" ^2

If you want to specifically install the php 5.6/7.1 version, use:, (*14)

composer require "fab2s/nodalflow" ^1

Once done, you can start playing:, (*15)

$nodalFlow = new NodalFlow;
$result = $nodalFlow->addPayload(('SomeClass::someTraversableMethod', true, true))
    ->addPayload('intval', true)
    // or ->add(new CallableNode('intval', false))
    // or ->add(new PayloadNodeFactory('intval', false))
    ->addPayload(function($param) {
        return $param + 1;
    }, true)
    ->addPayload(function($param) {
        for($i = 1; $i < 1024; $i++) {
            yield $param + $i;
        }
    }, true, true)
    ->addPayload($anotherNodalFlow, false)
    // or ->add(new BranchNode($anotherNodalFlow, false))
    // or ->add(new PayloadNodeFactory($anotherNodalFlow, false))
    ->addPayload([$someObject, 'someMethod'], false)
    ->exec($wateverParam);

Requirements

NodalFlow is tested against php 7.2, 7.3 and 7.4 8.0, 8.1 and 8.2, (*16)

Contributing

Contributions are welcome, do not hesitate to open issues and submit pull requests., (*17)

License

NodalFlow is open-sourced software licensed under the MIT license., (*18)

The Versions

31/05 2018

dev-master

9999999-dev

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

31/03 2018

1.1.2

1.1.2.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

09/02 2018

1.1.1

1.1.1.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

31/01 2018

1.1.0

1.1.0.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

27/11 2017

dev-sendTo

dev-sendTo

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

01/10 2017

1.0.3

1.0.3.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

18/08 2017

1.0.2

1.0.2.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

27/07 2017

1.0.1

1.0.1.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

09/05 2017

v1.0.0

1.0.0.0

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

09/05 2017

v1.0.0-rc.2

1.0.0.0-RC2

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node

21/04 2017

v1.0.0-rc.1

1.0.0.0-RC1

A PHP Nodal WorkFlow

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Fabrice de Stefanis

php nodalflow workflow nodal node