resque-population-control 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +17 -6
- data/lib/resque/plugins/population_control.rb +5 -1
- 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: 6d6da100902f1cead6fe811db755eb74f64250d2
|
4
|
+
data.tar.gz: ef21f31aa58b086329e16a1de942012b752a15d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54fe5f601db298ea06f860a24d9a00eef5192bf72f6e086f5e2eae7f954c033472a3af14a9e9aff9c55cc7de797275a7fd94d028f9f5ea2579736d586718ddd
|
7
|
+
data.tar.gz: ac7e9913d986c3eb6d4b444d59c90493c43abef298c47aac71500048c09cda7e4338f2f7b924ddbb3d49a1b7e571c094962783b07963384575138d4231dfcefc
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Population
|
1
|
+
# Resque Population Control!
|
2
2
|
|
3
|
-
|
3
|
+
Resque jobs getting out of hand? Bring them to order with this new resque plugin!
|
4
4
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'population-control'
|
12
|
+
gem 'resque-population-control'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,11 +18,22 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install population-control
|
21
|
+
$ gem install resque-population-control
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
The following examples limits Job to having at most 100 enqeueud or running instances.
|
26
|
+
|
27
|
+
class Job
|
28
|
+
extend Resque::Plugins::PopulationControl
|
29
|
+
population_control 100
|
30
|
+
|
31
|
+
@queue = :jobs
|
32
|
+
|
33
|
+
def self.perform(customer_id)
|
34
|
+
...
|
35
|
+
end
|
36
|
+
end
|
26
37
|
|
27
38
|
## Development
|
28
39
|
|
@@ -32,5 +43,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
43
|
|
33
44
|
## Contributing
|
34
45
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/MishaConway/resque-population-control
|
36
47
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Resque
|
2
2
|
module Plugins
|
3
3
|
module PopulationControl
|
4
|
-
VERSION = "0.
|
4
|
+
VERSION = "0.2.0"
|
5
5
|
|
6
6
|
class PopulationExceeded < ::StandardError; end;
|
7
7
|
|
@@ -9,6 +9,10 @@ module Resque
|
|
9
9
|
@population_control_max = max
|
10
10
|
end
|
11
11
|
|
12
|
+
def population_controlled?
|
13
|
+
population_control_redis.get(population_control_cache_key).to_i <= population_control_max
|
14
|
+
end
|
15
|
+
|
12
16
|
def before_enqueue *args
|
13
17
|
population_control_count = population_control_increment
|
14
18
|
if population_control_count > population_control_max
|