@@ -52,9 +52,15 @@ public function size($queue = null)
5252 */
5353 public function push ($ job , $ data = '' , $ queue = null )
5454 {
55- $ this ->pushToCloudTasks ($ queue , $ this ->createPayload (
56- $ job , $ this ->getQueue ($ queue ), $ data
57- ));
55+ return $ this ->enqueueUsing (
56+ $ job ,
57+ $ this ->createPayload ($ job , $ this ->getQueue ($ queue ), $ data ),
58+ $ queue ,
59+ null ,
60+ function ($ payload , $ queue ) {
61+ return $ this ->pushRaw ($ payload , $ queue );
62+ }
63+ );
5864 }
5965
6066 /**
@@ -63,11 +69,11 @@ public function push($job, $data = '', $queue = null)
6369 * @param string $payload
6470 * @param string|null $queue
6571 * @param array $options
66- * @return void
72+ * @return string
6773 */
6874 public function pushRaw ($ payload , $ queue = null , array $ options = [])
6975 {
70- $ this ->pushToCloudTasks ($ queue , $ payload );
76+ return $ this ->pushToCloudTasks ($ queue , $ payload );
7177 }
7278
7379 /**
@@ -81,9 +87,15 @@ public function pushRaw($payload, $queue = null, array $options = [])
8187 */
8288 public function later ($ delay , $ job , $ data = '' , $ queue = null )
8389 {
84- $ this ->pushToCloudTasks ($ queue , $ this ->createPayload (
85- $ job , $ this ->getQueue ($ queue ), $ data
86- ), $ delay );
90+ return $ this ->enqueueUsing (
91+ $ job ,
92+ $ this ->createPayload ($ job , $ this ->getQueue ($ queue ), $ data ),
93+ $ queue ,
94+ $ delay ,
95+ function ($ payload , $ queue , $ delay ) {
96+ return $ this ->pushToCloudTasks ($ queue , $ payload , $ delay );
97+ }
98+ );
8799 }
88100
89101 /**
@@ -92,7 +104,7 @@ public function later($delay, $job, $data = '', $queue = null)
92104 * @param string|null $queue
93105 * @param string $payload
94106 * @param \DateTimeInterface|\DateInterval|int $delay
95- * @return void
107+ * @return string
96108 */
97109 protected function pushToCloudTasks ($ queue , $ payload , $ delay = 0 )
98110 {
@@ -103,12 +115,13 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
103115 $ httpRequest = $ this ->createHttpRequest ();
104116 $ httpRequest ->setUrl ($ this ->getHandler ());
105117 $ httpRequest ->setHttpMethod (HttpMethod::POST );
106- $ httpRequest ->setBody (
107- // Laravel 7+ jobs have a uuid, but Laravel 6 doesn't have it.
108- // Since we are using and expecting the uuid in some places
109- // we will add it manually here if it's not present yet.
110- $ this ->withUuid ($ payload )
111- );
118+
119+ // Laravel 7+ jobs have a uuid, but Laravel 6 doesn't have it.
120+ // Since we are using and expecting the uuid in some places
121+ // we will add it manually here if it's not present yet.
122+ [$ payload , $ uuid ] = $ this ->withUuid ($ payload );
123+
124+ $ httpRequest ->setBody ($ payload );
112125
113126 $ task = $ this ->createTask ();
114127 $ task ->setHttpRequest ($ httpRequest );
@@ -128,9 +141,11 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
128141 $ createdTask = CloudTasksApi::createTask ($ queueName , $ task );
129142
130143 event ((new TaskCreated )->queue ($ queue )->task ($ task ));
144+
145+ return $ uuid ;
131146 }
132147
133- private function withUuid (string $ payload ): string
148+ private function withUuid (string $ payload ): array
134149 {
135150 /** @var array $decoded */
136151 $ decoded = json_decode ($ payload , true );
@@ -139,7 +154,10 @@ private function withUuid(string $payload): string
139154 $ decoded ['uuid ' ] = (string ) Str::uuid ();
140155 }
141156
142- return json_encode ($ decoded );
157+ return [
158+ json_encode ($ decoded ),
159+ $ decoded ['uuid ' ],
160+ ];
143161 }
144162
145163 /**
0 commit comments