Skip to content

Commit 1d13a1b

Browse files
committed
Merge pull request #11 from wr0ngway/fix_up_readme
Clean up the readme
2 parents b1e95a6 + 6b7bf98 commit 1d13a1b

1 file changed

Lines changed: 46 additions & 31 deletions

File tree

README.md

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,67 @@
1-
resque-concurrent-restriction
2-
===============
1+
# resque-concurrent-restriction
32

4-
Resque Concurrent Restriction is a plugin for the [Resque][0] queueing system (http://github.com/defunkt/resque). It allows one to specify how many of the given job can run concurrently.
3+
Resque Concurrent Restriction is a plugin for the [Resque][0] queueing system. It allows one to specify how many of the given job can run concurrently.
54

65
Resque Concurrent Restriction requires Resque 1.25 and redis 2.2
76

8-
[![Build Status](https://secure.travis-ci.org/wr0ngway/resque-concurrent-restriction.png)](http://travis-ci.org/wr0ngway/resque-concurrent-restriction)
7+
[![Build Status](https://circleci.com/gh/russCloak/resque-concurrent-restriction.png?style=shield)](http://travis-ci.org/russCloak/resque-concurrent-restriction)
98

10-
Install
11-
-------
9+
## Install
1210

13-
sudo gem install resque-concurrent-restriction
11+
Install it from the command-line:
1412

15-
To use
16-
------
13+
```bash
14+
gem install resque-concurrent-restriction
15+
```
1716

18-
It is especially useful when a system has intensive jobs for which you should only run a few at a time. What you should do for the IntensiveJob is to make it extend Resque::Plugins::ConcurrentRestriction and specify the concurrent limit (defaults to 1). For example:
17+
or add it to your `Gemfile`:
1918

20-
class IntensiveJob
21-
extend Resque::Plugins::ConcurrentRestriction
22-
concurrent 4
23-
24-
#rest of your class here
25-
end
19+
```ruby
20+
gem 'resque-concurrent-restriction', '~> 0.6'
21+
```
2622

27-
That means the IntensiveJob can not have more than 4 jobs running simultaneously
23+
## To use
2824

29-
One can also make the concurrency limit depend on the parameters of a job, for example, if you always pass a user_id as the first param, you can restrict the job to run N concurrent jobs per user:
25+
It is especially useful when a system has intensive jobs for which you should only run a few at a time. What you should do for the IntensiveJob is to make it extend Resque::Plugins::ConcurrentRestriction and specify the concurrent limit (defaults to 1). For example:
3026

31-
class IntensiveJob
32-
extend Resque::Plugins::ConcurrentRestriction
33-
concurrent 4
27+
```ruby
28+
class IntensiveJob
29+
extend Resque::Plugins::ConcurrentRestriction
30+
concurrent 4
3431

35-
def self.concurrent_identifier(*args)
36-
args.first.to_s
37-
end
38-
39-
#rest of your class here
40-
end
32+
def perform
33+
# ...
34+
end
35+
end
36+
```
37+
38+
That means the IntensiveJob can not have more than 4 jobs running simultaneously.
39+
40+
One can also make the concurrency limit depend on the parameters of a job. For example, if you always pass a user_id as the first parameter, you can restrict the job to run N concurrent jobs per user:
41+
42+
```ruby
43+
class IntensiveJob
44+
extend Resque::Plugins::ConcurrentRestriction
45+
concurrent 4
46+
47+
def self.concurrent_identifier(*args)
48+
args.first.to_s
49+
end
50+
51+
def perform
52+
# ...
53+
end
54+
end
55+
```
56+
57+
## Author
4158

42-
Author
43-
------
4459
Code was originally forked from the [resque-restriction][1] plugin (Richard Huang :: flyerhzm@gmail.com :: @flyerhzm), but diverged enough that it warranted being its own plugin to keep the code simple.
4560

4661
Matt Conway :: matt@conwaysplace.com :: @mattconway
4762

48-
Copyright
49-
---------
63+
## Copyright
64+
5065
Copyright (c) 2011 Matt Conway. See LICENSE for details.
5166

5267
[0]: http://github.com/defunkt/resque

0 commit comments

Comments
 (0)