@@ -108,13 +108,12 @@ function ($payload, $queue, $delay) {
108108 protected function pushToCloudTasks ($ queue , $ payload , $ delay = 0 )
109109 {
110110 $ queue = $ queue ?: $ this ->config ['queue ' ];
111- $ queueName = $ this ->client ->queueName ($ this ->config ['project ' ], $ this ->config ['location ' ], $ queue );
112- $ availableAt = $ this ->availableAt ($ delay );
113111
114- $ payload = json_decode ($ payload , true );
112+ $ payload = ( array ) json_decode ($ payload , true );
115113
116- $ task = new Task ();
117- $ task ->setName ($ this ->taskName ($ queue , $ payload ));
114+ $ task = new Task ([
115+ 'name ' => $ this ->taskName ($ queue , $ payload ),
116+ ]);
118117
119118 $ payload = $ this ->withAttempts ($ payload );
120119 $ payload = $ this ->withQueueName ($ payload , $ queue );
@@ -155,10 +154,12 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
155154 $ task ->setDispatchDeadline (new Duration (['seconds ' => $ this ->config ['dispatch_deadline ' ]]));
156155 }
157156
157+ $ availableAt = $ this ->availableAt ($ delay );
158158 if ($ availableAt > time ()) {
159159 $ task ->setScheduleTime (new Timestamp (['seconds ' => $ availableAt ]));
160160 }
161161
162+ $ queueName = $ this ->client ->queueName ($ this ->config ['project ' ], $ this ->config ['location ' ], $ queue );
162163 CloudTasksApi::createTask ($ queueName , $ task );
163164
164165 event ((new TaskCreated )->queue ($ queue )->task ($ task ));
@@ -255,11 +256,15 @@ public function release(CloudTasksJob $job, int $delay = 0): void
255256
256257 public function getHandler (): string
257258 {
259+ if (empty ($ this ->config ['handler ' ])) {
260+ $ this ->config ['handler ' ] = request ()->getSchemeAndHttpHost ();
261+ }
262+
258263 $ handler = rtrim ($ this ->config ['handler ' ], '/ ' );
259264
260265 return match (true ) {
261266 ! str_ends_with ($ handler , '/handle-task ' ) => $ handler .'/handle-task ' ,
262- default => $ handler ,
267+ default => $ this -> config [ ' handler ' ] ,
263268 };
264269 }
265270}
0 commit comments