Skip to content

Commit

Permalink
Pausing and resuming queues
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemanrubia committed Aug 5, 2022
1 parent 79c9f69 commit dd8a6ae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
18 changes: 18 additions & 0 deletions app/controllers/mission_control/jobs/queues/status_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class MissionControl::Jobs::Queues::StatusController < ApplicationController
before_action :set_queue

def pause
@queue.pause
redirect_to queues_url
end

def resume
@queue.resume
redirect_to queues_url
end

private
def set_queue
@queue = ActiveJob::Base.queue(params[:queue_id])
end
end
8 changes: 8 additions & 0 deletions app/views/mission_control/jobs/queues/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
<tr>
<th>Queue</th>
<th>Pending jobs</th>
<th>Actions</th>
</tr>
</thead>

<% @queues.each do |queue| %>
<tr>
<td> <%= queue.name %> </td>
<td> <%= queue.size %> </td>
<td>
<% if queue.active? %>
<%= button_to "Pause", pause_queue_status_path(queue.name), method: :put, class: "button is-warning" %>
<% else %>
<%= button_to "Resume", resume_queue_status_path(queue.name), method: :put, class: "button is-success" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
Expand Down
8 changes: 7 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
MissionControl::Jobs::Engine.routes.draw do
resources :queues
resources :queues do
scope module: :queues do
resource :status, controller: "status", only: [] do
put "pause", "resume", on: :member
end
end
end

root to: "queues#index"
end
Binary file added speedtest
Binary file not shown.

0 comments on commit dd8a6ae

Please sign in to comment.