@@ -52,9 +52,15 @@ public function size($queue = null)
52
52
*/
53
53
public function push ($ job , $ data = '' , $ queue = null )
54
54
{
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
+ );
58
64
}
59
65
60
66
/**
@@ -63,11 +69,11 @@ public function push($job, $data = '', $queue = null)
63
69
* @param string $payload
64
70
* @param string|null $queue
65
71
* @param array $options
66
- * @return void
72
+ * @return string
67
73
*/
68
74
public function pushRaw ($ payload , $ queue = null , array $ options = [])
69
75
{
70
- $ this ->pushToCloudTasks ($ queue , $ payload );
76
+ return $ this ->pushToCloudTasks ($ queue , $ payload );
71
77
}
72
78
73
79
/**
@@ -81,9 +87,15 @@ public function pushRaw($payload, $queue = null, array $options = [])
81
87
*/
82
88
public function later ($ delay , $ job , $ data = '' , $ queue = null )
83
89
{
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
+ );
87
99
}
88
100
89
101
/**
@@ -92,7 +104,7 @@ public function later($delay, $job, $data = '', $queue = null)
92
104
* @param string|null $queue
93
105
* @param string $payload
94
106
* @param \DateTimeInterface|\DateInterval|int $delay
95
- * @return void
107
+ * @return string
96
108
*/
97
109
protected function pushToCloudTasks ($ queue , $ payload , $ delay = 0 )
98
110
{
@@ -103,12 +115,13 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
103
115
$ httpRequest = $ this ->createHttpRequest ();
104
116
$ httpRequest ->setUrl ($ this ->getHandler ());
105
117
$ 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 );
112
125
113
126
$ task = $ this ->createTask ();
114
127
$ task ->setHttpRequest ($ httpRequest );
@@ -128,9 +141,11 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
128
141
$ createdTask = CloudTasksApi::createTask ($ queueName , $ task );
129
142
130
143
event ((new TaskCreated )->queue ($ queue )->task ($ task ));
144
+
145
+ return $ uuid ;
131
146
}
132
147
133
- private function withUuid (string $ payload ): string
148
+ private function withUuid (string $ payload ): array
134
149
{
135
150
/** @var array $decoded */
136
151
$ decoded = json_decode ($ payload , true );
@@ -139,7 +154,10 @@ private function withUuid(string $payload): string
139
154
$ decoded ['uuid ' ] = (string ) Str::uuid ();
140
155
}
141
156
142
- return json_encode ($ decoded );
157
+ return [
158
+ json_encode ($ decoded ),
159
+ $ decoded ['uuid ' ],
160
+ ];
143
161
}
144
162
145
163
/**
0 commit comments