resque-throttle 0.2.6 → 0.2.7
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.
- data/VERSION +1 -1
- data/lib/resque/throttled_job.rb +9 -8
- data/resque-throttle.gemspec +1 -1
- data/test/resque/throttled_job_test.rb +1 -2
- data/test/test_helper.rb +6 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/lib/resque/throttled_job.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Resque
|
2
|
+
class SettingNotFound < RuntimeError; end
|
3
|
+
|
2
4
|
class ThrottledJob
|
3
5
|
|
4
6
|
THROTTLE_DEFAULTS = {
|
5
7
|
:can_run_every => 1800,
|
6
8
|
:disabled => false,
|
7
|
-
:identifier => nil
|
8
9
|
}
|
9
10
|
|
10
11
|
def self.settings
|
@@ -15,20 +16,20 @@ module Resque
|
|
15
16
|
settings.merge!(args)
|
16
17
|
end
|
17
18
|
|
18
|
-
def self.
|
19
|
-
|
19
|
+
def self.identifier(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.key(*args)
|
23
|
+
[self.to_s, identifier(*args)].compact.join(":")
|
20
24
|
end
|
21
25
|
|
22
26
|
def self.can_run_every
|
23
27
|
settings[:can_run_every]
|
24
28
|
end
|
25
|
-
|
29
|
+
|
26
30
|
def self.disabled
|
27
31
|
settings[:disabled]
|
28
32
|
end
|
29
|
-
|
30
|
-
def self.identifier
|
31
|
-
settings[:identifier]
|
32
|
-
end
|
33
|
+
|
33
34
|
end
|
34
35
|
end
|
data/resque-throttle.gemspec
CHANGED
@@ -7,8 +7,7 @@ class ThrottledJobTest < Test::Unit::TestCase
|
|
7
7
|
assert Resque::ThrottledJob.new
|
8
8
|
end
|
9
9
|
|
10
|
-
context "settings
|
11
|
-
|
10
|
+
context "settings" do
|
12
11
|
context "#can_run_every" do
|
13
12
|
should "return the number of seconds in which to throttle these jobs" do
|
14
13
|
assert_equal 3600, OneHourThrottledJob.can_run_every
|
data/test/test_helper.rb
CHANGED
@@ -30,10 +30,15 @@ end
|
|
30
30
|
|
31
31
|
class IdetifierThrottledJob < Resque::ThrottledJob
|
32
32
|
@queue = :some_queue
|
33
|
-
|
33
|
+
|
34
|
+
throttle :can_run_every => 3600
|
34
35
|
|
35
36
|
def self.perform(some_id, some_other_thing)
|
36
37
|
end
|
38
|
+
|
39
|
+
def self.identifier(*args)
|
40
|
+
"my_identifier"
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
class DisabledThrottledJob < Resque::ThrottledJob
|