resque-population-control 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resque/plugins/population_control.rb +10 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea47539d34c221eefa4ef20c569bc0720eaa4ce1
|
4
|
+
data.tar.gz: b5fb7db383b5a98cc72c3c0c8820aa2178d56668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 107c994c9fead4b480605583aa8d9ae61a641e0164e30b0920cff849ded7ec3b96e08b18a4a2ec4230d4648be580739a6bcbd73eae13441e387d1cfbb58ea7c0
|
7
|
+
data.tar.gz: 7edd7ae9f35c7280ef2a2fe23dab1306fcd980b2de992aa9da57627eb473ff1e275a52af7621f391e26f87e8b1b34c06ebb965ccdbbbcb570daddd7847906a83
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Resque
|
2
2
|
module Plugins
|
3
3
|
module PopulationControl
|
4
|
-
VERSION = "0.
|
4
|
+
VERSION = "0.5.0"
|
5
5
|
|
6
6
|
class PopulationExceeded < ::StandardError; end;
|
7
7
|
|
@@ -11,7 +11,11 @@ module Resque
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def population_controlled?
|
14
|
-
|
14
|
+
population_control_count <= population_control_max
|
15
|
+
end
|
16
|
+
|
17
|
+
def max_population?
|
18
|
+
population_control_count >= population_control_max
|
15
19
|
end
|
16
20
|
|
17
21
|
def before_enqueue *args
|
@@ -44,6 +48,10 @@ module Resque
|
|
44
48
|
population_control_redis.set population_control_cache_key, 0 if population_control_redis.decr(population_control_cache_key) <= 0
|
45
49
|
end
|
46
50
|
|
51
|
+
def population_control_count
|
52
|
+
population_control_redis.get(population_control_cache_key).to_i
|
53
|
+
end
|
54
|
+
|
47
55
|
def population_control_redis
|
48
56
|
@population_control_redis ||= Resque.redis.redis
|
49
57
|
end
|