que-scheduler 4.0.2 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/que/scheduler.rb +1 -0
- data/lib/que/scheduler/configuration.rb +2 -0
- data/lib/que/scheduler/defined_job.rb +1 -1
- data/lib/que/scheduler/jobs/que_scheduler_audit_clear_down_job.rb +1 -1
- data/lib/que/scheduler/schedule.rb +2 -1
- data/lib/que/scheduler/scheduler_job_args.rb +2 -1
- data/lib/que/scheduler/state_checks.rb +1 -1
- data/lib/que/scheduler/time_zone.rb +61 -0
- data/lib/que/scheduler/to_enqueue.rb +7 -1
- data/lib/que/scheduler/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe4e2dccf7d28c0918286aff2764b770b5f7ce4ddfe3383e4db74e3b21531bcc
|
4
|
+
data.tar.gz: a0b4db17f63d630acd1ef5e401d897ca5df2995c1cf45489367541671a5039f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 358a0ed1b4e31f5dc355f11bfab0dd8765852857684f752bf8ab99ca805690ed3eb7b502d6f36f2683c2fdc1429eaff8d5d4faa00983c9175a6669cf1ff5ea5f
|
7
|
+
data.tar.gz: 29b612a226076216788cb914fbe7064c6840597962f718fd3635d85c23e4085aa2c497ec521e661c621631b7b36de9aae080538bc6b37ac93e489fad035ba583
|
data/README.md
CHANGED
@@ -162,6 +162,14 @@ Que::Scheduler.configure do |config|
|
|
162
162
|
# It *must* be the "highest throughput" queue - do not work the scheduler on a "long
|
163
163
|
# running jobs" queue. It is very unlikely you will want to change this.
|
164
164
|
config.que_scheduler_queue = ENV.fetch("QUE_SCHEDULER_QUEUE", "" or "default")
|
165
|
+
|
166
|
+
# If que-scheduler is being used with Rails, then it will inherit the time zone from that
|
167
|
+
# framework, and you can leave the value as nil as shown below. However, if you are not using
|
168
|
+
# Rails, you may need to set the time zone here. If que-scheduler cannot determine the time zone
|
169
|
+
# it will yield an error prompting you for action.
|
170
|
+
# If you need to set a value, use the string representation:
|
171
|
+
# eg: config.time_zone = "Europe/London"
|
172
|
+
config.time_zone = nil
|
165
173
|
end
|
166
174
|
```
|
167
175
|
|
data/lib/que/scheduler.rb
CHANGED
@@ -8,6 +8,7 @@ module Que
|
|
8
8
|
attr_accessor :schedule
|
9
9
|
attr_accessor :transaction_adapter
|
10
10
|
attr_accessor :que_scheduler_queue
|
11
|
+
attr_accessor :time_zone
|
11
12
|
end
|
12
13
|
|
13
14
|
class << self
|
@@ -26,6 +27,7 @@ module Que
|
|
26
27
|
config.que_scheduler_queue =
|
27
28
|
ENV.fetch("QUE_SCHEDULER_QUEUE", Que::Scheduler::VersionSupport.default_scheduler_queue)
|
28
29
|
config.schedule = nil
|
30
|
+
config.time_zone = nil
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -89,7 +89,7 @@ module Que
|
|
89
89
|
Que::Scheduler::ToEnqueue.active_job_sufficient_version? &&
|
90
90
|
job_class < ::ActiveJob::Base &&
|
91
91
|
Que::Scheduler::ToEnqueue.active_job_version < Gem::Version.create("6.0.3")
|
92
|
-
puts
|
92
|
+
puts <<~ERR
|
93
93
|
WARNING from que-scheduler....
|
94
94
|
Between versions 4.2.3 and 6.0.2 (inclusive) Rails did not support setting queue names
|
95
95
|
on que jobs with ActiveJob, so que-scheduler cannot support it.
|
@@ -41,7 +41,8 @@ module Que
|
|
41
41
|
end.to_h
|
42
42
|
end
|
43
43
|
|
44
|
-
def hash_item_to_defined_job(name,
|
44
|
+
def hash_item_to_defined_job(name, defined_job_hash_in)
|
45
|
+
defined_job_hash = defined_job_hash_in.stringify_keys
|
45
46
|
# Que stores arguments as a json array. If the args we have to provide are already an
|
46
47
|
# array we can can simply pass them through. If it is a single non-nil value, then we make
|
47
48
|
# an array with one item which is that value (this includes if it is a hash). It could
|
@@ -22,7 +22,8 @@ module Que
|
|
22
22
|
else
|
23
23
|
options = options.symbolize_keys
|
24
24
|
{
|
25
|
-
last_run_time:
|
25
|
+
last_run_time:
|
26
|
+
Que::Scheduler::TimeZone.time_zone.parse(options.fetch(:last_run_time)),
|
26
27
|
job_dictionary: options.fetch(:job_dictionary),
|
27
28
|
}
|
28
29
|
end
|
@@ -19,7 +19,7 @@ module Que
|
|
19
19
|
sync_err =
|
20
20
|
if Que::Scheduler::VersionSupport.running_synchronously? && db_version.zero?
|
21
21
|
code = Que::Scheduler::VersionSupport.running_synchronously_code?
|
22
|
-
|
22
|
+
<<~ERR_SYNC
|
23
23
|
You currently have Que to run in synchronous mode using
|
24
24
|
#{code}, so it is most likely this error
|
25
25
|
has happened during an initial migration. You should disable synchronous mode and
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Que
|
2
|
+
module Scheduler
|
3
|
+
module TimeZone
|
4
|
+
BOTH_CONFIG_AND_TIME_DOT_ZONE_SET = <<~ERR.freeze
|
5
|
+
The que-scheduler config for time_zone has been set to a non-nil value, but
|
6
|
+
it appears to also have been set on Time.zone (possibly by Rails). Both of these
|
7
|
+
cannot be non-nil.
|
8
|
+
You should remove the time_zone config from the que-scheduler config block.
|
9
|
+
ERR
|
10
|
+
|
11
|
+
TIME_ZONE_COULD_NOT_BE_DETERMINED = <<~ERR.freeze
|
12
|
+
It appears Time.zone is nil. This prevents proper functioning of que-scheduler.
|
13
|
+
|
14
|
+
Resolving this issue depends on your application setup.
|
15
|
+
|
16
|
+
1) If you are using Rails, set the standard time_zone config
|
17
|
+
eg:
|
18
|
+
```
|
19
|
+
# In application.rb
|
20
|
+
config.time_zone = "Europe/London"
|
21
|
+
```
|
22
|
+
|
23
|
+
2) If you are not using Rails, set your time zone in the que-scheduler config:
|
24
|
+
eg:
|
25
|
+
```
|
26
|
+
Que::Scheduler.configure do |config|
|
27
|
+
config.time_zone = "Europe/London"
|
28
|
+
end
|
29
|
+
```
|
30
|
+
ERR
|
31
|
+
|
32
|
+
TIME_ZONE_CONFIG_IS_NOT_VALID = <<~ERR.freeze
|
33
|
+
The que-scheduler config for time_zone has been set to a non-nil value, but that value
|
34
|
+
does not yield a real time zone when passed to ActiveSupport::TimeZone.new
|
35
|
+
ERR
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def time_zone
|
39
|
+
@time_zone ||=
|
40
|
+
begin
|
41
|
+
time_dot_zone = Time.zone
|
42
|
+
if time_dot_zone.present?
|
43
|
+
if Que::Scheduler.configuration.time_zone.present?
|
44
|
+
raise BOTH_CONFIG_AND_TIME_DOT_ZONE_SET
|
45
|
+
end
|
46
|
+
|
47
|
+
time_dot_zone
|
48
|
+
elsif Que::Scheduler.configuration.time_zone
|
49
|
+
new_tz = ActiveSupport::TimeZone.new(Que::Scheduler.configuration.time_zone)
|
50
|
+
raise TIME_ZONE_CONFIG_IS_NOT_VALID unless new_tz
|
51
|
+
|
52
|
+
new_tz
|
53
|
+
else
|
54
|
+
raise TIME_ZONE_COULD_NOT_BE_DETERMINED
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -105,7 +105,13 @@ module Que
|
|
105
105
|
scheduled_at =
|
106
106
|
begin
|
107
107
|
scheduled_at_float = data[:scheduled_at]
|
108
|
-
|
108
|
+
# rubocop:disable Style/EmptyElse
|
109
|
+
if scheduled_at_float
|
110
|
+
Que::Scheduler::TimeZone.time_zone.at(scheduled_at_float)
|
111
|
+
else
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
# rubocop:enable Style/EmptyElse
|
109
115
|
end
|
110
116
|
|
111
117
|
# Rails didn't support queues for ActiveJob for a while
|
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.0.
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Lascelles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -355,6 +355,7 @@ files:
|
|
355
355
|
- lib/que/scheduler/scheduler_job.rb
|
356
356
|
- lib/que/scheduler/scheduler_job_args.rb
|
357
357
|
- lib/que/scheduler/state_checks.rb
|
358
|
+
- lib/que/scheduler/time_zone.rb
|
358
359
|
- lib/que/scheduler/to_enqueue.rb
|
359
360
|
- lib/que/scheduler/version.rb
|
360
361
|
- lib/que/scheduler/version_support.rb
|