maintenance_tasks 2.15.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/jobs/concerns/maintenance_tasks/task_job_concern.rb +1 -1
- data/app/models/concerns/maintenance_tasks/run_concern.rb +29 -28
- data/app/models/maintenance_tasks/null_collection_builder.rb +1 -1
- data/app/models/maintenance_tasks/task_data_index.rb +10 -5
- data/lib/maintenance_tasks.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5504bbe129c76305465fce6a4cb5310feb2c0fd0fe2516a1896f60615825e183
|
|
4
|
+
data.tar.gz: 3a1cbf3fc0eef572d7b8e1451331e33618e8a1b888cde2cf8d39e0c6363b6a6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e59152a9747d77adf137470e375ad68d06b07b410c73879f14f3d5cb418f26abe831102b32f6e5868f8824a2999f43ca4fdd0ad6a7eb84e85fbdb9d4e1530db7
|
|
7
|
+
data.tar.gz: 07bda592ce0919dc2487eb1df8ea585addbdaab8a8bca20c9f67332e3b5f8f04b6b2a66231de112e919a646352453a707f9909d857d5d57c7c58f9c4d46c8337
|
|
@@ -8,35 +8,36 @@ module MaintenanceTasks
|
|
|
8
8
|
module RunConcern
|
|
9
9
|
extend ActiveSupport::Concern
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
11
|
+
STATUSES = [
|
|
12
|
+
:enqueued, # The task has been enqueued by the user.
|
|
13
|
+
:running, # The task is being performed by a job worker.
|
|
14
|
+
:succeeded, # The task finished without error.
|
|
15
|
+
:cancelling, # The task has been told to cancel but is finishing work.
|
|
16
|
+
:cancelled, # The user explicitly halted the task's execution.
|
|
17
|
+
:interrupted, # The task was interrupted by the job infrastructure.
|
|
18
|
+
:pausing, # The task has been told to pause but is finishing work.
|
|
19
|
+
:paused, # The task was paused in the middle of the run by the user.
|
|
20
|
+
:errored, # The task code produced an unhandled exception.
|
|
21
|
+
].freeze
|
|
22
|
+
|
|
23
|
+
ACTIVE_STATUSES = [
|
|
24
|
+
:enqueued,
|
|
25
|
+
:running,
|
|
26
|
+
:paused,
|
|
27
|
+
:pausing,
|
|
28
|
+
:cancelling,
|
|
29
|
+
:interrupted,
|
|
30
|
+
].freeze
|
|
31
|
+
|
|
32
|
+
STOPPING_STATUSES = [
|
|
33
|
+
:pausing,
|
|
34
|
+
:cancelling,
|
|
35
|
+
:cancelled,
|
|
36
|
+
].freeze
|
|
37
|
+
|
|
38
|
+
COMPLETED_STATUSES = [:succeeded, :errored, :cancelled].freeze
|
|
39
39
|
|
|
40
|
+
included do
|
|
40
41
|
enum :status, STATUSES.to_h { |status| [status, status.to_s] }
|
|
41
42
|
|
|
42
43
|
after_save :instrument_status_change
|
|
@@ -15,7 +15,9 @@ module MaintenanceTasks
|
|
|
15
15
|
# Returns a list of sorted Task Data objects that represent the
|
|
16
16
|
# available Tasks.
|
|
17
17
|
#
|
|
18
|
-
# Tasks are sorted by category, and within a category, by
|
|
18
|
+
# Tasks are sorted by category, and within a category, by the most
|
|
19
|
+
# recent Run's creation time (most recent first). New tasks with no
|
|
20
|
+
# Run history fall back to alphabetical order by name.
|
|
19
21
|
# Determining a Task's category requires their latest Run records.
|
|
20
22
|
# Two queries are done to get the currently active and completed Run
|
|
21
23
|
# records, and Task Data instances are initialized with these related run
|
|
@@ -41,10 +43,13 @@ module MaintenanceTasks
|
|
|
41
43
|
tasks << TaskDataIndex.new(task_name, last_run)
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
# multiple active
|
|
47
|
-
|
|
46
|
+
# Most-recent-first by Run creation time; new tasks (no Run) sort
|
|
47
|
+
# together by name. Status is a final tiebreaker to keep ordering
|
|
48
|
+
# stable across database adapters when a Task has multiple active
|
|
49
|
+
# Runs created at the same time.
|
|
50
|
+
tasks.sort_by! do |task|
|
|
51
|
+
[-(task.related_run&.created_at&.to_f || 0), task.name, task.status]
|
|
52
|
+
end
|
|
48
53
|
end
|
|
49
54
|
end
|
|
50
55
|
|
data/lib/maintenance_tasks.rb
CHANGED
|
@@ -145,6 +145,11 @@ module MaintenanceTasks
|
|
|
145
145
|
# @return [ActiveSupport::Duration, false] time interval after which a task is considered stale.
|
|
146
146
|
mattr_accessor :task_staleness_threshold, default: 30.days
|
|
147
147
|
|
|
148
|
+
NO_COUNT_DEFINED = Object.new
|
|
149
|
+
NO_COUNT_DEFINED.define_singleton_method(:inspect) { "MaintenanceTasks::NO_COUNT_DEFINED" }
|
|
150
|
+
NO_COUNT_DEFINED.freeze
|
|
151
|
+
private_constant :NO_COUNT_DEFINED
|
|
152
|
+
|
|
148
153
|
class << self
|
|
149
154
|
DEPRECATION_MESSAGE = "MaintenanceTasks.error_handler is deprecated and will be removed in the 3.0 release. " \
|
|
150
155
|
"Instead, reports will be sent to the Rails error reporter. Do not set a handler and subscribe " \
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: maintenance_tasks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.16.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shopify Engineering
|
|
@@ -184,7 +184,7 @@ homepage: https://github.com/Shopify/maintenance_tasks
|
|
|
184
184
|
licenses:
|
|
185
185
|
- MIT
|
|
186
186
|
metadata:
|
|
187
|
-
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v2.
|
|
187
|
+
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v2.16.0
|
|
188
188
|
allowed_push_host: https://rubygems.org
|
|
189
189
|
rdoc_options: []
|
|
190
190
|
require_paths:
|
|
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
200
200
|
- !ruby/object:Gem::Version
|
|
201
201
|
version: '0'
|
|
202
202
|
requirements: []
|
|
203
|
-
rubygems_version: 4.0.
|
|
203
|
+
rubygems_version: 4.0.11
|
|
204
204
|
specification_version: 4
|
|
205
205
|
summary: A Rails engine for queuing and managing maintenance tasks
|
|
206
206
|
test_files: []
|