que-scheduler 4.3.0 → 4.3.1
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 -0
- data/lib/que/scheduler/migrations.rb +6 -2
- data/lib/que/scheduler/scheduler_job.rb +10 -5
- data/lib/que/scheduler/to_enqueue.rb +5 -6
- data/lib/que/scheduler/version.rb +1 -1
- data/lib/que/scheduler/version_support.rb +33 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ede03b787b5856626a071b1bc95482444e85426749dbd3e71cd0df4cce2471
|
4
|
+
data.tar.gz: acb2b596d1eb686618e508b25480402686e46c631cfe193ae8c974e49b91090a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a61f0242dde1547c4df76f2626ccab9e4fe2f2046db698ff54699f0b19fe3233a1ba4a586781500a3f9f8519033de3f2ef68cf39f73ba1e7d31fcfb270d0b7e
|
7
|
+
data.tar.gz: 5e8636614bb56e1b38acd50f7b2afdfc2edf9860cc55898b98552537d3aaab543dff7a40396e6aae623fd70f2fe1618f1214faf6589a5c4fb5c2000c8bff7f2e
|
data/README.md
CHANGED
@@ -43,13 +43,17 @@ module Que
|
|
43
43
|
|
44
44
|
# This method is only intended for use in squashed migrations
|
45
45
|
def reenqueue_scheduler_if_missing
|
46
|
-
|
46
|
+
return unless Que::Scheduler::Db.count_schedulers.zero?
|
47
|
+
|
48
|
+
Que::Scheduler::VersionSupport.enqueue_a_job(Que::Scheduler::SchedulerJob)
|
47
49
|
end
|
48
50
|
|
49
51
|
private
|
50
52
|
|
51
53
|
def migrate_up(current, version)
|
52
|
-
|
54
|
+
if current.zero? # Version 1 does not use SQL
|
55
|
+
Que::Scheduler::VersionSupport.enqueue_a_job(Que::Scheduler::SchedulerJob)
|
56
|
+
end
|
53
57
|
execute_step((current += 1), :up) until current == version
|
54
58
|
end
|
55
59
|
|
@@ -65,11 +65,16 @@ module Que
|
|
65
65
|
|
66
66
|
# And rerun...
|
67
67
|
next_run_at = scheduler_job_args.as_time.beginning_of_minute + SCHEDULER_FREQUENCY
|
68
|
-
enqueued_job =
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
enqueued_job = Que::Scheduler::VersionSupport.enqueue_a_job(
|
69
|
+
SchedulerJob,
|
70
|
+
{
|
71
|
+
queue: Que::Scheduler.configuration.que_scheduler_queue,
|
72
|
+
run_at: next_run_at,
|
73
|
+
},
|
74
|
+
{
|
75
|
+
last_run_time: last_full_execution.iso8601,
|
76
|
+
job_dictionary: job_dictionary,
|
77
|
+
}
|
73
78
|
)
|
74
79
|
|
75
80
|
# rubocop:disable Style/GuardClause This reads better as a conditional
|
@@ -65,12 +65,11 @@ module Que
|
|
65
65
|
class QueJobType < ToEnqueue
|
66
66
|
def enqueue
|
67
67
|
job_settings = to_h.slice(:queue, :priority, :run_at).compact
|
68
|
-
job =
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
68
|
+
job = Que::Scheduler::VersionSupport.enqueue_a_job(
|
69
|
+
job_class,
|
70
|
+
job_settings,
|
71
|
+
args
|
72
|
+
)
|
74
73
|
|
75
74
|
return nil if job.nil? || !job # nil in Rails < 6.1, false after.
|
76
75
|
|
@@ -47,6 +47,25 @@ module Que
|
|
47
47
|
normalise_array_of_hashes(Que.execute(str, args))
|
48
48
|
end
|
49
49
|
|
50
|
+
# rubocop:disable Style/IfInsideElse
|
51
|
+
def enqueue_a_job(clazz, job_options = {}, job_args = [])
|
52
|
+
if supports_job_options_keyword?
|
53
|
+
# More recent versions have separated the way job arguments and options are passed in
|
54
|
+
if job_args.is_a?(Hash)
|
55
|
+
clazz.enqueue(job_args, job_options: job_options)
|
56
|
+
else
|
57
|
+
clazz.enqueue(*job_args, job_options: job_options)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
if job_args.is_a?(Hash)
|
61
|
+
clazz.enqueue(**job_args.merge(job_options))
|
62
|
+
else
|
63
|
+
clazz.enqueue(*job_args, **job_options)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# rubocop:enable Style/IfInsideElse
|
50
69
|
def default_scheduler_queue
|
51
70
|
zero_major? ? "" : Que::DEFAULT_QUEUE
|
52
71
|
end
|
@@ -64,12 +83,25 @@ module Que
|
|
64
83
|
@zero_major ||= que_version.split(".").first.to_i.zero?
|
65
84
|
end
|
66
85
|
|
86
|
+
def one_major?
|
87
|
+
# This is the only way to handle beta releases too
|
88
|
+
@one_major ||= que_version.split(".").first.to_i == 1
|
89
|
+
end
|
90
|
+
|
67
91
|
def que_version
|
68
|
-
@que_version ||=
|
92
|
+
@que_version ||= que_version_object.to_s
|
69
93
|
end
|
70
94
|
|
71
95
|
private
|
72
96
|
|
97
|
+
def supports_job_options_keyword?
|
98
|
+
@supports_job_options_keyword ||= que_version_object >= Gem::Version.new("1.2.0")
|
99
|
+
end
|
100
|
+
|
101
|
+
def que_version_object
|
102
|
+
@que_version_object ||= Gem.loaded_specs["que"].version
|
103
|
+
end
|
104
|
+
|
73
105
|
def normalise_array_of_hashes(array)
|
74
106
|
array.map { |row| row.to_h.transform_keys(&:to_sym) }
|
75
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: que-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Lascelles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|