resque-population-control 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3668a6357c5d4ece7b9d781fad1fc15164c2feee
4
- data.tar.gz: 1576f53cceceed287aecbea7066e586d1c245a80
3
+ metadata.gz: 6d6da100902f1cead6fe811db755eb74f64250d2
4
+ data.tar.gz: ef21f31aa58b086329e16a1de942012b752a15d3
5
5
  SHA512:
6
- metadata.gz: c7d65ade5ae4562bc6fb03c25eb9f4ae6ce7e39c2f7bee31057ecfbe660ceeaf8f02ee59fae3012fa471a6d807fa386c8c28d24478f6a7ae976b16b1416bcf35
7
- data.tar.gz: 26e7a42af657cb439887cd73bef2e106f684878a23b3ad6050ce12a75d5355f41b0b996340d6918ed3b3aa2c0d651fc0036fc57a835d5fea44f7e41ab219809f
6
+ metadata.gz: e54fe5f601db298ea06f860a24d9a00eef5192bf72f6e086f5e2eae7f954c033472a3af14a9e9aff9c55cc7de797275a7fd94d028f9f5ea2579736d586718ddd
7
+ data.tar.gz: ac7e9913d986c3eb6d4b444d59c90493c43abef298c47aac71500048c09cda7e4338f2f7b924ddbb3d49a1b7e571c094962783b07963384575138d4231dfcefc
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Population::Control
1
+ # Resque Population Control!
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/population/control`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[USERNAME]/population-control.
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.1.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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-population-control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Misha Conway