resque-scheduler 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque-scheduler might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/AUTHORS.md +3 -0
- data/CHANGELOG.md +21 -2
- data/Gemfile +8 -0
- data/README.md +17 -10
- data/lib/resque/scheduler.rb +25 -13
- data/lib/resque/scheduler/delaying_extensions.rb +6 -0
- data/lib/resque/scheduler/env.rb +3 -3
- data/lib/resque/scheduler/lock/resilient.rb +2 -2
- data/lib/resque/scheduler/locking.rb +2 -2
- data/lib/resque/scheduler/server/views/delayed.erb +1 -1
- data/lib/resque/scheduler/version.rb +1 -1
- data/resque-scheduler.gemspec +2 -2
- metadata +5 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d023543334a4b91f16d2c055415ee69cb7d1d8a7cf8219c63b7041d6cd83dfe
|
4
|
+
data.tar.gz: 905a6a650435f19ae58c6cd7cbb6c260485dd23a4335c0cc6a94f285611df783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163b20de37de1fba902be2e744cf61b716e04610b391b510f4fe2cbd47aa22299b4a012994a62a928063d749520121cacc58609e10a7b7d1c17126aeb1e5aa49
|
7
|
+
data.tar.gz: bb1be8accb32a7d682198bdff57b2958526408a1e54093315c322b6a1c69905c6548763057957a563a0fd553c62e5d557b5fad2a5ae6b6f11ba26355ec6270b9
|
data/AUTHORS.md
CHANGED
@@ -27,6 +27,7 @@ Resque Scheduler authors
|
|
27
27
|
- Harry Lascelles
|
28
28
|
- Henrik Nyh
|
29
29
|
- Hormoz Kheradmand
|
30
|
+
- Ian Davies
|
30
31
|
- James Le Cuirot
|
31
32
|
- Jarkko Mönkkönen
|
32
33
|
- John Crepezzi
|
@@ -35,6 +36,7 @@ Resque Scheduler authors
|
|
35
36
|
- Jonathan Conley
|
36
37
|
- Jonathan Hyman
|
37
38
|
- Jonathan Owens
|
39
|
+
- Jordan Gardner
|
38
40
|
- Joshua Szmajda
|
39
41
|
- Justin Weiss
|
40
42
|
- Les Hill
|
@@ -46,6 +48,7 @@ Resque Scheduler authors
|
|
46
48
|
- Michael Lovitt
|
47
49
|
- Michael Nikitochkin
|
48
50
|
- Michael Rykov
|
51
|
+
- Mike MacDonald
|
49
52
|
- Nickolas Means
|
50
53
|
- Olek Janiszewski
|
51
54
|
- Olivier Brisse
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,23 @@
|
|
2
2
|
|
3
3
|
**ATTN**: This project uses [semantic versioning](http://semver.org/).
|
4
4
|
|
5
|
-
## [
|
5
|
+
## [4.4.0] - 2019-04-11
|
6
|
+
### Added
|
7
|
+
- Support Resque 2
|
8
|
+
- Support redis-rb 4
|
9
|
+
- Support Ruby 2.5
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Redis timeouts no longer crash the scheduler process
|
13
|
+
- Fix race condition when running multiple schedulers
|
14
|
+
- Fix setting the `poll_sleep_amount` option
|
15
|
+
- Escape class names in resque-web /delayed URLs
|
16
|
+
|
17
|
+
## Changed
|
18
|
+
- Addressed redis-namespace deprecation warnings
|
19
|
+
- Ensure `enqueue_in` args are Numeric, catching a common issue passing `ActiveSupport::Duration`
|
20
|
+
|
21
|
+
## [4.3.1] - 2017-11-20
|
6
22
|
### Changed
|
7
23
|
- Add support and testing for ruby 2.4
|
8
24
|
- Change log format and file name
|
@@ -11,6 +27,7 @@
|
|
11
27
|
|
12
28
|
### Fixed
|
13
29
|
- Reporting version via `resque-scheduler --version`
|
30
|
+
- Class name escaping in `/delayed` view
|
14
31
|
|
15
32
|
## [4.3.0] - 2016-06-26
|
16
33
|
### Added
|
@@ -407,7 +424,9 @@
|
|
407
424
|
### Added
|
408
425
|
- Initial release
|
409
426
|
|
410
|
-
[Unreleased]: https://github.com/resque/resque-scheduler/compare/v4.
|
427
|
+
[Unreleased]: https://github.com/resque/resque-scheduler/compare/v4.4.0...HEAD
|
428
|
+
[4.4.0]: https://github.com/resque/resque-scheduler/compare/v4.3.1...v4.4.0
|
429
|
+
[4.3.1]: https://github.com/resque/resque-scheduler/compare/v4.3.0...v4.3.1
|
411
430
|
[4.3.0]: https://github.com/resque/resque-scheduler/compare/v4.2.1...v4.3.0
|
412
431
|
[4.2.1]: https://github.com/resque/resque-scheduler/compare/v4.2.0...v4.2.1
|
413
432
|
[4.2.0]: https://github.com/resque/resque-scheduler/compare/v4.1.0...v4.2.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ resque-scheduler
|
|
13
13
|
Resque-scheduler is an extension to [Resque](http://github.com/resque/resque)
|
14
14
|
that adds support for queueing items in the future.
|
15
15
|
|
16
|
-
Job scheduling is supported in two different
|
16
|
+
Job scheduling is supported in two different ways: Recurring (scheduled) and
|
17
17
|
Delayed.
|
18
18
|
|
19
19
|
Scheduled jobs are like cron jobs, recurring on a regular basis. Delayed
|
@@ -160,7 +160,7 @@ following task to wherever tasks are kept, such as
|
|
160
160
|
```ruby
|
161
161
|
task 'resque:pool:setup' do
|
162
162
|
Resque::Pool.after_prefork do |job|
|
163
|
-
Resque.redis.
|
163
|
+
Resque.redis._client.reconnect
|
164
164
|
end
|
165
165
|
end
|
166
166
|
```
|
@@ -235,6 +235,17 @@ Resque.remove_delayed_selection { |args| args[0]['account_id'] == current_accoun
|
|
235
235
|
Resque.remove_delayed_selection { |args| args[0]['user_id'] == current_user.id }
|
236
236
|
```
|
237
237
|
|
238
|
+
If you need to cancel a delayed job based on some matching arguments AND by which class the job is, but don't wish to specify each argument from when the job was created, you can do like so:
|
239
|
+
|
240
|
+
``` ruby
|
241
|
+
# after you've enqueued a job like:
|
242
|
+
Resque.enqueue_at(5.days.from_now, SendFollowUpEmail, :account_id => current_account.id, :user_id => current_user.id)
|
243
|
+
# remove jobs matching just the account and that were of the class SendFollowUpEmail:
|
244
|
+
Resque.remove_delayed_selection(SendFollowUpEmail) { |args| args[0]['account_id'] == current_account.id }
|
245
|
+
# or remove jobs matching just the user and that were of the class SendFollowUpEmail:
|
246
|
+
Resque.remove_delayed_selection(SendFollowUpEmail) { |args| args[0]['user_id'] == current_user.id }
|
247
|
+
```
|
248
|
+
|
238
249
|
If you need to enqueue immediately a delayed job based on some matching arguments, but don't wish to specify each argument from when the job was created, you can do like so:
|
239
250
|
|
240
251
|
``` ruby
|
@@ -338,8 +349,8 @@ for handling the heavy lifting of the actual scheduling engine.
|
|
338
349
|
#### Dynamic schedules
|
339
350
|
|
340
351
|
Dynamic schedules are programmatically set on a running `resque-scheduler`.
|
341
|
-
|
342
|
-
when setting schedules.
|
352
|
+
Most [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler) options are supported
|
353
|
+
when setting schedules. Specifically the `overlap` option will not work.
|
343
354
|
|
344
355
|
Dynamic schedules are not enabled by default. To be able to dynamically set schedules, you
|
345
356
|
must pass the following to `resque-scheduler` initialization (see *Installation* above for a more complete example):
|
@@ -516,7 +527,7 @@ RESQUE_SCHEDULER_MASTER_LOCK_PREFIX=MyApp: rake resque:scheduler
|
|
516
527
|
|
517
528
|
### resque-web Additions
|
518
529
|
|
519
|
-
Resque-scheduler also adds
|
530
|
+
Resque-scheduler also adds two tabs to the resque-web UI. One is for viewing
|
520
531
|
(and manually queueing) the schedule and one is for viewing pending jobs in
|
521
532
|
the delayed queue.
|
522
533
|
|
@@ -550,11 +561,7 @@ require 'resque/scheduler/server'
|
|
550
561
|
|
551
562
|
That should make the scheduler tabs show up in `resque-web`.
|
552
563
|
|
553
|
-
|
554
|
-
|
555
|
-
As of resque-scheduler 2.0.0, it's no longer necessary to have the resque-web
|
556
|
-
process aware of the schedule because it reads it from redis. But prior to
|
557
|
-
2.0, you'll want to make sure you load the schedule in this file as well.
|
564
|
+
You'll want to make sure you load the schedule in this file as well.
|
558
565
|
Something like this:
|
559
566
|
|
560
567
|
```ruby
|
data/lib/resque/scheduler.rb
CHANGED
@@ -13,6 +13,9 @@ module Resque
|
|
13
13
|
autoload :Extension, 'resque/scheduler/extension'
|
14
14
|
autoload :Util, 'resque/scheduler/util'
|
15
15
|
autoload :VERSION, 'resque/scheduler/version'
|
16
|
+
INTERMITTENT_ERRORS = [
|
17
|
+
Errno::EAGAIN, Errno::ECONNRESET, Redis::CannotConnectError, Redis::TimeoutError
|
18
|
+
].freeze
|
16
19
|
|
17
20
|
private
|
18
21
|
|
@@ -44,13 +47,7 @@ module Resque
|
|
44
47
|
$stdout.sync = true
|
45
48
|
$stderr.sync = true
|
46
49
|
|
47
|
-
|
48
|
-
# If dynamic is set, load that schedule otherwise use normal load
|
49
|
-
if dynamic
|
50
|
-
reload_schedule!
|
51
|
-
else
|
52
|
-
load_schedule!
|
53
|
-
end
|
50
|
+
was_master = nil
|
54
51
|
|
55
52
|
begin
|
56
53
|
@th = Thread.current
|
@@ -58,11 +55,21 @@ module Resque
|
|
58
55
|
# Now start the scheduling part of the loop.
|
59
56
|
loop do
|
60
57
|
begin
|
61
|
-
|
58
|
+
# Check on changes to master/child
|
59
|
+
@am_master = master?
|
60
|
+
if am_master != was_master
|
61
|
+
procline am_master ? 'Master scheduler' : 'Child scheduler'
|
62
|
+
|
63
|
+
# Load schedule because changed
|
64
|
+
reload_schedule!
|
65
|
+
end
|
66
|
+
|
67
|
+
if am_master
|
62
68
|
handle_delayed_items
|
63
69
|
update_schedule if dynamic
|
64
70
|
end
|
65
|
-
|
71
|
+
was_master = am_master
|
72
|
+
rescue *INTERMITTENT_ERRORS => e
|
66
73
|
log! e.message
|
67
74
|
release_master_lock
|
68
75
|
end
|
@@ -99,7 +106,7 @@ module Resque
|
|
99
106
|
Resque.schedule.each do |name, config|
|
100
107
|
load_schedule_job(name, config)
|
101
108
|
end
|
102
|
-
Resque.redis.del(:schedules_changed)
|
109
|
+
Resque.redis.del(:schedules_changed) if am_master && dynamic
|
103
110
|
procline 'Schedules Loaded'
|
104
111
|
end
|
105
112
|
|
@@ -202,7 +209,7 @@ module Resque
|
|
202
209
|
loop do
|
203
210
|
handle_shutdown do
|
204
211
|
# Continually check that it is still the master
|
205
|
-
item = enqueue_next_item(timestamp) if
|
212
|
+
item = enqueue_next_item(timestamp) if am_master
|
206
213
|
end
|
207
214
|
# continue processing until there are no more ready items in this
|
208
215
|
# timestamp
|
@@ -420,10 +427,10 @@ module Resque
|
|
420
427
|
private
|
421
428
|
|
422
429
|
def enqueue_recurring(name, config)
|
423
|
-
if
|
430
|
+
if am_master
|
424
431
|
log! "queueing #{config['class']} (#{name})"
|
425
|
-
Resque.last_enqueued_at(name, Time.now.to_s)
|
426
432
|
enqueue(config)
|
433
|
+
Resque.last_enqueued_at(name, Time.now.to_s)
|
427
434
|
end
|
428
435
|
end
|
429
436
|
|
@@ -442,6 +449,11 @@ module Resque
|
|
442
449
|
def internal_name
|
443
450
|
"resque-scheduler-#{Resque::Scheduler::VERSION}"
|
444
451
|
end
|
452
|
+
|
453
|
+
def am_master
|
454
|
+
@am_master = master? unless defined?(@am_master)
|
455
|
+
@am_master
|
456
|
+
end
|
445
457
|
end
|
446
458
|
end
|
447
459
|
end
|
@@ -45,6 +45,9 @@ module Resque
|
|
45
45
|
# Identical to enqueue_at but takes number_of_seconds_from_now
|
46
46
|
# instead of a timestamp.
|
47
47
|
def enqueue_in(number_of_seconds_from_now, klass, *args)
|
48
|
+
unless number_of_seconds_from_now.is_a?(Numeric)
|
49
|
+
raise ArgumentError, 'Please supply a numeric number of seconds'
|
50
|
+
end
|
48
51
|
enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
|
49
52
|
end
|
50
53
|
|
@@ -53,6 +56,9 @@ module Resque
|
|
53
56
|
# number of seconds has passed.
|
54
57
|
def enqueue_in_with_queue(queue, number_of_seconds_from_now,
|
55
58
|
klass, *args)
|
59
|
+
unless number_of_seconds_from_now.is_a?(Numeric)
|
60
|
+
raise ArgumentError, 'Please supply a numeric number of seconds'
|
61
|
+
end
|
56
62
|
enqueue_at_with_queue(queue, Time.now + number_of_seconds_from_now,
|
57
63
|
klass, *args)
|
58
64
|
end
|
data/lib/resque/scheduler/env.rb
CHANGED
@@ -43,7 +43,7 @@ module Resque
|
|
43
43
|
end
|
44
44
|
|
45
45
|
Process.daemon(true, !Resque::Scheduler.quiet)
|
46
|
-
Resque.redis.
|
46
|
+
Resque.redis._client.reconnect
|
47
47
|
end
|
48
48
|
|
49
49
|
def setup_pid_file
|
@@ -64,13 +64,13 @@ module Resque
|
|
64
64
|
|
65
65
|
c.dynamic = !!options[:dynamic] if options.key?(:dynamic)
|
66
66
|
|
67
|
-
c.env = options[:env] if options.key(:env)
|
67
|
+
c.env = options[:env] if options.key?(:env)
|
68
68
|
|
69
69
|
c.logfile = options[:logfile] if options.key?(:logfile)
|
70
70
|
|
71
71
|
c.logformat = options[:logformat] if options.key?(:logformat)
|
72
72
|
|
73
|
-
if psleep = options[:poll_sleep_amount] && !psleep.nil?
|
73
|
+
if (psleep = options[:poll_sleep_amount]) && !psleep.nil?
|
74
74
|
c.poll_sleep_amount = Float(psleep)
|
75
75
|
end
|
76
76
|
|
@@ -43,7 +43,7 @@ module Resque
|
|
43
43
|
@locked_sha = nil if refresh
|
44
44
|
|
45
45
|
@locked_sha ||=
|
46
|
-
Resque.redis.script(:load, <<-EOF.gsub(/^ {14}/, ''))
|
46
|
+
Resque.data_store.redis.script(:load, <<-EOF.gsub(/^ {14}/, ''))
|
47
47
|
if redis.call('GET', KEYS[1]) == ARGV[1]
|
48
48
|
then
|
49
49
|
redis.call('EXPIRE', KEYS[1], #{timeout})
|
@@ -62,7 +62,7 @@ module Resque
|
|
62
62
|
@acquire_sha = nil if refresh
|
63
63
|
|
64
64
|
@acquire_sha ||=
|
65
|
-
Resque.redis.script(:load, <<-EOF.gsub(/^ {14}/, ''))
|
65
|
+
Resque.data_store.redis.script(:load, <<-EOF.gsub(/^ {14}/, ''))
|
66
66
|
if redis.call('SETNX', KEYS[1], ARGV[1]) == 1
|
67
67
|
then
|
68
68
|
redis.call('EXPIRE', KEYS[1], #{timeout})
|
@@ -76,7 +76,7 @@ module Resque
|
|
76
76
|
|
77
77
|
def release_master_lock
|
78
78
|
master_lock.release
|
79
|
-
rescue
|
79
|
+
rescue *INTERMITTENT_ERRORS
|
80
80
|
@master_lock = nil
|
81
81
|
end
|
82
82
|
|
@@ -97,7 +97,7 @@ module Resque
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def redis_master_version
|
100
|
-
Resque.redis.info['redis_version'].to_f
|
100
|
+
Resque.data_store.redis.info['redis_version'].to_f
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -46,7 +46,7 @@
|
|
46
46
|
<td><%= h(show_job_arguments(job['args'])) if job && delayed_timestamp_size == 1 %></td>
|
47
47
|
<td>
|
48
48
|
<% if job %>
|
49
|
-
<a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
|
49
|
+
<a href="<%=u URI("/delayed/jobs/#{URI.escape(job['class'])}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
|
50
50
|
<% end %>
|
51
51
|
</td>
|
52
52
|
</tr>
|
data/resque-scheduler.gemspec
CHANGED
@@ -54,7 +54,7 @@ Gem::Specification.new do |spec|
|
|
54
54
|
spec.add_development_dependency 'rubocop', '~> 0.40.0'
|
55
55
|
|
56
56
|
spec.add_runtime_dependency 'mono_logger', '~> 1.0'
|
57
|
-
spec.add_runtime_dependency 'redis', '>= 3.3'
|
58
|
-
spec.add_runtime_dependency 'resque', '
|
57
|
+
spec.add_runtime_dependency 'redis', '>= 3.3'
|
58
|
+
spec.add_runtime_dependency 'resque', '>= 1.26'
|
59
59
|
spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2'
|
60
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-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
|
- Ben VandenBos
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -216,9 +216,6 @@ dependencies:
|
|
216
216
|
- - ">="
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '3.3'
|
219
|
-
- - "<"
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
version: '5'
|
222
219
|
type: :runtime
|
223
220
|
prerelease: false
|
224
221
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -226,21 +223,18 @@ dependencies:
|
|
226
223
|
- - ">="
|
227
224
|
- !ruby/object:Gem::Version
|
228
225
|
version: '3.3'
|
229
|
-
- - "<"
|
230
|
-
- !ruby/object:Gem::Version
|
231
|
-
version: '5'
|
232
226
|
- !ruby/object:Gem::Dependency
|
233
227
|
name: resque
|
234
228
|
requirement: !ruby/object:Gem::Requirement
|
235
229
|
requirements:
|
236
|
-
- - "
|
230
|
+
- - ">="
|
237
231
|
- !ruby/object:Gem::Version
|
238
232
|
version: '1.26'
|
239
233
|
type: :runtime
|
240
234
|
prerelease: false
|
241
235
|
version_requirements: !ruby/object:Gem::Requirement
|
242
236
|
requirements:
|
243
|
-
- - "
|
237
|
+
- - ">="
|
244
238
|
- !ruby/object:Gem::Version
|
245
239
|
version: '1.26'
|
246
240
|
- !ruby/object:Gem::Dependency
|
@@ -328,8 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
328
322
|
- !ruby/object:Gem::Version
|
329
323
|
version: '0'
|
330
324
|
requirements: []
|
331
|
-
|
332
|
-
rubygems_version: 2.6.8
|
325
|
+
rubygems_version: 3.0.3
|
333
326
|
signing_key:
|
334
327
|
specification_version: 4
|
335
328
|
summary: Light weight job scheduling on top of Resque
|