Class: MARS::Workflows::Parallel
- Defined in:
- lib/mars/workflows/parallel.rb
Instance Attribute Summary
Attributes inherited from Runnable
Instance Method Summary collapse
-
#initialize(name, steps:, aggregator: nil, **kwargs) ⇒ Parallel
constructor
A new instance of Parallel.
- #run(context) ⇒ Object
Methods inherited from Runnable
Methods included from Hooks
included, #run_after_hooks, #run_before_hooks
Constructor Details
#initialize(name, steps:, aggregator: nil, **kwargs) ⇒ Parallel
Returns a new instance of Parallel.
6 7 8 9 10 11 |
# File 'lib/mars/workflows/parallel.rb', line 6 def initialize(name, steps:, aggregator: nil, **kwargs) super(name: name, **kwargs) @steps = steps @aggregator = aggregator || Aggregator.new("#{name} Aggregator") end |
Instance Method Details
#run(context) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/mars/workflows/parallel.rb', line 13 def run(context) context = ensure_context(context) child_contexts = [] results = execute_steps(context, child_contexts) context.merge(child_contexts) context.current_input = results aggregator.run(context) end |