que-scheduler 4.3.0 → 4.4.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 +4 -5
- 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 +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aac67112308ae6e0840d46479cf890eb123f94c51ac9ac9a9a1b51900064cc96
|
4
|
+
data.tar.gz: 1e268c0c918988a05e4bb5912ff47aee45b680ade2c3b422ea9dbf5c1bd0fd18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba7be6ea94dfa50387a329e39753ce1b17df38aa13e8c106c49c4eabaa3a249be8528d8fc6985201736a87a74ef318083f4f9661d6153191f484f06136f3ede
|
7
|
+
data.tar.gz: eba73e89578334e55d4d39a253edf1d2822647eee62d733d52235184c8eaa9b36f64a7027fde5ed3c2a6ea2c73666a9ea6b82ed4ca62edbd5df1ed0bdeee6432
|
data/README.md
CHANGED
@@ -308,12 +308,10 @@ A full changelog can be found here: [CHANGELOG.md](https://github.com/hlascelles
|
|
308
308
|
|
309
309
|
## System requirements
|
310
310
|
|
311
|
-
Your [postgres](https://www.postgresql.org/) database must be at least version 9.
|
311
|
+
Your [postgres](https://www.postgresql.org/) database must be at least version 9.6.0.
|
312
312
|
|
313
|
-
The latest version of que-scheduler supports Ruby 2.7
|
314
|
-
|
315
|
-
|
316
|
-
Ruby 3.x support (and thus que 2.x support) is currently in beta.
|
313
|
+
The latest version of que-scheduler supports Ruby 2.7 and above.
|
314
|
+
que-scheduler versions below 4.2.3 work with Ruby 2.5 and Ruby 2.6.
|
317
315
|
|
318
316
|
Using que 0.x with Rails 6 needs a patch to support it.
|
319
317
|
See the patch and how to use it here: https://github.com/que-rb/que/issues/247#issuecomment-595258236
|
@@ -334,3 +332,4 @@ This gem was inspired by the makers of the excellent [Que](https://github.com/ch
|
|
334
332
|
* @papodaca
|
335
333
|
* @ajoneil
|
336
334
|
* @ippachi
|
335
|
+
* @milgner
|
@@ -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.
|
4
|
+
version: 4.4.0
|
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-
|
11
|
+
date: 2022-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -71,9 +71,9 @@ dependencies:
|
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0.14'
|
74
|
-
- - "
|
74
|
+
- - "<"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 3.0.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -81,9 +81,9 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0.14'
|
84
|
-
- - "
|
84
|
+
- - "<"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: 3.0.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: activerecord
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +93,7 @@ dependencies:
|
|
93
93
|
version: '5.0'
|
94
94
|
- - "<"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '8.0'
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -103,7 +103,7 @@ dependencies:
|
|
103
103
|
version: '5.0'
|
104
104
|
- - "<"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
106
|
+
version: '8.0'
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: appraisal
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,16 +192,16 @@ dependencies:
|
|
192
192
|
name: pg
|
193
193
|
requirement: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
|
-
- - "
|
195
|
+
- - ">="
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
version: '0
|
197
|
+
version: '0'
|
198
198
|
type: :development
|
199
199
|
prerelease: false
|
200
200
|
version_requirements: !ruby/object:Gem::Requirement
|
201
201
|
requirements:
|
202
|
-
- - "
|
202
|
+
- - ">="
|
203
203
|
- !ruby/object:Gem::Version
|
204
|
-
version: '0
|
204
|
+
version: '0'
|
205
205
|
- !ruby/object:Gem::Dependency
|
206
206
|
name: pry-byebug
|
207
207
|
requirement: !ruby/object:Gem::Requirement
|