que-scheduler 4.0.0 → 4.0.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 +40 -25
- data/lib/que/scheduler.rb +1 -1
- data/lib/que/scheduler/configuration.rb +35 -0
- data/lib/que/scheduler/db.rb +1 -1
- data/lib/que/scheduler/schedule.rb +16 -10
- data/lib/que/scheduler/version.rb +1 -1
- metadata +16 -2
- data/lib/que/scheduler/config.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78c9bc8d137dbe8a7c2428e50c615928c5d702d06432763b5346030fcbe81d5b
|
4
|
+
data.tar.gz: 3e639fd3f2263266fa25e25c637390f718e7751726feaefaa63f69cc91124f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b599d23b38d8263412e2a1fa7eb6621f564a628ae7b66800b0259667a76956e0a9e16824bd463a24edd0752119f30ec01ac3a1951e1d4abfc1d05ed1905745dc
|
7
|
+
data.tar.gz: 42691328a2727e14f15305e6baac0f0d7b3e4cb1d1a91c80d2ef1f7ab42db56e3bd1640884805adf381d65fbe2d6b3d7abbe2373e8ef49dfbeb737f790b76700
|
data/README.md
CHANGED
@@ -36,8 +36,8 @@ resque-scheduler files, but with additional features.
|
|
36
36
|
## Schedule configuration
|
37
37
|
|
38
38
|
The schedule file should be placed here: `config/que_schedule.yml`. Alternatively if you
|
39
|
-
wish to generate the configuration dynamically, you can set it directly
|
40
|
-
|
39
|
+
wish to generate the configuration dynamically, you can set it directly using an initializer
|
40
|
+
(see "Gem configuration" below).
|
41
41
|
|
42
42
|
The file is a list of que job classes with arguments and a schedule frequency (in crontab
|
43
43
|
syntax). The format is similar to the resque-scheduler format, though priorities must be supplied as
|
@@ -135,19 +135,34 @@ A job can have a `schedule_type` assigned to it. Valid values are:
|
|
135
135
|
|
136
136
|
## Gem configuration
|
137
137
|
|
138
|
-
You can configure some aspects of the gem with
|
138
|
+
You can configure some aspects of the gem with a config block (eg in a Rails initializer).
|
139
|
+
The default is given below. You can omit any configuration sections you are not intending to change.
|
140
|
+
It is quite likely you won't have to create this config at all.
|
139
141
|
|
140
142
|
```ruby
|
141
143
|
Que::Scheduler.configure do |config|
|
142
144
|
# The location of the schedule yaml file.
|
143
|
-
config.schedule_location = ENV.fetch(
|
145
|
+
config.schedule_location = ENV.fetch("QUE_SCHEDULER_CONFIG_LOCATION", "config/que_schedule.yml")
|
146
|
+
|
147
|
+
# The schedule as a hash. You can use this if you want to build the schedule yourself at runtime.
|
148
|
+
# This will override the above value if provided.
|
149
|
+
config.schedule = {
|
150
|
+
SpecifiedByHashTestJob: {
|
151
|
+
cron: "02 11 * * *"
|
152
|
+
}
|
153
|
+
}
|
144
154
|
|
145
|
-
#
|
146
|
-
# However
|
155
|
+
# The transaction block adapter. By default, que-scheduler uses the one supplied by que.
|
156
|
+
# However if, for example, you rely on listeners to ActiveRecord's exact `transaction` method, or
|
147
157
|
# Sequel's DB.after_commit helper, then you can supply it here.
|
148
158
|
config.transaction_adapter = ::Que.method(:transaction)
|
149
|
-
end
|
150
159
|
|
160
|
+
# Which queue name the que-scheduler job should self-schedule on. Typically this is the default
|
161
|
+
# queue of que, which has a different name in Que 0.x ("") and 1.x ("default").
|
162
|
+
# It *must* be the "highest throughput" queue - do not work the scheduler on a "long
|
163
|
+
# running jobs" queue. It is very unlikely you will want to change this.
|
164
|
+
config.que_scheduler_queue = ENV.fetch("QUE_SCHEDULER_QUEUE", "" or "default")
|
165
|
+
end
|
151
166
|
```
|
152
167
|
|
153
168
|
## Scheduler Audit
|
@@ -159,8 +174,25 @@ migration tasks.
|
|
159
174
|
Additionally, there is the audit table `que_scheduler_audit_enqueued`. This logs every job that
|
160
175
|
the scheduler enqueues.
|
161
176
|
|
177
|
+
que-scheduler comes with the `QueSchedulerAuditClearDownJob` job built in that you can optionally
|
178
|
+
schedule to clear down audit rows if you don't need to retain them indefinitely. You should add this
|
179
|
+
to your own scheduler config yaml.
|
180
|
+
|
181
|
+
For example:
|
182
|
+
|
183
|
+
```yaml
|
184
|
+
# This will clear down the oldest que-scheduler audit rows. Since que-scheduler
|
185
|
+
# runs approximately every minute, 129600 is 90 days.
|
186
|
+
Que::Scheduler::Jobs::QueSchedulerAuditClearDownJob:
|
187
|
+
cron: "0 0 * * *"
|
188
|
+
args:
|
189
|
+
retain_row_count: 129600
|
190
|
+
```
|
191
|
+
|
192
|
+
## Required migrations
|
193
|
+
|
162
194
|
When there is a major version (breaking) change, a migration should be run in. The version of the
|
163
|
-
latest migration proceeds at a faster rate than the version of the gem
|
195
|
+
latest migration proceeds at a faster rate than the version of the gem. eg If the gem is on version
|
164
196
|
3 then the migrations may be on version 6).
|
165
197
|
|
166
198
|
To run in all the migrations required up to a number, just migrate to that number with one line, and
|
@@ -188,23 +220,6 @@ The changes in past migrations were:
|
|
188
220
|
| 5 | Dropped an unnecessary index |
|
189
221
|
| 6 | Enforced single scheduler job at the trigger level |
|
190
222
|
|
191
|
-
## Built in optional job for audit clear down
|
192
|
-
|
193
|
-
que-scheduler comes with the `QueSchedulerAuditClearDownJob` job built in that you can optionally
|
194
|
-
schedule to clear down audit rows if you don't need to retain them indefinitely. You should add this
|
195
|
-
to your own scheduler config yaml.
|
196
|
-
|
197
|
-
For example:
|
198
|
-
|
199
|
-
```yaml
|
200
|
-
# This will clear down the oldest que-scheduler audit rows. Since que-scheduler
|
201
|
-
# runs approximately every minute, 129600 is 90 days.
|
202
|
-
Que::Scheduler::Jobs::QueSchedulerAuditClearDownJob:
|
203
|
-
cron: "0 0 * * *"
|
204
|
-
args:
|
205
|
-
retain_row_count: 129600
|
206
|
-
```
|
207
|
-
|
208
223
|
## HA Redundancy and DB restores
|
209
224
|
|
210
225
|
Because of the way que-scheduler works, it requires no additional processes. It is, itself, a Que job.
|
data/lib/que/scheduler.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "que"
|
2
|
+
require_relative "version_support"
|
3
|
+
|
4
|
+
module Que
|
5
|
+
module Scheduler
|
6
|
+
class Configuration
|
7
|
+
attr_accessor :schedule_location
|
8
|
+
attr_accessor :schedule
|
9
|
+
attr_accessor :transaction_adapter
|
10
|
+
attr_accessor :que_scheduler_queue
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :configuration
|
15
|
+
|
16
|
+
def configure
|
17
|
+
self.configuration ||= Configuration.new
|
18
|
+
yield(configuration)
|
19
|
+
end
|
20
|
+
|
21
|
+
def apply_defaults
|
22
|
+
configure do |config|
|
23
|
+
config.schedule_location =
|
24
|
+
ENV.fetch("QUE_SCHEDULER_CONFIG_LOCATION", "config/que_schedule.yml")
|
25
|
+
config.transaction_adapter = ::Que.method(:transaction)
|
26
|
+
config.que_scheduler_queue =
|
27
|
+
ENV.fetch("QUE_SCHEDULER_QUEUE", Que::Scheduler::VersionSupport.default_scheduler_queue)
|
28
|
+
config.schedule = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Que::Scheduler.apply_defaults
|
data/lib/que/scheduler/db.rb
CHANGED
@@ -1,21 +1,31 @@
|
|
1
|
+
require_relative "configuration"
|
1
2
|
require_relative "defined_job"
|
2
3
|
|
3
4
|
module Que
|
4
5
|
module Scheduler
|
5
6
|
class Schedule
|
6
7
|
class << self
|
8
|
+
# The main method for determining the schedule. It has to evaluate the schedule as late as
|
9
|
+
# possible (ie just as it is about to be used) as we cannot guarantee we are in a Rails
|
10
|
+
# app with initializers. In a future release this may change to "fast fail" in Rails by
|
11
|
+
# checking the config up front.
|
7
12
|
def schedule
|
8
13
|
@schedule ||=
|
9
14
|
begin
|
10
|
-
|
11
|
-
|
15
|
+
configuration = Que::Scheduler.configuration
|
16
|
+
if !configuration.schedule.nil?
|
17
|
+
# If an explicit schedule as a hash has been defined, use that.
|
18
|
+
from_hash(configuration.schedule)
|
19
|
+
elsif File.exist?(configuration.schedule_location)
|
20
|
+
# If the schedule is defined as a file location, then load it and return it.
|
21
|
+
from_file(configuration.schedule_location)
|
22
|
+
else
|
23
|
+
raise "No que-scheduler config set, or file found " \
|
24
|
+
"at #{configuration.schedule_location}"
|
25
|
+
end
|
12
26
|
end
|
13
27
|
end
|
14
28
|
|
15
|
-
def schedule=(schedule_config)
|
16
|
-
@schedule = schedule_config.nil? ? nil : from_yaml(schedule_config)
|
17
|
-
end
|
18
|
-
|
19
29
|
def from_file(location)
|
20
30
|
from_yaml(IO.read(location))
|
21
31
|
end
|
@@ -69,10 +79,6 @@ module Que
|
|
69
79
|
def schedule
|
70
80
|
Schedule.schedule
|
71
81
|
end
|
72
|
-
|
73
|
-
def schedule=(value)
|
74
|
-
Schedule.schedule = value
|
75
|
-
end
|
76
82
|
end
|
77
83
|
end
|
78
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Lascelles
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: climate_control
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: combustion
|
117
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -319,7 +333,7 @@ files:
|
|
319
333
|
- lib/que-scheduler.rb
|
320
334
|
- lib/que/scheduler.rb
|
321
335
|
- lib/que/scheduler/audit.rb
|
322
|
-
- lib/que/scheduler/
|
336
|
+
- lib/que/scheduler/configuration.rb
|
323
337
|
- lib/que/scheduler/db.rb
|
324
338
|
- lib/que/scheduler/defined_job.rb
|
325
339
|
- lib/que/scheduler/enqueueing_calculator.rb
|
data/lib/que/scheduler/config.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require "que"
|
2
|
-
require_relative "version_support"
|
3
|
-
|
4
|
-
module Que
|
5
|
-
module Scheduler
|
6
|
-
class << self
|
7
|
-
attr_accessor :configuration
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.configure
|
11
|
-
self.configuration ||= Configuration.new
|
12
|
-
yield(configuration)
|
13
|
-
end
|
14
|
-
|
15
|
-
class Configuration
|
16
|
-
attr_accessor :schedule_location
|
17
|
-
attr_accessor :transaction_adapter
|
18
|
-
attr_accessor :que_scheduler_queue
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Que::Scheduler.configure do |config|
|
24
|
-
config.schedule_location = ENV.fetch("QUE_SCHEDULER_CONFIG_LOCATION", "config/que_schedule.yml")
|
25
|
-
config.transaction_adapter = ::Que.method(:transaction)
|
26
|
-
config.que_scheduler_queue = Que::Scheduler::VersionSupport.default_scheduler_queue
|
27
|
-
end
|