mission_control-jobs 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/stylesheets/mission_control/jobs/jobs.css +1 -1
- data/app/controllers/mission_control/jobs/discards_controller.rb +1 -1
- data/app/controllers/mission_control/jobs/dispatches_controller.rb +9 -4
- data/app/controllers/mission_control/jobs/recurring_tasks_controller.rb +9 -1
- data/app/helpers/mission_control/jobs/jobs_helper.rb +1 -1
- data/app/models/mission_control/jobs/recurring_task.rb +4 -0
- data/app/views/mission_control/jobs/jobs/_general_information.html.erb +11 -0
- data/app/views/mission_control/jobs/jobs/blocked/_actions.html.erb +1 -1
- data/app/views/mission_control/jobs/jobs/blocked/_job.html.erb +3 -2
- data/app/views/mission_control/jobs/jobs/scheduled/_actions.html.erb +1 -0
- data/app/views/mission_control/jobs/recurring_tasks/_actions.html.erb +3 -0
- data/app/views/mission_control/jobs/recurring_tasks/_recurring_task.html.erb +3 -0
- data/app/views/mission_control/jobs/recurring_tasks/_title.html.erb +3 -0
- data/app/views/mission_control/jobs/recurring_tasks/index.html.erb +3 -2
- data/config/routes.rb +1 -1
- data/lib/active_job/executing.rb +1 -1
- data/lib/active_job/jobs_relation.rb +5 -0
- data/lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb +6 -0
- data/lib/active_job/queue_adapters/solid_queue_ext.rb +7 -3
- data/lib/mission_control/jobs/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cae6550d727f9f26c6b5c0f1259a03c7a3f802abe8eb025973fab559b8a8f73
|
4
|
+
data.tar.gz: 98a0bea82a4f3b9c3a3d338719f419508eef9ae05dbfc356314f142d053a4d11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 223fb6d226ef1511e88cac89f0b1176e5db6bd01899b49279012d1ed94e607c28491f4ec770c96848291d84748e6f2b3956812ee0a4f25a3b7a814557f3de259
|
7
|
+
data.tar.gz: 52e763ce4e3b3bb7d59881d284f1a136474b46b3cffba722db96f333e63538e7647f638fe5b67c427e5fb6bbdf96452f0dc7b216e04300ffd690d8197302161b
|
data/README.md
CHANGED
@@ -66,7 +66,7 @@ This library extends Active Job with a querying interface and the following sett
|
|
66
66
|
## Adapter Specifics
|
67
67
|
|
68
68
|
- **Resque**: Queue pausing is supported only if you have `resque-pause` installed in your project
|
69
|
-
- **Solid Queue**: Requires version >= 0.
|
69
|
+
- **Solid Queue**: Requires version >= 1.0.1.
|
70
70
|
|
71
71
|
## Advanced configuration
|
72
72
|
|
@@ -3,11 +3,16 @@ class MissionControl::Jobs::DispatchesController < MissionControl::Jobs::Applica
|
|
3
3
|
|
4
4
|
def create
|
5
5
|
@job.dispatch
|
6
|
-
redirect_to
|
6
|
+
redirect_to redirect_location, notice: "Dispatched job with id #{@job.job_id}"
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def jobs_relation
|
11
|
+
ActiveJob.jobs
|
12
|
+
end
|
13
|
+
|
14
|
+
def redirect_location
|
15
|
+
status = @job.status.presence_in(supported_job_statuses) || :blocked
|
16
|
+
application_jobs_url(@application, status)
|
17
|
+
end
|
13
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class MissionControl::Jobs::RecurringTasksController < MissionControl::Jobs::ApplicationController
|
2
2
|
before_action :ensure_supported_recurring_tasks
|
3
|
-
before_action :set_recurring_task, only: :show
|
3
|
+
before_action :set_recurring_task, only: [ :show, :update ]
|
4
4
|
|
5
5
|
def index
|
6
6
|
@recurring_tasks = MissionControl::Jobs::Current.server.recurring_tasks
|
@@ -10,6 +10,14 @@ class MissionControl::Jobs::RecurringTasksController < MissionControl::Jobs::App
|
|
10
10
|
@jobs_page = MissionControl::Jobs::Page.new(@recurring_task.jobs, page: params[:page].to_i)
|
11
11
|
end
|
12
12
|
|
13
|
+
def update
|
14
|
+
if (job = @recurring_task.enqueue) && job.successfully_enqueued?
|
15
|
+
redirect_to application_job_path(@application, job.job_id), notice: "Enqueued recurring task #{@recurring_task.id}"
|
16
|
+
else
|
17
|
+
redirect_to application_recurring_task_path(@application, @recurring_task), alert: "Something went wrong enqueuing this recurring task"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
private
|
14
22
|
def ensure_supported_recurring_tasks
|
15
23
|
unless recurring_tasks_supported?
|
@@ -26,7 +26,7 @@ module MissionControl::Jobs::JobsHelper
|
|
26
26
|
def attribute_names_for_job_status(status)
|
27
27
|
case status.to_s
|
28
28
|
when "failed" then [ "Error", "" ]
|
29
|
-
when "blocked" then [ "Queue", "Blocked by", "
|
29
|
+
when "blocked" then [ "Queue", "Blocked by", "" ]
|
30
30
|
when "finished" then [ "Queue", "Finished" ]
|
31
31
|
when "scheduled" then [ "Queue", "Scheduled", "" ]
|
32
32
|
when "in_progress" then [ "Queue", "Run by", "Running since" ]
|
@@ -12,6 +12,10 @@ class MissionControl::Jobs::RecurringTask
|
|
12
12
|
ActiveJob::JobsRelation.new(queue_adapter: queue_adapter).where(recurring_task_id: id)
|
13
13
|
end
|
14
14
|
|
15
|
+
def enqueue
|
16
|
+
queue_adapter.enqueue_recurring_task(id)
|
17
|
+
end
|
18
|
+
|
15
19
|
private
|
16
20
|
attr_reader :queue_adapter
|
17
21
|
end
|
@@ -26,6 +26,17 @@
|
|
26
26
|
<%= formatted_time(job.enqueued_at.to_datetime) %>
|
27
27
|
</td>
|
28
28
|
</tr>
|
29
|
+
<% if job.scheduled? %>
|
30
|
+
<tr>
|
31
|
+
<th>Scheduled</th>
|
32
|
+
<td>
|
33
|
+
<%= formatted_time(job.scheduled_at) %>
|
34
|
+
<% if job_delayed?(job) %>
|
35
|
+
<div class="is-danger tag ml-4">delayed</div>
|
36
|
+
<% end %>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
<% end %>
|
29
40
|
<% if job.failed? %>
|
30
41
|
<tr>
|
31
42
|
<th>Failed</th>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div class="buttons is-right">
|
2
|
-
<%= button_to "
|
2
|
+
<%= button_to "Run now", application_job_dispatch_path(@application, job.job_id), class: "button is-warning is-light mr-0" %>
|
3
3
|
</div>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<td><%= link_to job.queue_name, application_queue_path(@application, job.queue) %></td>
|
2
|
-
<td><div class="is-family-monospace is-size-7"><%= job.blocked_by %></div
|
3
|
-
<
|
2
|
+
<td><div class="is-family-monospace is-size-7"><%= job.blocked_by %></div>
|
3
|
+
<div class="has-text-grey is-size-7">Until <%= formatted_time(job.blocked_until) %></div>
|
4
|
+
</td>
|
4
5
|
<td class="pr-0">
|
5
6
|
<%= render "mission_control/jobs/jobs/blocked/actions", job: job %>
|
6
7
|
</td>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<div class="buttons is-right">
|
2
|
+
<%= button_to "Run now", application_job_dispatch_path(@application, job.job_id), class: "button is-warning is-light mr-0" %>
|
2
3
|
<%= button_to "Discard", application_job_discard_path(@application, job.job_id), class: "button is-danger is-light mr-0",
|
3
4
|
form: { data: { turbo_confirm: "This will delete the job and can't be undone. Are you sure?" } } %>
|
4
5
|
</div>
|
@@ -16,4 +16,7 @@
|
|
16
16
|
<td> <%= recurring_task.schedule %> </td>
|
17
17
|
<td><div class="has-text-grey"><%= recurring_task.last_enqueued_at ? formatted_time(recurring_task.last_enqueued_at) : "Never" %></div></td>
|
18
18
|
<td class="next_time"><div class="has-text-grey"><%= formatted_time(recurring_task.next_time) %></div></td>
|
19
|
+
<td class="pr-0">
|
20
|
+
<%= render "mission_control/jobs/recurring_tasks/actions", recurring_task: recurring_task %>
|
21
|
+
</td>
|
19
22
|
</tr>
|
data/config/routes.rb
CHANGED
@@ -20,7 +20,7 @@ MissionControl::Jobs::Engine.routes.draw do
|
|
20
20
|
resources :jobs, only: :index, path: ":status/jobs"
|
21
21
|
|
22
22
|
resources :workers, only: [ :index, :show ]
|
23
|
-
resources :recurring_tasks, only: [ :index, :show ]
|
23
|
+
resources :recurring_tasks, only: [ :index, :show, :update ]
|
24
24
|
end
|
25
25
|
|
26
26
|
# Allow referencing urls without providing an application_id. It will default to the first one.
|
data/lib/active_job/executing.rb
CHANGED
@@ -154,7 +154,12 @@ class ActiveJob::JobsRelation
|
|
154
154
|
end
|
155
155
|
|
156
156
|
# Dispatch the provided job.
|
157
|
+
#
|
158
|
+
# This operation is only valid for blocked or scheduled jobs. It will
|
159
|
+
# raise an error +ActiveJob::Errors::InvalidOperation+ otherwise.
|
157
160
|
def dispatch_job(job)
|
161
|
+
raise ActiveJob::Errors::InvalidOperation, "This operation can only be performed on blocked or scheduled jobs, but this job is #{job.status}" unless job.blocked? || job.scheduled?
|
162
|
+
|
158
163
|
queue_adapter.dispatch_job(job, self)
|
159
164
|
end
|
160
165
|
|
@@ -20,6 +20,12 @@ module ActiveJob::QueueAdapters::SolidQueueExt::RecurringTasks
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def enqueue_recurring_task(task_id)
|
24
|
+
if task = SolidQueue::RecurringTask.find_by(key: task_id)
|
25
|
+
task.enqueue(at: Time.now)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
23
29
|
private
|
24
30
|
def recurring_task_attributes_from_solid_queue_recurring_task(task)
|
25
31
|
{
|
@@ -123,9 +123,13 @@ module ActiveJob::QueueAdapters::SolidQueueExt
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def dispatch_immediately(job)
|
126
|
-
|
127
|
-
|
128
|
-
|
126
|
+
if job.blocked?
|
127
|
+
SolidQueue::Job.transaction do
|
128
|
+
job.dispatch_bypassing_concurrency_limits
|
129
|
+
job.blocked_execution.destroy!
|
130
|
+
end
|
131
|
+
else
|
132
|
+
job.scheduled_execution.update!(scheduled_at: Time.now)
|
129
133
|
end
|
130
134
|
end
|
131
135
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mission_control-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 1.0.1
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: 1.0.1
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: selenium-webdriver
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -425,6 +425,7 @@ files:
|
|
425
425
|
- app/views/mission_control/jobs/queues/_queue_title.html.erb
|
426
426
|
- app/views/mission_control/jobs/queues/index.html.erb
|
427
427
|
- app/views/mission_control/jobs/queues/show.html.erb
|
428
|
+
- app/views/mission_control/jobs/recurring_tasks/_actions.html.erb
|
428
429
|
- app/views/mission_control/jobs/recurring_tasks/_general_information.html.erb
|
429
430
|
- app/views/mission_control/jobs/recurring_tasks/_recurring_task.html.erb
|
430
431
|
- app/views/mission_control/jobs/recurring_tasks/_title.html.erb
|