File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ An unnamed hook (`before_perform`) will be executed first.
6666
6767The available hooks are:
6868
69+ * ` after_enqueue ` : Called with the job args after a job is placed on the queue.
70+ Any exception raised propagates up to the code which queued the job.
71+
6972* ` before_perform ` : Called with the job args before perform. If it raises
7073 ` Resque::Job::DontPerform ` , the job is aborted. If other exceptions
7174 are raised, they will be propagated up the the ` Resque::Failure `
@@ -99,6 +102,13 @@ look something like this.
99102
100103Modules are even better because jobs can use many of them.
101104
105+ module ScaledJob
106+ def after_enqueue_scale_workers(*args)
107+ Logger.info "Scaling worker count up"
108+ Scaler.up! if Redis.info[:pending].to_i > 25
109+ end
110+ end
111+
102112 module LoggedJob
103113 def before_perform_log_job(*args)
104114 Logger.info "About to perform #{self} with #{args.inspect}"
@@ -115,6 +125,7 @@ Modules are even better because jobs can use many of them.
115125 class MyJob
116126 extend LoggedJob
117127 extend RetriedJob
128+ extend ScaledJob
118129 def self.perform(*args)
119130 ...
120131 end
You can’t perform that action at this time.
0 commit comments