Skip to content

Commit

Permalink
more wordsmithing
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttam committed Mar 9, 2010
1 parent 20fc5d9 commit 5d150c1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ In your class, add the can_run_every in which the job should be throttled. Examp


By default, the key which identifies the job is simply the class name. If you'd like By default, the key which identifies the job is simply the class name. If you'd like
to override that to be more granular, you can do that in the identifier class method to override that to be more granular, you can do that in the identifier class method
by returning a string. Example: by returning a string. For example, if you want the job to be limit to once a day per
account, do something like the following:


class MyThrottledJob < Resque::ThrottledJob class MyThrottledJob < Resque::ThrottledJob
throttle :can_run_every => 24.hours throttle :can_run_every => 24.hours


def self.identifier(*args) def self.identifier(*args)
some_id = *args account_id = *args
thing = MyClass.find_by_id(some_id) "account_id:#{account_id}"
"some_id:#{thing.thing_id}"
end end


#rest of your class here #rest of your class here
end end


The *args passed to identifier are the same arguments that are passed to perform.

When a job is throttled, it will raise a ThrottledError and the job will not be enqueued. When a job is throttled, it will raise a ThrottledError and the job will not be enqueued.


Contributing Contributing
Expand Down

0 comments on commit 5d150c1

Please sign in to comment.