File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
src/Illuminate/Queue/Middleware Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,13 @@ class ThrottlesExceptions
15
15
*/
16
16
protected $ key ;
17
17
18
+ /**
19
+ * Indicates whether the throttle key should use the job's UUID.
20
+ *
21
+ * @var bool
22
+ */
23
+ protected $ byJob = false ;
24
+
18
25
/**
19
26
* The maximum number of attempts allowed before rate limiting applies.
20
27
*
@@ -148,7 +155,13 @@ public function backoff($backoff)
148
155
*/
149
156
protected function getKey ($ job )
150
157
{
151
- return $ this ->key ? $ this ->prefix .$ this ->key : $ this ->prefix .$ job ->job ->uuid ();
158
+ if ($ this ->key ) {
159
+ return $ this ->prefix .$ this ->key ;
160
+ } elseif ($ this ->byJob ) {
161
+ return $ this ->prefix .$ job ->job ->uuid ();
162
+ }
163
+
164
+ return $ this ->prefix .md5 (get_class ($ job ));
152
165
}
153
166
154
167
/**
@@ -164,6 +177,18 @@ public function by($key)
164
177
return $ this ;
165
178
}
166
179
180
+ /**
181
+ * Indicate that the throttle key should use the job's UUID.
182
+ *
183
+ * @return $this
184
+ */
185
+ public function byJob ()
186
+ {
187
+ $ this ->byJob = true ;
188
+
189
+ return $ this ;
190
+ }
191
+
167
192
/**
168
193
* Get the number of seconds that should elapse before the job is retried.
169
194
*
You can’t perform that action at this time.
0 commit comments