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.
66
66
67
67
The available hooks are:
68
68
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
+
69
72
* ` before_perform ` : Called with the job args before perform. If it raises
70
73
` Resque::Job::DontPerform ` , the job is aborted. If other exceptions
71
74
are raised, they will be propagated up the the ` Resque::Failure `
@@ -99,6 +102,13 @@ look something like this.
99
102
100
103
Modules are even better because jobs can use many of them.
101
104
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
+
102
112
module LoggedJob
103
113
def before_perform_log_job(*args)
104
114
Logger.info "About to perform #{self} with #{args.inspect}"
@@ -115,6 +125,7 @@ Modules are even better because jobs can use many of them.
115
125
class MyJob
116
126
extend LoggedJob
117
127
extend RetriedJob
128
+ extend ScaledJob
118
129
def self.perform(*args)
119
130
...
120
131
end
You can’t perform that action at this time.
0 commit comments