Skip to content

Commit 61d9cb5

Browse files
darkhelmetdefunkt
authored andcommitted
Add docs for after_enqueue hook
1 parent 193289b commit 61d9cb5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/HOOKS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ An unnamed hook (`before_perform`) will be executed first.
6666

6767
The 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

100103
Modules 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

0 commit comments

Comments
 (0)