Skip to content

Deflow algorithm

Gurmit Teotia edited this page Aug 21, 2023 · 27 revisions

Execution of workflow branches is powered by what I fondly called Dependency Flow (Deflow) algorithm. Deflow algorithm simplify the writing of complex workflows involving parallel execution of branches.

Deflow algorithm works as described below:

  1. Schedule the start-up items when workflow starts
  2. Schedule all children, given all of its parent branches are inactive, when a workflow item continue the execution
  3. Trigger the execution of all joining items when a workflow branch becomes inactive

Above implementation of Deflow algorithm will work very well for many complex scenario, however you can customise any of above step in the workflow. Let us understand it further using through an example:

     A          B
     |          |
     C          D
     |          |
     ````````````
          |
          E
          |
          F
          |
          G
  • In above workflow A and B are start-up activities which will be scheduled in parallel in when workflow is started
  • Activities C and D are scheduled when activities A and B are completed.
  • If activity C is completed before activity D (or other way round) then activity E will not be scheduled because its other parent branch B->D is still active. Later on when activity D is completed, then activity E is scheduled because all of its parent branches are inactive now.

Let us understand the point 3 for Deflow algorithm through examples. A workflow branch becomes inactive when:

  • All of its items (activities, timer...) are completed.
  • A workflow item (activity, timer...) is jumping down the branch after joint item. e.g. in above case if activity B or D jumps down after first join item (activity E) to either F or G then branch B->D will become inactive.
  • A workflow item is not scheduled because "When" API is evaluated to false. e.g. if D is not scheduled because its When condition is evaluated to be false, then it will try to trigger the scheduling of activity E.
  • A workflow item has paused the execution of branch without keeping it active. e.g. if activity D pause the execution on its completion then branch B->D will become inactive.
Clone this wiki locally