1212use Google \Cloud \Tasks \V2 \HttpRequest ;
1313use Google \Cloud \Tasks \V2 \OidcToken ;
1414use Google \Cloud \Tasks \V2 \Task ;
15- use Google \Protobuf \Duration ;
1615use Google \Protobuf \Timestamp ;
1716use Illuminate \Contracts \Queue \Queue as QueueContract ;
1817use Illuminate \Queue \Queue as LaravelQueue ;
@@ -138,22 +137,10 @@ protected function pushToCloudTasks($queue, $payload, $delay, mixed $job)
138137
139138 $ task = tap (new Task ())->setName ($ this ->taskName ($ queue , $ payload ['displayName ' ]));
140139
141- $ payload = $ this ->enrichPayloadWithInternalData (
142- payload: $ payload ,
143- queueName: $ queue ,
144- taskName: $ task ->getName (),
145- connectionName: $ this ->getConnectionName (),
146- );
140+ $ payload = $ this ->enrichPayloadWithAttempts ($ payload );
147141
148142 $ this ->addPayloadToTask ($ payload , $ task , $ job );
149143
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-
157144 $ availableAt = $ this ->availableAt ($ delay );
158145 if ($ availableAt > time ()) {
159146 $ task ->setScheduleTime (new Timestamp (['seconds ' => $ availableAt ]));
@@ -175,22 +162,18 @@ private function taskName(string $queueName, string $displayName): string
175162 $ queueName ,
176163 str ($ displayName )
177164 ->afterLast ('\\' )
165+ ->replaceMatches ('![^-\pL\pN\s]+!u ' , '- ' )
166+ ->replaceMatches ('![-\s]+!u ' , '- ' )
178167 ->prepend ((string ) Str::ulid (), '- ' )
179168 ->toString (),
180169 );
181170 }
182171
183- private function enrichPayloadWithInternalData (
172+ private function enrichPayloadWithAttempts (
184173 array $ payload ,
185- string $ queueName ,
186- string $ taskName ,
187- string $ connectionName ,
188174 ): array {
189175 $ payload ['internal ' ] = [
190176 'attempts ' => $ payload ['internal ' ]['attempts ' ] ?? 0 ,
191- 'queue ' => $ queueName ,
192- 'taskName ' => $ taskName ,
193- 'connection ' => $ connectionName ,
194177 ];
195178
196179 return $ payload ;
@@ -241,7 +224,7 @@ public function pop($queue = null)
241224
242225 public function delete (CloudTasksJob $ job ): void
243226 {
244- CloudTasksApi:: deleteTask ( $ job -> getTaskName ());
227+ // Job deletion will be handled by Cloud Tasks.
245228 }
246229
247230 public function release (CloudTasksJob $ job , int $ delay = 0 ): void
0 commit comments