Class Ruote::Exp::AddBranchesExpression
In: lib/ruote/exp/fe_add_branches.rb
Parent: FlowExpression

The ‘add_branches’/’add_branch’ expression can be used to add branches to a concurrent-iterator while it is running.

  concurrent_iterator :on => 'a, b, c' do
    sequence do
      participant :ref => 'worker_${v:i}'
      add_branches 'd, e', :if => '${v:/not_sufficient}'
    end
  end

In this example, if the process level variable ‘not_sufficient’ is set to true, workers d and e will be added to the iterated elements.

‘add_branches’ understand comma-separated list of values or direcltly array of values, like the concurrent_iterator does. The :sep or :separator attribute can be used for custom separators :

  add_branches 'd|e|f', :sep => '|'

:ref

By default, add_branches looks up the first parent expression that is concurrent_iterator. This is all well, but what when you have nested concurrent_iterator and want to hit the enclosing one from inside the enclosed one ? Or when you want to add branches from somewhere else in the process instance, outside of the concurrent_iterator ?

  concurrence do

    concurrent_iterator :on => 'a, b, c', :tag => 'main' do
      subprocess :ref => 'perform_work'
    end

    sequence do
      subprocess :ref => 'supervise_work'
      add_branches 'd, e', :ref => 'main', :if => '${f:more_cowbell}'
      rewind :if => '${f:more_cowbell}'
    end
  end

The add_branches expression refers to the ‘main’ concurrent_iterator via the :ref => ‘main’ attribute.

missing concurrent_iterator

If :ref points to nothing or add_branch has no :ref and is not placed inside of a concurrent_iterator, the expression will silently have no effect.

Methods

Included Modules

IteratorMixin

Public Instance methods

Protected Instance methods

[Validate]