Class: ChronoForge::Dashboard::ActionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/chrono_forge/dashboard/actions_controller.rb

Constant Summary collapse

RETRYABLE_STATES =

Both failed and stalled workflows are retryable, so bulk retry covers both (matching the per-workflow Retry, which uses ‘retryable?`).

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

Instance Method Summary collapse

Instance Method Details

#bulk_retryObject



32
33
34
35
36
37
38
39
# File 'app/controllers/chrono_forge/dashboard/actions_controller.rb', line 32

def bulk_retry
  n = 0
  ChronoForge::Workflow.where(state: RETRYABLE_STATES).find_each do |wf|
    wf.retry_later
    n += 1
  end
  redirect_to workflows_path, notice: "Re-enqueued #{n} workflow(s)."
end

#bulk_retry_branchObject

Retry every blocked (failed/stalled) child of one branch.



42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/chrono_forge/dashboard/actions_controller.rb', line 42

def bulk_retry_branch
  parent = ChronoForge::Workflow.find(params[:workflow_id])
  branch_log = parent.execution_logs.find(params[:id])
  n = 0
  branch_log.spawned_workflows.where(state: RETRYABLE_STATES).find_each do |wf|
    wf.retry_later
    n += 1
  end
  redirect_to workflow_branch_path(parent, branch_log), notice: "Re-enqueued #{n} child workflow(s)."
end

#resumeObject

Re-enqueue an idle (parked) workflow so the executor picks it up again. This is the recovery for a dropped poll/wake — a wait_until or merge whose poller job was lost, or a continue_if whose event has since arrived: the replay re-checks the condition and re-arms the poll if still unmet.



22
23
24
25
26
# File 'app/controllers/chrono_forge/dashboard/actions_controller.rb', line 22

def resume
  return redirect_to(workflow_path(workflow), alert: "Only idle workflows can be resumed.") unless workflow.idle?
  workflow.job_klass.perform_later(workflow.key)
  redirect_to workflow_path(workflow), notice: "Re-enqueued #{workflow.key}."
end

#retryObject



8
9
10
11
# File 'app/controllers/chrono_forge/dashboard/actions_controller.rb', line 8

def retry
  workflow.retry_later
  redirect_to workflow_path(workflow), notice: "Re-enqueued #{workflow.key}."
end

#unlockObject



13
14
15
16
# File 'app/controllers/chrono_forge/dashboard/actions_controller.rb', line 13

def unlock
  workflow.update!(locked_at: nil, locked_by: nil, state: :idle)
  redirect_to workflow_path(workflow), notice: "Unlocked #{workflow.key}."
end