12
12
use Google \Cloud \Tasks \V2 \HttpRequest ;
13
13
use Google \Cloud \Tasks \V2 \OidcToken ;
14
14
use Google \Cloud \Tasks \V2 \Task ;
15
- use Google \Protobuf \Duration ;
16
15
use Google \Protobuf \Timestamp ;
17
16
use Illuminate \Contracts \Queue \Queue as QueueContract ;
18
17
use Illuminate \Queue \Queue as LaravelQueue ;
@@ -138,22 +137,10 @@ protected function pushToCloudTasks($queue, $payload, $delay, mixed $job)
138
137
139
138
$ task = tap (new Task ())->setName ($ this ->taskName ($ queue , $ payload ['displayName ' ]));
140
139
141
- $ payload = $ this ->enrichPayloadWithInternalData (
142
- payload: $ payload ,
143
- queueName: $ queue ,
144
- taskName: $ task ->getName (),
145
- connectionName: $ this ->getConnectionName (),
146
- );
140
+ $ payload = $ this ->enrichPayloadWithAttempts ($ payload );
147
141
148
142
$ this ->addPayloadToTask ($ payload , $ task , $ job );
149
143
150
- // The deadline for requests sent to the app. If the app does not respond by
151
- // this deadline then the request is cancelled and the attempt is marked as
152
- // a failure. Cloud Tasks will retry the task according to the RetryConfig.
153
- if (! empty ($ this ->config ['dispatch_deadline ' ])) {
154
- $ task ->setDispatchDeadline (new Duration (['seconds ' => $ this ->config ['dispatch_deadline ' ]]));
155
- }
156
-
157
144
$ availableAt = $ this ->availableAt ($ delay );
158
145
if ($ availableAt > time ()) {
159
146
$ task ->setScheduleTime (new Timestamp (['seconds ' => $ availableAt ]));
@@ -175,22 +162,18 @@ private function taskName(string $queueName, string $displayName): string
175
162
$ queueName ,
176
163
str ($ displayName )
177
164
->afterLast ('\\' )
165
+ ->replaceMatches ('![^-\pL\pN\s]+!u ' , '- ' )
166
+ ->replaceMatches ('![-\s]+!u ' , '- ' )
178
167
->prepend ((string ) Str::ulid (), '- ' )
179
168
->toString (),
180
169
);
181
170
}
182
171
183
- private function enrichPayloadWithInternalData (
172
+ private function enrichPayloadWithAttempts (
184
173
array $ payload ,
185
- string $ queueName ,
186
- string $ taskName ,
187
- string $ connectionName ,
188
174
): array {
189
175
$ payload ['internal ' ] = [
190
176
'attempts ' => $ payload ['internal ' ]['attempts ' ] ?? 0 ,
191
- 'queue ' => $ queueName ,
192
- 'taskName ' => $ taskName ,
193
- 'connection ' => $ connectionName ,
194
177
];
195
178
196
179
return $ payload ;
@@ -241,7 +224,7 @@ public function pop($queue = null)
241
224
242
225
public function delete (CloudTasksJob $ job ): void
243
226
{
244
- CloudTasksApi:: deleteTask ( $ job -> getTaskName ());
227
+ // Job deletion will be handled by Cloud Tasks.
245
228
}
246
229
247
230
public function release (CloudTasksJob $ job , int $ delay = 0 ): void
0 commit comments