Permalink
Browse files

rename identifier to restriction_identifier to solve the confliction …

…with resque-retry
  • Loading branch information...
1 parent 7197875 commit 3de3f9a4d1a9034d8940ab197d1275c56d18e60d @flyerhzm committed Nov 4, 2010
View
@@ -1,4 +1,5 @@
spec/dump.rdb
pkg/**
.idea
+.rvmrc
View
@@ -0,0 +1,2 @@
+rvm_gemset_create_on_use_flag=1
+rvm gemset use resque-restriction
View
@@ -9,6 +9,11 @@ Resque Restriction is a plugin for the [Resque][0] queueing system (http://githu
Resque Restriction requires Resque 1.7.0.
+Attention
+---------
+
+The <code>identifier</code> method is renamed to <code>restriction_identifier</code> to solve the confliction with resque-retry from version 0.3.0.
+
Install
-------
@@ -37,14 +42,14 @@ You can also add customized restriction as you like. For example, we have a job
class GenerateFacebookShares < Resque::Plugins::RestrictionJob
restrict :per_day => 40
- def self.identifier(options)
+ def self.restriction_identifier(options)
[self.to_s, options["user_id"]].join(":")
end
#rest of your class here
end
-options["user_id"] returns the user's facebook uid, the key point is that the different identifiers can restrict different job execution numbers.
+options["user_id"] returns the user's facebook uid, the key point is that the different restriction_identifiers can restrict different job execution numbers.
Contributing
------------
@@ -66,10 +66,10 @@ def redis_key(period, *args)
when :per_month then Date.today.strftime("%Y-%m")
when :per_year then Date.today.year.to_s
else period.to_s =~ /^per_(\d+)$/ and (Time.now.to_i / $1.to_i).to_s end
- [self.identifier(*args), period_str].compact.join(":")
+ [self.restriction_identifier(*args), period_str].compact.join(":")
end
- def identifier(*args)
+ def restriction_identifier(*args)
self.to_s
end
@@ -42,7 +42,7 @@
Resque.redis.get(OneHourRestrictionJob.redis_key(:per_hour)).should == "9"
end
- it "should use identifier to set exclusive execution counts" do
+ it "should use restriction_identifier to set exclusive execution counts" do
result = perform_job(IdentifiedRestrictionJob, 1)
result.should be_true
result = perform_job(IdentifiedRestrictionJob, 1)
View
@@ -71,7 +71,7 @@ class IdentifiedRestrictionJob < Resque::Plugins::RestrictionJob
@queue = 'normal'
- def self.identifier(*args)
+ def self.restriction_identifier(*args)
[self.to_s, args.first].join(":")
end

0 comments on commit 3de3f9a

Please sign in to comment.