resque-scheduler 1.9.9 → 1.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +120 -0
- data/.travis.yml +10 -0
- data/Gemfile +2 -1
- data/HISTORY.md +5 -3
- data/Rakefile +31 -3
- data/lib/resque/scheduler.rb +4 -4
- data/lib/resque_scheduler.rb +23 -4
- data/lib/resque_scheduler/server.rb +5 -5
- data/lib/resque_scheduler/server/views/scheduler.erb +1 -1
- data/lib/resque_scheduler/tasks.rb +1 -1
- data/lib/resque_scheduler/version.rb +1 -1
- data/resque-scheduler.gemspec +26 -23
- data/test/delayed_queue_test.rb +32 -5
- data/test/redis-test.conf +1 -1
- data/test/resque-web_test.rb +1 -1
- data/test/scheduler_args_test.rb +1 -1
- data/test/scheduler_test.rb +1 -1
- data/test/test_helper.rb +8 -8
- metadata +139 -120
- data/Gemfile.lock +0 -52
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f0e55db383000283bc9f62c6f1426f08c413364
|
4
|
+
data.tar.gz: e9e155220dbf07b2af2f02d12350bedd15b96d92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23893a124cc859f8f9467d814252da43fb60096149a057b73fdf175c95def95dbcae3b94d002a05357cc4126eec316fd7a14d7c08af49559199ad23f8caa38bb
|
7
|
+
data.tar.gz: a34f09d54fe6127853e9c24e8dcbf1cea6c72b669a65940be84f7b039896ca55c08e638cfac302ee3b8bfeda2b57b5cced7584dc9ed741e173d195ddc2cf79cc
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`.
|
2
|
+
# The point is for the user to remove these configuration records
|
3
|
+
# one by one as the offences are removed from the code base.
|
4
|
+
|
5
|
+
AccessControl:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
AlignParameters:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
AssignmentInCondition:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
CaseEquality:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
ClassVars:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
CollectionMethods:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
ColonMethodCall:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
CommentAnnotation:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Documentation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
EmptyLines:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Encoding:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
FavorUnlessOverNegatedIf:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
FavorUntilOverNegatedWhile:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
HandleExceptions:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
HashSyntax:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
IfUnlessModifier:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
LineLength:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Loop:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
MethodCallParentheses:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
MethodLength:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
ModuleFunction:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
NumericLiterals:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
ParenthesesAroundCondition:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
PerlBackrefs:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
RedundantBegin:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
RescueException:
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
RescueModifier:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
SingleLineMethods:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
SpaceAfterComma:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
SpaceAroundBlockBraces:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
SpaceAroundEqualsInParameterDefault:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
SpaceAroundOperators:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
SpaceInsideHashLiteralBraces:
|
102
|
+
Enabled: false
|
103
|
+
|
104
|
+
SpecialGlobalVars:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
StringLiterals:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
TrailingBlankLines:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
TrailingWhitespace:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
TrivialAccessors:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
UselessAssignment:
|
120
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
##
|
1
|
+
## 1.9.10 (2013-09-19)
|
2
2
|
|
3
|
-
*
|
4
|
-
*
|
3
|
+
* Backported `#enqueue_at_with_queue`
|
4
|
+
* Locking to resque < 1.25.0
|
5
|
+
* Mocha setup compatibility
|
6
|
+
* Ruby 1.8 compatibility in scheduler tab when schedule keys are symbols
|
5
7
|
|
6
8
|
## 1.9.9 (2011-03-29)
|
7
9
|
|
data/Rakefile
CHANGED
@@ -1,13 +1,41 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler::GemHelper.install_tasks
|
1
|
+
require 'bundler/gem_tasks'
|
3
2
|
|
4
3
|
$LOAD_PATH.unshift 'lib'
|
5
4
|
|
6
5
|
task :default => :test
|
7
6
|
|
8
|
-
desc
|
7
|
+
desc 'Run tests'
|
9
8
|
task :test do
|
9
|
+
if RUBY_VERSION =~ /^1\.8/
|
10
|
+
unless ENV['SEED']
|
11
|
+
srand
|
12
|
+
ENV['SEED'] = (srand % 0xFFFF).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
$stdout.puts "Running with SEED=#{ENV['SEED']}"
|
16
|
+
srand Integer(ENV['SEED'])
|
17
|
+
elsif ENV['SEED']
|
18
|
+
ARGV += %W(--seed #{ENV['SEED']})
|
19
|
+
end
|
10
20
|
Dir['test/*_test.rb'].each do |f|
|
11
21
|
require File.expand_path(f)
|
12
22
|
end
|
13
23
|
end
|
24
|
+
|
25
|
+
desc 'Run rubocop'
|
26
|
+
task :rubocop do
|
27
|
+
unless RUBY_VERSION < '1.9'
|
28
|
+
sh('rubocop --config .rubocop.yml --format simple') { |r, _| r || abort }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
require 'rdoc/task'
|
34
|
+
|
35
|
+
Rake::RDocTask.new do |rd|
|
36
|
+
rd.main = 'README.md'
|
37
|
+
rd.rdoc_files.include('README.md', 'lib/**/*.rb')
|
38
|
+
rd.rdoc_dir = 'doc'
|
39
|
+
end
|
40
|
+
rescue LoadError
|
41
|
+
end
|
data/lib/resque/scheduler.rb
CHANGED
@@ -11,7 +11,7 @@ module Resque
|
|
11
11
|
|
12
12
|
# If true, logs more stuff...
|
13
13
|
attr_accessor :verbose
|
14
|
-
|
14
|
+
|
15
15
|
# If set, produces no output
|
16
16
|
attr_accessor :mute
|
17
17
|
|
@@ -39,7 +39,7 @@ module Resque
|
|
39
39
|
def register_signal_handlers
|
40
40
|
trap("TERM") { shutdown }
|
41
41
|
trap("INT") { shutdown }
|
42
|
-
|
42
|
+
|
43
43
|
begin
|
44
44
|
trap('QUIT') { shutdown }
|
45
45
|
trap('USR1') { kill_child }
|
@@ -96,7 +96,7 @@ module Resque
|
|
96
96
|
# continue processing until there are no more ready timestamps
|
97
97
|
end while !timestamp.nil?
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
# Enqueues all delayed jobs for a timestamp
|
101
101
|
def enqueue_delayed_items_for_timestamp(timestamp)
|
102
102
|
item = nil
|
@@ -140,7 +140,7 @@ module Resque
|
|
140
140
|
constantize(job_klass).scheduled(queue, klass_name, *params)
|
141
141
|
else
|
142
142
|
Resque::Job.create(queue, klass_name, *params)
|
143
|
-
end
|
143
|
+
end
|
144
144
|
rescue
|
145
145
|
log! "Failed to enqueue #{klass_name}:\n #{$!}"
|
146
146
|
end
|
data/lib/resque_scheduler.rb
CHANGED
@@ -18,7 +18,7 @@ module ResqueScheduler
|
|
18
18
|
#
|
19
19
|
# :name can be anything and is used only to describe the scheduled job
|
20
20
|
# :cron can be any cron scheduling string :job can be any resque job class
|
21
|
-
# :every can be used in lieu of :cron. see rufus-scheduler's 'every' usage for
|
21
|
+
# :every can be used in lieu of :cron. see rufus-scheduler's 'every' usage for
|
22
22
|
# valid syntax. If :cron is present it will take precedence over :every.
|
23
23
|
# :class must be a resque worker class
|
24
24
|
# :args can be any yaml which will be converted to a ruby literal and passed
|
@@ -45,12 +45,27 @@ module ResqueScheduler
|
|
45
45
|
delayed_push(timestamp, job_to_hash(klass, args))
|
46
46
|
end
|
47
47
|
|
48
|
+
# Identical to +enqueue_at+, except you can also specify
|
49
|
+
# a queue in which the job will be placed after the
|
50
|
+
# timestamp has passed.
|
51
|
+
def enqueue_at_with_queue(queue, timestamp, klass, *args)
|
52
|
+
validate_job!(klass)
|
53
|
+
delayed_push(timestamp, job_to_hash_with_queue(queue, klass, args))
|
54
|
+
end
|
55
|
+
|
48
56
|
# Identical to enqueue_at but takes number_of_seconds_from_now
|
49
57
|
# instead of a timestamp.
|
50
58
|
def enqueue_in(number_of_seconds_from_now, klass, *args)
|
51
59
|
enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
|
52
60
|
end
|
53
61
|
|
62
|
+
# Identical to +enqueue_in+, except you can also specify
|
63
|
+
# a queue in which the job will be placed after the
|
64
|
+
# number of seconds has passed.
|
65
|
+
def enqueue_in_with_queue(queue, number_of_seconds_from_now, klass, *args)
|
66
|
+
enqueue_at_with_queue(queue, Time.now + number_of_seconds_from_now, klass, *args)
|
67
|
+
end
|
68
|
+
|
54
69
|
# Used internally to stuff the item into the schedule sorted list.
|
55
70
|
# +timestamp+ can be either in seconds or a datetime object
|
56
71
|
# Insertion if O(log(n)).
|
@@ -131,18 +146,22 @@ module ResqueScheduler
|
|
131
146
|
end
|
132
147
|
|
133
148
|
def count_all_scheduled_jobs
|
134
|
-
total_jobs = 0
|
149
|
+
total_jobs = 0
|
135
150
|
Array(redis.zrange(:delayed_queue_schedule, 0, -1)).each do |timestamp|
|
136
151
|
total_jobs += redis.llen("delayed:#{timestamp}").to_i
|
137
|
-
end
|
152
|
+
end
|
138
153
|
total_jobs
|
139
|
-
end
|
154
|
+
end
|
140
155
|
|
141
156
|
private
|
142
157
|
def job_to_hash(klass, args)
|
143
158
|
{:class => klass.to_s, :args => args, :queue => queue_from_class(klass)}
|
144
159
|
end
|
145
160
|
|
161
|
+
def job_to_hash_with_queue(queue, klass, args)
|
162
|
+
{:class => klass.to_s, :args => args, :queue => queue}
|
163
|
+
end
|
164
|
+
|
146
165
|
def clean_up_timestamp(key, timestamp)
|
147
166
|
# If the list is empty, remove it.
|
148
167
|
if 0 == redis.llen(key).to_i
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
# Extend Resque::Server to add tabs
|
3
3
|
module ResqueScheduler
|
4
|
-
|
4
|
+
|
5
5
|
module Server
|
6
6
|
|
7
7
|
def self.included(base)
|
@@ -28,7 +28,7 @@ module ResqueScheduler
|
|
28
28
|
Resque::Scheduler.enqueue_from_config(config)
|
29
29
|
redirect u("/overview")
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
get "/delayed" do
|
33
33
|
# Is there a better way to specify alternate template locations with sinatra?
|
34
34
|
erb File.read(File.join(File.dirname(__FILE__), 'server/views/delayed.erb'))
|
@@ -38,7 +38,7 @@ module ResqueScheduler
|
|
38
38
|
# Is there a better way to specify alternate template locations with sinatra?
|
39
39
|
erb File.read(File.join(File.dirname(__FILE__), 'server/views/delayed_timestamp.erb'))
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
post "/delayed/queue_now" do
|
43
43
|
timestamp = params['timestamp']
|
44
44
|
Resque::Scheduler.enqueue_delayed_items_for_timestamp(timestamp.to_i) if timestamp.to_i > 0
|
@@ -53,5 +53,5 @@ module ResqueScheduler
|
|
53
53
|
Resque::Server.tabs << 'Delayed'
|
54
54
|
|
55
55
|
end
|
56
|
-
|
57
|
-
end
|
56
|
+
|
57
|
+
end
|
data/resque-scheduler.gemspec
CHANGED
@@ -1,29 +1,32 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'resque_scheduler/version'
|
3
5
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
s.description = %q{Light weight job scheduling on top of Resque.
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'resque-scheduler'
|
8
|
+
spec.version = ResqueScheduler::VERSION
|
9
|
+
spec.authors = ['Ben VandenBos']
|
10
|
+
spec.email = ['bvandenbos@gmail.com']
|
11
|
+
spec.homepage = 'http://github.com/resque/resque-scheduler'
|
12
|
+
spec.summary = 'Light weight job scheduling on top of Resque'
|
13
|
+
spec.description = %q{Light weight job scheduling on top of Resque.
|
13
14
|
Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
|
14
15
|
Also supports queueing jobs on a fixed, cron-like schedule.}
|
15
|
-
|
16
|
-
s.required_rubygems_version = ">= 1.3.6"
|
17
|
-
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
spec.files = `git ls-files`.split("\n")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^test/})
|
20
|
+
spec.require_path = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'mocha'
|
24
|
+
spec.add_development_dependency 'rack-test'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'json' if RUBY_VERSION < '1.9'
|
27
|
+
spec.add_development_dependency 'rubocop' unless RUBY_VERSION < '1.9'
|
28
|
+
|
29
|
+
spec.add_runtime_dependency 'redis', '>= 2.0.1'
|
30
|
+
spec.add_runtime_dependency 'resque', ['>= 1.8.0', '< 1.25.0']
|
31
|
+
spec.add_runtime_dependency 'rufus-scheduler', '>= 0'
|
29
32
|
end
|
data/test/delayed_queue_test.rb
CHANGED
@@ -28,7 +28,34 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
28
28
|
# Confirm the item came out correctly
|
29
29
|
assert_equal('SomeIvarJob', item['class'], "Should be the same class that we queued")
|
30
30
|
assert_equal(["path"], item['args'], "Should have the same arguments that we queued")
|
31
|
-
|
31
|
+
|
32
|
+
# And now confirm the keys are gone
|
33
|
+
assert(!Resque.redis.exists("delayed:#{timestamp.to_i}"))
|
34
|
+
assert_equal(0, Resque.redis.zcard(:delayed_queue_schedule), "delayed queue should be empty")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_enqueue_at_with_queue_inserts_into_correct_queue
|
38
|
+
timestamp = Time.now - 1 # 1 second ago (in the past, should come out right away)
|
39
|
+
|
40
|
+
assert_equal(0, Resque.redis.llen("delayed:#{timestamp.to_i}").to_i, "delayed queue should be empty to start")
|
41
|
+
|
42
|
+
Resque.enqueue_at_with_queue("critical", timestamp, SomeIvarJob, "path")
|
43
|
+
|
44
|
+
# Confirm the correct keys were added
|
45
|
+
assert_equal(1, Resque.redis.llen("delayed:#{timestamp.to_i}").to_i, "delayed queue should have one entry now")
|
46
|
+
assert_equal(1, Resque.redis.zcard(:delayed_queue_schedule), "The delayed_queue_schedule should have 1 entry now")
|
47
|
+
|
48
|
+
read_timestamp = Resque.next_delayed_timestamp
|
49
|
+
|
50
|
+
# Confirm the timestamp came out correctly
|
51
|
+
assert_equal(timestamp.to_i, read_timestamp, "The timestamp we pull out of redis should match the one we put in")
|
52
|
+
item = Resque.next_item_for_timestamp(read_timestamp)
|
53
|
+
|
54
|
+
# Confirm the item came out correctly
|
55
|
+
assert_equal('SomeIvarJob', item['class'], "Should be the same class that we queued")
|
56
|
+
assert_equal(["path"], item['args'], "Should have the same arguments that we queued")
|
57
|
+
assert_equal('critical', item['queue'], "Should have the queue that we asked for")
|
58
|
+
|
32
59
|
# And now confirm the keys are gone
|
33
60
|
assert(!Resque.redis.exists("delayed:#{timestamp.to_i}"))
|
34
61
|
assert_equal(0, Resque.redis.zcard(:delayed_queue_schedule), "delayed queue should be empty")
|
@@ -141,10 +168,10 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
141
168
|
Resque.expects(:queue_from_class).never # Should NOT need to load the class
|
142
169
|
Resque::Scheduler.handle_delayed_items(t)
|
143
170
|
end
|
144
|
-
|
171
|
+
|
145
172
|
def test_enqueue_delayed_items_for_timestamp
|
146
173
|
t = Time.now + 60
|
147
|
-
|
174
|
+
|
148
175
|
Resque.enqueue_at(t, SomeIvarJob)
|
149
176
|
Resque.enqueue_at(t, SomeIvarJob)
|
150
177
|
|
@@ -153,7 +180,7 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
153
180
|
Resque.expects(:queue_from_class).never # Should NOT need to load the class
|
154
181
|
|
155
182
|
Resque::Scheduler.enqueue_delayed_items_for_timestamp(t)
|
156
|
-
|
183
|
+
|
157
184
|
# delayed queue for timestamp should be empty
|
158
185
|
assert_equal(0, Resque.delayed_timestamp_peek(t, 0, 3).length)
|
159
186
|
end
|
@@ -206,7 +233,7 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
206
233
|
assert_equal(2, Resque.remove_delayed(SomeIvarJob, "bar"))
|
207
234
|
assert_equal(1, Resque.delayed_queue_schedule_size)
|
208
235
|
end
|
209
|
-
|
236
|
+
|
210
237
|
def test_remove_specific_item_in_group_of_other_items_at_different_timestamps
|
211
238
|
t = Time.now + 120
|
212
239
|
Resque.enqueue_at(t, SomeIvarJob, "foo")
|
data/test/redis-test.conf
CHANGED
@@ -112,4 +112,4 @@ databases 16
|
|
112
112
|
# Glue small output buffers together in order to send small replies in a
|
113
113
|
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
114
114
|
# in terms of number of queries per second. Use 'yes' if unsure.
|
115
|
-
glueoutputbuf yes
|
115
|
+
# glueoutputbuf yes
|
data/test/resque-web_test.rb
CHANGED
@@ -10,7 +10,7 @@ context "on GET to /schedule" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context "on GET to /schedule with scheduled jobs" do
|
13
|
-
setup do
|
13
|
+
setup do
|
14
14
|
ENV['rails_env'] = 'production'
|
15
15
|
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp", 'rails_env' => 'production'},
|
16
16
|
:some_other_job => {'queue' => 'high', 'class' => 'SomeOtherJob', 'args' => {:b => 'blah'}}}
|
data/test/scheduler_args_test.rb
CHANGED
@@ -14,7 +14,7 @@ context "scheduling jobs with arguments" do
|
|
14
14
|
test "calls the worker without arguments when 'args' is blank in the config" do
|
15
15
|
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
16
16
|
class: SomeIvarJob
|
17
|
-
args:
|
17
|
+
args:
|
18
18
|
YAML
|
19
19
|
SomeIvarJob.expects(:perform).once.with()
|
20
20
|
Resque.reserve('ivar').perform
|
data/test/scheduler_test.rb
CHANGED
@@ -29,7 +29,7 @@ class Resque::SchedulerTest < Test::Unit::TestCase
|
|
29
29
|
Resque::Job.stubs(:create).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
|
30
30
|
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp")
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def test_enqueue_from_config_with_custom_class_job_in_the_resque_queue
|
34
34
|
FakeJob.stubs(:scheduled).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
|
35
35
|
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'custom_job_class' => 'Resque::SchedulerTest::FakeJob', 'args' => "/tmp")
|
data/test/test_helper.rb
CHANGED
@@ -6,7 +6,7 @@ dir = File.dirname(File.expand_path(__FILE__))
|
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
8
|
require 'test/unit'
|
9
|
-
require 'mocha'
|
9
|
+
require 'mocha/setup'
|
10
10
|
require 'resque'
|
11
11
|
require File.join(dir, '../lib/resque_scheduler')
|
12
12
|
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'
|
@@ -39,11 +39,11 @@ at_exit do
|
|
39
39
|
|
40
40
|
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
|
41
41
|
puts "Killing test redis server..."
|
42
|
-
`rm -f #{dir}/dump.rdb`
|
43
42
|
Process.kill("KILL", pid.to_i)
|
44
43
|
exit exit_code
|
45
44
|
end
|
46
45
|
|
46
|
+
`rm -f #{dir}/dump.rdb`
|
47
47
|
puts "Starting redis for testing at localhost:9736..."
|
48
48
|
`redis-server #{dir}/redis-test.conf`
|
49
49
|
Resque.redis = 'localhost:9736'
|
@@ -59,13 +59,13 @@ def context(*args, &block)
|
|
59
59
|
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
|
60
60
|
def self.test(name, &block)
|
61
61
|
define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
|
62
|
-
end
|
63
|
-
def self.xtest(*args) end
|
64
|
-
def self.setup(&block) define_method(:setup, &block) end
|
65
|
-
def self.teardown(&block) define_method(:teardown, &block) end
|
66
|
-
end
|
62
|
+
end
|
63
|
+
def self.xtest(*args) end
|
64
|
+
def self.setup(&block) define_method(:setup, &block) end
|
65
|
+
def self.teardown(&block) define_method(:teardown, &block) end
|
66
|
+
end
|
67
67
|
(class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
|
68
|
-
klass.class_eval
|
68
|
+
klass.class_eval(&block)
|
69
69
|
end
|
70
70
|
|
71
71
|
class SomeJob
|
metadata
CHANGED
@@ -1,122 +1,147 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-scheduler
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 9
|
8
|
-
- 9
|
9
|
-
version: 1.9.9
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.9.10
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Ben VandenBos
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocha
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
33
34
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: redis
|
37
35
|
prerelease: false
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack-test
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: redis
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
47
89
|
version: 2.0.1
|
48
90
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: resque
|
52
91
|
prerelease: false
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: resque
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
62
103
|
version: 1.8.0
|
104
|
+
- - <
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.25.0
|
63
107
|
type: :runtime
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: rufus-scheduler
|
67
108
|
prerelease: false
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
version:
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 1.8.0
|
114
|
+
- - <
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.25.0
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rufus-scheduler
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
76
124
|
type: :runtime
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: mocha
|
80
|
-
prerelease: false
|
81
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
|
-
requirements:
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
segments:
|
87
|
-
- 0
|
88
|
-
version: "0"
|
89
|
-
type: :development
|
90
|
-
version_requirements: *id005
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: rack-test
|
93
125
|
prerelease: false
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
segments:
|
100
|
-
- 0
|
101
|
-
version: "0"
|
102
|
-
type: :development
|
103
|
-
version_requirements: *id006
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
104
131
|
description: |-
|
105
132
|
Light weight job scheduling on top of Resque.
|
106
133
|
Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
|
107
134
|
Also supports queueing jobs on a fixed, cron-like schedule.
|
108
|
-
email:
|
135
|
+
email:
|
109
136
|
- bvandenbos@gmail.com
|
110
137
|
executables: []
|
111
|
-
|
112
138
|
extensions: []
|
113
|
-
|
114
139
|
extra_rdoc_files: []
|
115
|
-
|
116
|
-
files:
|
140
|
+
files:
|
117
141
|
- .gitignore
|
142
|
+
- .rubocop.yml
|
143
|
+
- .travis.yml
|
118
144
|
- Gemfile
|
119
|
-
- Gemfile.lock
|
120
145
|
- HISTORY.md
|
121
146
|
- LICENSE
|
122
147
|
- README.markdown
|
@@ -137,39 +162,33 @@ files:
|
|
137
162
|
- test/scheduler_args_test.rb
|
138
163
|
- test/scheduler_test.rb
|
139
164
|
- test/test_helper.rb
|
140
|
-
|
141
|
-
homepage: http://github.com/bvandenbos/resque-scheduler
|
165
|
+
homepage: http://github.com/resque/resque-scheduler
|
142
166
|
licenses: []
|
143
|
-
|
167
|
+
metadata: {}
|
144
168
|
post_install_message:
|
145
169
|
rdoc_options: []
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
none: false
|
159
|
-
requirements:
|
160
|
-
- - ">="
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
segments:
|
163
|
-
- 1
|
164
|
-
- 3
|
165
|
-
- 6
|
166
|
-
version: 1.3.6
|
170
|
+
require_paths:
|
171
|
+
- - lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
167
182
|
requirements: []
|
168
|
-
|
169
183
|
rubyforge_project:
|
170
|
-
rubygems_version:
|
184
|
+
rubygems_version: 2.0.3
|
171
185
|
signing_key:
|
172
|
-
specification_version:
|
186
|
+
specification_version: 4
|
173
187
|
summary: Light weight job scheduling on top of Resque
|
174
|
-
test_files:
|
175
|
-
|
188
|
+
test_files:
|
189
|
+
- test/delayed_queue_test.rb
|
190
|
+
- test/redis-test.conf
|
191
|
+
- test/resque-web_test.rb
|
192
|
+
- test/scheduler_args_test.rb
|
193
|
+
- test/scheduler_test.rb
|
194
|
+
- test/test_helper.rb
|
data/Gemfile.lock
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
resque-scheduler (1.9.7)
|
5
|
-
redis (>= 2.0.1)
|
6
|
-
resque (>= 1.8.0)
|
7
|
-
rufus-scheduler
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: http://rubygems.org/
|
11
|
-
specs:
|
12
|
-
git (1.2.5)
|
13
|
-
jeweler (1.5.1)
|
14
|
-
bundler (~> 1.0.0)
|
15
|
-
git (>= 1.2.5)
|
16
|
-
rake
|
17
|
-
json (1.4.6)
|
18
|
-
mocha (0.9.9)
|
19
|
-
rake
|
20
|
-
rack (1.2.1)
|
21
|
-
rack-test (0.5.6)
|
22
|
-
rack (>= 1.0)
|
23
|
-
rake (0.8.7)
|
24
|
-
redis (2.1.1)
|
25
|
-
redis-namespace (0.8.0)
|
26
|
-
redis (< 3.0.0)
|
27
|
-
resque (1.10.0)
|
28
|
-
json (~> 1.4.6)
|
29
|
-
redis-namespace (~> 0.8.0)
|
30
|
-
sinatra (>= 0.9.2)
|
31
|
-
vegas (~> 0.1.2)
|
32
|
-
rufus-scheduler (2.0.7)
|
33
|
-
tzinfo
|
34
|
-
sinatra (1.1.0)
|
35
|
-
rack (~> 1.1)
|
36
|
-
tilt (~> 1.1)
|
37
|
-
tilt (1.1)
|
38
|
-
tzinfo (0.3.23)
|
39
|
-
vegas (0.1.8)
|
40
|
-
rack (>= 1.0.0)
|
41
|
-
|
42
|
-
PLATFORMS
|
43
|
-
ruby
|
44
|
-
|
45
|
-
DEPENDENCIES
|
46
|
-
jeweler
|
47
|
-
mocha
|
48
|
-
rack-test
|
49
|
-
redis (>= 2.0.1)
|
50
|
-
resque (>= 1.8.0)
|
51
|
-
resque-scheduler!
|
52
|
-
rufus-scheduler
|