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
Copy file name to clipboardExpand all lines: README.md
+81-17Lines changed: 81 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -11,22 +11,16 @@
11
11
12
12
This package allows you to use Google Cloud Tasks as your queue driver.
13
13
14
-
**This is a WIP package, use at own risk**
14
+
# How it works
15
15
16
-
# How it works [!]
17
-
18
-
!! Please read this next section !!
19
-
20
-
You may already know this, but using Google Cloud Tasks is fundamentally different than typical Laravel queues.
16
+
Using Cloud Tasks as a Laravel queue driver is fundamentally different than other Laravel queue drivers, like Redis.
21
17
22
18
Typically a Laravel queue has a worker that listens to incoming jobs using the `queue:work` / `queue:listen` command.
23
19
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.
24
20
25
-
Please read the following resource on how to correctly configure your queue so your application doesn't get overloaded with queue request:
(4) Update the `QUEUE_CONNECTION` environment variable
64
+
(3) Update the `QUEUE_CONNECTION` environment variable
76
65
77
66
```
78
67
QUEUE_CONNECTION=cloudtasks
79
68
```
69
+
70
+
(4) Create a new Cloud Tasks queue using `gcloud`
71
+
72
+
````bash
73
+
gcloud tasks queues create [QUEUE_ID]
74
+
````
75
+
76
+
Now that the package is installed, the final step is to set the correct environment variables.
77
+
78
+
Please check the table below on what the values mean and what their value should be.
79
+
80
+
|Environment variable|Description|Example
81
+
|---|---|---
82
+
|`STACKKIT_CLOUD_TASKS_PROJECT`|The project your queue belongs to.|`my-project`
83
+
|`STACKKIT_CLOUD_TASKS_LOCATION`|The region where the AppEngine is hosted|`europe-west6`
84
+
|`STACKKIT_CLOUD_TASKS_HANDLER`|The URL that Cloud Tasks will call to process a job. This should be the URL to your Laravel app with the `handle-task` path added|`https://<your website>.com/handle-task`
85
+
|`STACKKIT_CLOUD_TASKS_QUEUE`|The queue a job will be added to|`emails`
86
+
|`STACKKIT_CLOUD_TASKS_SERVICE_EMAIL`|The emailaddress of the AppEngine service account. Important, it should have the *Cloud Tasks Enqueuer* role|`[email protected]`
87
+
# Configuring the queue
88
+
89
+
When you first create a queue using `gcloud tasks queues create`, the default settings will look something like this:
90
+
91
+
```
92
+
rateLimits:
93
+
maxBurstSize: 100
94
+
maxConcurrentDispatches: 1000
95
+
maxDispatchesPerSecond: 500.0
96
+
retryConfig:
97
+
maxAttempts: 100
98
+
maxBackoff: 3600s
99
+
maxDoublings: 16
100
+
minBackoff: 0.100s
101
+
```
102
+
103
+
## Configurable settings
104
+
105
+
### maxBurstSize
106
+
107
+
Max burst size limits how fast tasks in queue are processed when many tasks are in the queue and the rate is high.
108
+
109
+
### maxConcurrentDispatches
110
+
111
+
The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched for this queue
112
+
113
+
### maxDispatchesPerSecond
114
+
115
+
The maximum rate at which tasks are dispatched from this queue.
116
+
117
+
### maxAttempts
118
+
119
+
Number of attempts per task. Cloud Tasks will attempt the task max_attempts times (that is, if the first attempt fails, then there will be max_attempts - 1 retries). Must be >= -1.|
120
+
121
+
### maxBackoff
122
+
123
+
A task will be scheduled for retry between min_backoff and max_backoff duration after it fails
124
+
125
+
### maxDoublings
126
+
127
+
The time between retries will double max_doublings times.
128
+
129
+
A task's retry interval starts at min_backoff, then doubles max_doublings times, then increases linearly, and finally retries retries at intervals of max_backoff up to max_attempts times.
130
+
131
+
For example, if min_backoff is 10s, max_backoff is 300s, and max_doublings is 3, then the a task will first be retried in 10s. The retry interval will double three times, and then increase linearly by 2^3 * 10s. Finally, the task will retry at intervals of max_backoff until the task has been attempted max_attempts times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, ....
132
+
133
+
## Recommended settings for Laravel
134
+
135
+
To simulate a single `queue:work/queue:listen` process, simply set the `maxConcurrentDispatches` to 1:
0 commit comments