resque-throttle 0.2.18 → 0.2.19
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/README.markdown +66 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/resque-throttle.gemspec +7 -7
- metadata +6 -6
- data/README.rdoc +0 -17
data/README.markdown
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
resque-throttle
|
2
|
+
===============
|
3
|
+
|
4
|
+
Resque Throttle is a plugin for the [Resque][0] queueing system
|
5
|
+
(http://github.com/defunkt/resque). It adds a ThrottledJob class that will
|
6
|
+
limit the amount of times it can be enqueued per class.
|
7
|
+
|
8
|
+
To use
|
9
|
+
------
|
10
|
+
The job you wish to throttle should inherit from the Resque::ThrottledJob class.
|
11
|
+
|
12
|
+
In your class, add the can_run_every in which the job should be throttled. Example:
|
13
|
+
|
14
|
+
class MyThrottledJob < Resque::ThrottledJob
|
15
|
+
throttle :can_run_every => 24.hours
|
16
|
+
|
17
|
+
#rest of your class here
|
18
|
+
end
|
19
|
+
|
20
|
+
By default, the key which identifies the job is simply the class name. This "identifier"
|
21
|
+
is stored in a redis key with a TTL equal to that of the can_run_every. Thus the
|
22
|
+
default behavior is a single Job class inheriting from Resque::ThrottledJob can only
|
23
|
+
run every 30 minutes.
|
24
|
+
|
25
|
+
If you'd like to override that to be more granular, you can do that in the identifier class method
|
26
|
+
by returning a string. For example, if you want the job to be limited to once a day per
|
27
|
+
account, do something like the following:
|
28
|
+
|
29
|
+
class MyThrottledJob < Resque::ThrottledJob
|
30
|
+
throttle :can_run_every => 24.hours
|
31
|
+
|
32
|
+
def self.identifier(*args)
|
33
|
+
account_id = *args
|
34
|
+
"account_id:#{account_id}"
|
35
|
+
end
|
36
|
+
|
37
|
+
#rest of your class here
|
38
|
+
end
|
39
|
+
|
40
|
+
The *args passed to identifier are the same arguments that are passed to perform.
|
41
|
+
|
42
|
+
When a job is throttled, it will raise a ThrottledError and the job will not be enqueued.
|
43
|
+
|
44
|
+
Contributing
|
45
|
+
------------
|
46
|
+
|
47
|
+
Once you've made your commits:
|
48
|
+
|
49
|
+
1. [Fork][1] Resque Throttle
|
50
|
+
2. Create a topic branch - `git checkout -b my_branch`
|
51
|
+
3. Push to your branch - `git push origin my_branch`
|
52
|
+
4. Create an [Issue][2] with a link to your branch
|
53
|
+
5. That's it!
|
54
|
+
|
55
|
+
Author
|
56
|
+
------
|
57
|
+
Scott J. Tamosunas :: tamosunas@gmail.com :: @scotttam
|
58
|
+
|
59
|
+
Copyright
|
60
|
+
---------
|
61
|
+
Copyright (c) 2010 Zendesk. See LICENSE for details.
|
62
|
+
|
63
|
+
[0]: http://github.com/defunkt/resque
|
64
|
+
[1]: http://help.github.com/forking/
|
65
|
+
[2]: http://github.com/scotttam/resque-throttle/issues
|
66
|
+
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
gem.email = "tamosunas@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/scotttam/resque-throttle"
|
12
12
|
gem.authors = ["Scott J. Tamosunas"]
|
13
|
-
gem.add_dependency "
|
13
|
+
gem.add_dependency "resque", ">=1.6.0"
|
14
14
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
15
|
gem.add_development_dependency "mocha", ">=0.9.8"
|
16
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.19
|
data/resque-throttle.gemspec
CHANGED
@@ -5,22 +5,22 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{resque-throttle}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.19"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott J. Tamosunas"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-10}
|
13
13
|
s.description = %q{resque-throttle is an extension to the resque queue system that restricts the frequency in which certain jobs are run. Add more description here.}
|
14
14
|
s.email = %q{tamosunas@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.
|
17
|
+
"README.markdown"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
22
|
"LICENSE",
|
23
|
-
"README.
|
23
|
+
"README.markdown",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/resque-throttle.rb",
|
@@ -48,16 +48,16 @@ Gem::Specification.new do |s|
|
|
48
48
|
s.specification_version = 3
|
49
49
|
|
50
50
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
|
-
s.add_runtime_dependency(%q<
|
51
|
+
s.add_runtime_dependency(%q<resque>, [">= 1.6.0"])
|
52
52
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
53
53
|
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
54
54
|
else
|
55
|
-
s.add_dependency(%q<
|
55
|
+
s.add_dependency(%q<resque>, [">= 1.6.0"])
|
56
56
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
57
57
|
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
58
58
|
end
|
59
59
|
else
|
60
|
-
s.add_dependency(%q<
|
60
|
+
s.add_dependency(%q<resque>, [">= 1.6.0"])
|
61
61
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
62
62
|
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
63
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott J. Tamosunas
|
@@ -9,18 +9,18 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-10 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: resque
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 1.6.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thoughtbot-shoulda
|
@@ -50,12 +50,12 @@ extensions: []
|
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
52
|
- LICENSE
|
53
|
-
- README.
|
53
|
+
- README.markdown
|
54
54
|
files:
|
55
55
|
- .document
|
56
56
|
- .gitignore
|
57
57
|
- LICENSE
|
58
|
-
- README.
|
58
|
+
- README.markdown
|
59
59
|
- Rakefile
|
60
60
|
- VERSION
|
61
61
|
- lib/resque-throttle.rb
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
= resque-throttle
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Note on Patches/Pull Requests
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2010 Zendesk. See LICENSE for details.
|