Class: Simplekiq::Orchestration
- Inherits:
-
Object
- Object
- Simplekiq::Orchestration
- Defined in:
- lib/simplekiq/orchestration.rb
Instance Attribute Summary collapse
-
#parallel_workflow ⇒ Object
Returns the value of attribute parallel_workflow.
-
#serial_workflow ⇒ Object
Returns the value of attribute serial_workflow.
Instance Method Summary collapse
- #in_parallel ⇒ Object
-
#initialize ⇒ Orchestration
constructor
A new instance of Orchestration.
- #run(*step) ⇒ Object
- #serialized_workflow ⇒ Object
Constructor Details
#initialize ⇒ Orchestration
Returns a new instance of Orchestration.
6 7 8 |
# File 'lib/simplekiq/orchestration.rb', line 6 def initialize @serial_workflow = [] end |
Instance Attribute Details
#parallel_workflow ⇒ Object
Returns the value of attribute parallel_workflow.
5 6 7 |
# File 'lib/simplekiq/orchestration.rb', line 5 def parallel_workflow @parallel_workflow end |
#serial_workflow ⇒ Object
Returns the value of attribute serial_workflow.
5 6 7 |
# File 'lib/simplekiq/orchestration.rb', line 5 def serial_workflow @serial_workflow end |
Instance Method Details
#in_parallel ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/simplekiq/orchestration.rb', line 15 def in_parallel @parallel_workflow = [] yield serial_workflow << @parallel_workflow if @parallel_workflow.any? ensure @parallel_workflow = nil serial_workflow end |
#run(*step) ⇒ Object
10 11 12 13 |
# File 'lib/simplekiq/orchestration.rb', line 10 def run(*step) workflow = parallel_workflow || serial_workflow workflow << step end |
#serialized_workflow ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/simplekiq/orchestration.rb', line 24 def serialized_workflow @serialized_workflow ||= serial_workflow.map do |step| case step[0] when Array step.map do |(job, *args)| {"klass" => job.name, "args" => args} end when Class job, *args = step {"klass" => job.name, "args" => args} end end end |