You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package requires Laravel 10 or higher and supports MySQL 8 and PostgreSQL 15. Might support older database versions too, but package hasn't been tested for it.
23
+
<br>
24
+
This package requires Laravel 10 or higher and supports MySQL 8 and PostgreSQL 15. Might support older database versions too, but package hasn't been tested for it.
25
25
26
-
Please check the [Laravel support policy](https://laravel.com/docs/master/releases#support-policy) table for supported Laravel and PHP versions.
26
+
Please check the [Laravel support policy](https://laravel.com/docs/master/releases#support-policy) table for supported
| `STACKKIT_CLOUD_TASKS_PROJECT` | The project your queue belongs to. |`my-project`
89
-
| `STACKKIT_CLOUD_TASKS_LOCATION` | The region where the project is hosted. |`europe-west6`
90
-
| `STACKKIT_CLOUD_TASKS_QUEUE` | The default queue a job will be added to. |`emails`
91
-
| **App Engine**
92
-
| `STACKKIT_APP_ENGINE_TASK` (optional) | Set to true to use App Engine task (else a Http task will be used). Defaults to false. |`true`
93
-
| `STACKKIT_APP_ENGINE_SERVICE` (optional) | The App Engine service to handle the task (only if using App Engine task). |`api`
94
-
| **Non- App Engine apps**
95
-
| `STACKKIT_CLOUD_TASKS_SERVICE_EMAIL` (optional) | The email address of the service account. Important, it should have the correct roles. See the section below which roles. |`[email protected]`
96
-
| `STACKKIT_CLOUD_TASKS_HANDLER` (optional) | The URL that Cloud Tasks will call to process a job. This should be the URL to your Laravel app. By default we will use the URL that dispatched the job. |`https://<your website>.com`
| `STACKKIT_CLOUD_TASKS_PROJECT` | The project your queue belongs to. | `my-project`
90
+
| `STACKKIT_CLOUD_TASKS_LOCATION` | The region where the project is hosted. | `europe-west6`
91
+
| `STACKKIT_CLOUD_TASKS_QUEUE` | The default queue a job will be added to. | `emails`
92
+
| **App Engine**
93
+
| `STACKKIT_APP_ENGINE_TASK` (optional) | Set to true to use App Engine task (else a Http task will be used). Defaults to false. | `true`
94
+
| `STACKKIT_APP_ENGINE_SERVICE` (optional) | The App Engine service to handle the task (only if using App Engine task). | `api`
95
+
| **Non- App Engine apps**
96
+
| `STACKKIT_CLOUD_TASKS_SERVICE_EMAIL` (optional) | The email address of the service account. Important, it should have the correct roles. See the section below which roles. | `[email protected]`
97
+
| `STACKKIT_CLOUD_TASKS_HANDLER` (optional) | The URL that Cloud Tasks will call to process a job. This should be the URL to your Laravel app. By default we will use the URL that dispatched the job. | `https://<your website>.com`
98
+
97
99
</details>
100
+
101
+
### How to
102
+
103
+
#### Passing headers to a task
104
+
105
+
You can pass headers to a task by using the `withHeaders` method on the queue connection.
106
+
107
+
```php
108
+
use Illuminate\Queue\Queue;
109
+
110
+
Queue::connection()->setTaskHeaders([
111
+
'X-My-Header' => 'My-Value',
112
+
]);
113
+
```
114
+
115
+
If necessary, the current job being dispatched is also available:
Using Cloud Tasks as a Laravel queue driver is fundamentally different than other Laravel queue drivers, like Redis.
129
+
<br>
130
+
Using Cloud Tasks as a Laravel queue driver is fundamentally different than other Laravel queue drivers, like Redis.
104
131
105
132
Typically a Laravel queue has a worker that listens to incoming jobs using the `queue:work` / `queue:listen` command.
106
-
With Cloud Tasks, this is not the case. Instead, Cloud Tasks will schedule the job for you and make an HTTP request to your application with the job payload. There is no need to run a `queue:work/listen` command.
133
+
With Cloud Tasks, this is not the case. Instead, Cloud Tasks will schedule the job for you and make an HTTP request to
134
+
your application with the job payload. There is no need to run a `queue:work/listen` command.
107
135
108
136
#### Good to know
109
137
110
-
- Backoff, retries, max tries, retryUntil are all handled by Laravel. All these options are ignored in the Cloud Tasks configuration.
138
+
- Backoff, retries, max tries, retryUntil are all handled by Laravel. All these options are ignored in the Cloud Tasks
139
+
configuration.
111
140
112
141
</details>
113
142
<details>
114
-
<summary>Dashboard (beta)</summary>
115
-
<br>
116
-
The package comes with a beautiful dashboard that can be used to monitor all queued jobs.
143
+
<summary>Dashboard (beta)</summary>
144
+
<br>
145
+
The package comes with a beautiful dashboard that can be used to monitor all queued jobs.
117
146
118
147
119
-
<imgsrc="/assets/dashboard.png"width="100%">
148
+
<imgsrc="/assets/dashboard.png"width="100%">
120
149
121
-
---
150
+
---
122
151
123
152
_Experimental_
124
153
125
154
The dashboard works by storing all outgoing tasks in a database table. When Cloud Tasks calls the application and this
126
155
package handles the task, we will automatically update the tasks' status, attempts
127
156
and possible errors.
128
157
129
-
There is probably a (small) performance penalty because each task dispatch and handling does extra database read and writes.
158
+
There is probably a (small) performance penalty because each task dispatch and handling does extra database read and
159
+
writes.
130
160
Also, the dashboard has not been tested with high throughput queues.
131
161
132
-
---
162
+
---
133
163
134
164
135
165
To make use of it, enable it through the `.env` file:
The dashboard is accessible at the URI: /cloud-tasks
150
180
151
181
</details>
152
182
<details>
153
-
<summary>Authentication</summary>
154
-
<br>
183
+
<summary>Authentication</summary>
184
+
<br>
155
185
156
186
Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable with a path to the credentials file.
157
187
158
188
More info: https://cloud.google.com/docs/authentication/production
159
189
160
-
If you're not using your master service account (which has all abilities), you must add the following roles to make it works:
190
+
If you're not using your master service account (which has all abilities), you must add the following roles to make it
191
+
works:
192
+
161
193
1. App Engine Viewer
162
194
2. Cloud Tasks Enqueuer
163
195
3. Cloud Tasks Viewer
164
196
4. Cloud Tasks Task Deleter
165
197
5. Service Account User
198
+
166
199
</details>
167
200
<details>
168
-
<summary>Security</summary>
169
-
<br>
170
-
The job handler requires each request to have an OpenID token. In the installation step we set the service account email, and with that service account, Cloud Tasks will generate an OpenID token and send it along with the job payload to the handler.
201
+
<summary>Security</summary>
202
+
<br>
203
+
The job handler requires each request to have an OpenID token. In the installation step we set the service account email, and with that service account, Cloud Tasks will generate an OpenID token and send it along with the job payload to the handler.
171
204
172
205
This package verifies that the token is digitally signed by Google. Only Google Tasks will be able to call your handler.
173
206
@@ -176,7 +209,7 @@ More information about OpenID Connect:
0 commit comments