que-scheduler 3.2.7 → 3.2.8
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/README.md +2 -1
- data/lib/que/scheduler/scheduler_job.rb +1 -1
- data/lib/que/scheduler/state_checks.rb +17 -1
- data/lib/que/scheduler/version.rb +1 -1
- data/lib/que/scheduler/version_support.rb +26 -5
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2a35cace72621c452055873ea88a13aba5d00a63933df91b2d4d60840f11337
|
4
|
+
data.tar.gz: 1b2d3bbb599260b37f8ca8c10a12bd03992b08ed74b0c75f47905b1f8238dfd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab5ad0c46554887d523d7b9f90c8336da989489e76cc69a0bfe5465b66b34e7a7c3d0f2fc6c0dc026660926b51e4fff0fde029600b93e52386147565a4c10a2a
|
7
|
+
data.tar.gz: 7359bfdc4db605aea48c8bb87b1f02a8203dc103fa6e6c9ba5d6f33d051026c7e4abc7d4e5a503660d522d99f89c720455879a7b631929bd4e591961388afa75
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ needs to be run, enqueueing those jobs, then enqueueing itself to check again la
|
|
22
22
|
look for it is `config/que_schedule.yml`. They are essentially the same as resque-scheduler
|
23
23
|
files, but with additional features.
|
24
24
|
|
25
|
-
1. Add a migration to start the job scheduler and prepare the audit table.
|
25
|
+
1. Add a migration to start the job scheduler and prepare the audit table. Note that this migration will fail if Que is set to execute jobs synchronously, i.e. `Que::Job.run_synchronously = true`.
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
class CreateQueSchedulerSchema < ActiveRecord::Migration
|
@@ -234,3 +234,4 @@ This gem was inspired by the makers of the excellent [Que](https://github.com/ch
|
|
234
234
|
|
235
235
|
* @jish
|
236
236
|
* @joehorsnell
|
237
|
+
* @bnauta
|
@@ -13,8 +13,8 @@ module Que
|
|
13
13
|
class SchedulerJob < Que::Job
|
14
14
|
SCHEDULER_FREQUENCY = 60
|
15
15
|
|
16
|
-
# Always highest possible priority.
|
17
16
|
Que::Scheduler::VersionSupport.set_priority(self, 0)
|
17
|
+
Que::Scheduler::VersionSupport.apply_retry_semantics(self)
|
18
18
|
|
19
19
|
def run(options = nil)
|
20
20
|
Que::Scheduler::Db.transaction do
|
@@ -17,9 +17,22 @@ module Que
|
|
17
17
|
db_version = Que::Scheduler::Migrations.db_version
|
18
18
|
return if db_version == Que::Scheduler::Migrations::MAX_VERSION
|
19
19
|
|
20
|
+
sync_err =
|
21
|
+
if Que::Scheduler::VersionSupport.running_synchronously? && db_version.zero?
|
22
|
+
code = Que::Scheduler::VersionSupport.running_synchronously_code?
|
23
|
+
<<-ERR_SYNC
|
24
|
+
You currently have Que to run in synchronous mode using
|
25
|
+
#{code}, so it is most likely this error
|
26
|
+
has happened during an initial migration. You should disable synchronous mode and
|
27
|
+
try again. Note, que-scheduler uses "forward time" scheduled jobs, so will not work
|
28
|
+
in synchronous mode.
|
29
|
+
|
30
|
+
ERR_SYNC
|
31
|
+
end
|
32
|
+
|
20
33
|
raise(<<-ERR)
|
21
34
|
The que-scheduler db migration state was found to be #{db_version}. It should be #{Que::Scheduler::Migrations::MAX_VERSION}.
|
22
|
-
|
35
|
+
#{sync_err}
|
23
36
|
que-scheduler adds some tables to the DB to provide an audit history of what was
|
24
37
|
enqueued when, and with what options and arguments. The structure of these tables is
|
25
38
|
versioned, and should match that version required by the gem.
|
@@ -42,6 +55,9 @@ module Que
|
|
42
55
|
Que::Scheduler::Migrations.migrate!(version: #{Que::Scheduler::Migrations::MAX_VERSION})
|
43
56
|
end
|
44
57
|
end
|
58
|
+
|
59
|
+
It is also possible that you are running a migration with Que set up to execute jobs
|
60
|
+
synchronously. This will fail as que-scheduler needs the above tables to work.
|
45
61
|
ERR
|
46
62
|
end
|
47
63
|
|
@@ -5,7 +5,14 @@ require 'que'
|
|
5
5
|
module Que
|
6
6
|
module Scheduler
|
7
7
|
module VersionSupport
|
8
|
+
RETRY_PROC = proc { |count|
|
9
|
+
# Maximum one hour, otherwise use the default backoff
|
10
|
+
count > 7 ? (60 * 60) : ((count**4) + 3)
|
11
|
+
}
|
12
|
+
|
8
13
|
class << self
|
14
|
+
# Ensure que-scheduler runs at the highest priority. This is because its priority is a
|
15
|
+
# the top of all jobs it enqueues.
|
9
16
|
def set_priority(context, priority)
|
10
17
|
if zero_major?
|
11
18
|
context.instance_variable_set('@priority', priority)
|
@@ -14,6 +21,16 @@ module Que
|
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
24
|
+
# Ensure the job runs at least once an hour when it is backing off due to errors
|
25
|
+
def apply_retry_semantics(context)
|
26
|
+
if zero_major?
|
27
|
+
context.instance_variable_set('@retry_interval', RETRY_PROC)
|
28
|
+
else
|
29
|
+
context.maximum_retry_count = 1 << 128 # Heat death of universe
|
30
|
+
context.retry_interval = RETRY_PROC
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
17
34
|
def job_attributes(enqueued_job)
|
18
35
|
if zero_major?
|
19
36
|
enqueued_job.attrs.transform_keys(&:to_sym)
|
@@ -31,11 +48,15 @@ module Que
|
|
31
48
|
end
|
32
49
|
|
33
50
|
def default_scheduler_queue
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
51
|
+
zero_major? ? '' : Que::DEFAULT_QUEUE
|
52
|
+
end
|
53
|
+
|
54
|
+
def running_synchronously?
|
55
|
+
zero_major? ? (Que.mode == :sync) : Que.run_synchronously
|
56
|
+
end
|
57
|
+
|
58
|
+
def running_synchronously_code?
|
59
|
+
zero_major? ? 'Que.mode == :sync' : 'Que.run_synchronously = true'
|
39
60
|
end
|
40
61
|
|
41
62
|
def zero_major?
|
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: 3.2.
|
4
|
+
version: 3.2.8
|
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: 2020-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -62,16 +62,22 @@ dependencies:
|
|
62
62
|
name: hashie
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '3'
|
68
|
+
- - "<"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '5'
|
68
71
|
type: :runtime
|
69
72
|
prerelease: false
|
70
73
|
version_requirements: !ruby/object:Gem::Requirement
|
71
74
|
requirements:
|
72
|
-
- - "
|
75
|
+
- - ">="
|
73
76
|
- !ruby/object:Gem::Version
|
74
77
|
version: '3'
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '5'
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
82
|
name: que
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +87,7 @@ dependencies:
|
|
81
87
|
version: '0.12'
|
82
88
|
- - "<="
|
83
89
|
- !ruby/object:Gem::Version
|
84
|
-
version: 1.0.0.
|
90
|
+
version: 1.0.0.beta4
|
85
91
|
type: :runtime
|
86
92
|
prerelease: false
|
87
93
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,7 +97,7 @@ dependencies:
|
|
91
97
|
version: '0.12'
|
92
98
|
- - "<="
|
93
99
|
- !ruby/object:Gem::Version
|
94
|
-
version: 1.0.0.
|
100
|
+
version: 1.0.0.beta4
|
95
101
|
- !ruby/object:Gem::Dependency
|
96
102
|
name: activerecord
|
97
103
|
requirement: !ruby/object:Gem::Requirement
|