Skip to content

Commit

Permalink
Add docs for after_enqueue hook
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhelmet authored and defunkt committed Aug 24, 2010
1 parent 193289b commit 61d9cb5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/HOOKS.md
Expand Up @@ -66,6 +66,9 @@ An unnamed hook (`before_perform`) will be executed first.

The available hooks are:

* `after_enqueue`: Called with the job args after a job is placed on the queue.
Any exception raised propagates up to the code which queued the job.

* `before_perform`: Called with the job args before perform. If it raises
`Resque::Job::DontPerform`, the job is aborted. If other exceptions
are raised, they will be propagated up the the `Resque::Failure`
Expand Down Expand Up @@ -99,6 +102,13 @@ look something like this.

Modules are even better because jobs can use many of them.

module ScaledJob
def after_enqueue_scale_workers(*args)
Logger.info "Scaling worker count up"
Scaler.up! if Redis.info[:pending].to_i > 25
end
end

module LoggedJob
def before_perform_log_job(*args)
Logger.info "About to perform #{self} with #{args.inspect}"
Expand All @@ -115,6 +125,7 @@ Modules are even better because jobs can use many of them.
class MyJob
extend LoggedJob
extend RetriedJob
extend ScaledJob
def self.perform(*args)
...
end
Expand Down

0 comments on commit 61d9cb5

Please sign in to comment.