Class: ChronoForge::Dashboard::BulkRetryJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/chrono_forge/dashboard/bulk_retry_job.rb

Overview

Fans out per-workflow retries off the request thread. The "Retry blocked" buttons enqueue one of these instead of looping in the controller, so the HTTP request stays fast even when thousands of workflows are blocked.

Constant Summary collapse

RETRYABLE_STATES =

Both failed and stalled workflows are retryable (matching the per-workflow Retry, which uses retryable?).

%i[failed stalled].map { |s| ChronoForge::Workflow.states[s] }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.retryable(branch_log = nil) ⇒ Object

The blocked workflows a run would retry: all of them, or just one branch's spawned children. Exposed so the controller can report a count up front.



13
14
15
16
# File 'app/jobs/chrono_forge/dashboard/bulk_retry_job.rb', line 13

def self.retryable(branch_log = nil)
  base = branch_log ? branch_log.spawned_workflows : ChronoForge::Workflow.all
  base.where(state: RETRYABLE_STATES)
end

Instance Method Details

#perform(branch_log_id = nil) ⇒ Object



18
19
20
21
# File 'app/jobs/chrono_forge/dashboard/bulk_retry_job.rb', line 18

def perform(branch_log_id = nil)
  branch_log = branch_log_id && ChronoForge::ExecutionLog.find(branch_log_id)
  self.class.retryable(branch_log).find_each(&:retry_later)
end