Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add docs for after_enqueue hook

  • Loading branch information...
commit 61d9cb5bfb75391cd67983e9b611ea02bfdcd641 1 parent 193289b
@darkhelmet darkhelmet authored defunkt committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 docs/HOOKS.md
View
11 docs/HOOKS.md
@@ -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`
@@ -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}"
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.