Class: Actions::Middleware::ProxyBatchTriggering
- Inherits:
-
Dynflow::Middleware
- Object
- Dynflow::Middleware
- Actions::Middleware::ProxyBatchTriggering
- Defined in:
- app/lib/actions/middleware/proxy_batch_triggering.rb
Instance Method Summary collapse
- #remote_tasks ⇒ Object
-
#run(event = nil) ⇒ Object
If the event could result into sub tasks being planned, check if there are any RemoteTasks to trigger after the event is processed.
- #trigger_remote_tasks ⇒ Object
Instance Method Details
#remote_tasks ⇒ Object
[View source]
25 26 27 |
# File 'app/lib/actions/middleware/proxy_batch_triggering.rb', line 25 def remote_tasks action.task.remote_sub_tasks end |
#run(event = nil) ⇒ Object
If the event could result into sub tasks being planned, check if there are any RemoteTasks to trigger after the event is processed
The ProxyAction needs to be planned with ‘:use_batch_triggering => true` to activate the feature
8 9 10 11 12 |
# File 'app/lib/actions/middleware/proxy_batch_triggering.rb', line 8 def run(event = nil) pass event ensure trigger_remote_tasks if event.nil? || event.is_a?(Dynflow::Action::WithBulkSubPlans::PlanNextBatch) end |
#trigger_remote_tasks ⇒ Object
[View source]
14 15 16 17 18 19 20 21 22 23 |
# File 'app/lib/actions/middleware/proxy_batch_triggering.rb', line 14 def trigger_remote_tasks # Find the tasks in batches, order them by proxy_url so we get all tasks # to a certain proxy "close to each other" remote_tasks.pending.order(:proxy_url, :id).find_in_batches(:batch_size => batch_size) do |batch| # Group the tasks by operation, in theory there should be only one operation batch.group_by(&:operation).each do |operation, group| ForemanTasks::RemoteTask.batch_trigger(operation, group) end end end |