mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add synchronization across horizontally scaled instances to schedule flows and hooks (#18584)
* Add synchronization to schedule flows and hooks Fixes #15052 * Add changeset * Add test * Add to sequential list * Fix spelling in changeset --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: ian <licitdev@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8401cd5a8e
commit
60be3c2b40
@@ -130,7 +130,7 @@ finish and return whatever value is in **Response Body**. This slows the API, bu
|
||||

|
||||
|
||||
This trigger enables you to create data at scheduled intervals, via
|
||||
[6-point cron job syntax](https://github.com/node-cron/node-cron#cron-syntax).
|
||||
[6-point cron job syntax](https://github.com/node-schedule/node-schedule#cron-style-scheduling).
|
||||
|
||||
- **Interval** — Set the cron job interval to schedule when the flow triggers.
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ The callback function itself receives one parameter:
|
||||
### Schedule
|
||||
|
||||
Schedule hooks execute at certain points in time rather than when Directus performs a specific action. This is supported
|
||||
through [`node-cron`](https://www.npmjs.com/package/node-cron).
|
||||
through [`node-schedule`](https://www.npmjs.com/package/node-schedule).
|
||||
|
||||
To set up a scheduled event, provide a cron statement as the first parameter to the `schedule()` function. For example
|
||||
`schedule('15 14 1 * *', <...>)` (at 14:15 on day-of-month 1) or `schedule('5 4 * * sun', <...>)` (at 04:05 on Sunday).
|
||||
|
||||
@@ -450,10 +450,12 @@ RATE_LIMITER_REDIS_DB=0
|
||||
|
||||
### Pressure-based rate limiter
|
||||
|
||||
This rate-limiter prevents the API from accepting new requests while the server is experiencing high load. This continuously monitors the current event loop and memory usage, and error out requests with a 503 early when the system is overloaded.
|
||||
This rate-limiter prevents the API from accepting new requests while the server is experiencing high load. This
|
||||
continuously monitors the current event loop and memory usage, and error out requests with a 503 early when the system
|
||||
is overloaded.
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
|-----------------------------------------------|---------------------------------------------------------------------|---------------|
|
||||
| --------------------------------------------- | ------------------------------------------------------------------- | ------------- |
|
||||
| `PRESSURE_LIMITER_ENABLED` | Whether or not to enable pressure-based rate limiting on the API. | `true` |
|
||||
| `PRESSURE_LIMITER_SAMPLE_INTERVAL` | The time window for measuring pressure in ms. | `250` |
|
||||
| `PRESSURE_LIMITER_MAX_EVENT_LOOP_UTILIZATION` | The maximum allowed utilization where `1` is 100% loop utilization. | `0.99` |
|
||||
@@ -949,6 +951,26 @@ Alternatively, you can provide the individual connection parameters:
|
||||
|
||||
<sup>[1]</sup> `redis` should be used in load-balanced installations of Directus
|
||||
|
||||
## Synchronization
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
| --------------------------- | ----------------------------------------------------------------------- | ------------- |
|
||||
| `SYNCHRONIZATION_STORE` | One of `memory`, `redis`<sup>[1]</sup> | `memory` |
|
||||
| `SYNCHRONIZATION_NAMESPACE` | How to scope the channels in Redis | `directus` |
|
||||
| `SYNCHRONIZATION_REDIS` | Redis connection string, e.g., `redis://user:password@127.0.0.1:6380/4` | --- |
|
||||
|
||||
Alternatively, you can provide the individual connection parameters:
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
| -------------------------------- | ------------------------------------------------------------- | ------------- |
|
||||
| `SYNCHRONIZATION_REDIS_HOST` | Hostname of the Redis instance, e.g., `"127.0.0.1"` | -- |
|
||||
| `SYNCHRONIZATION_REDIS_PORT` | Port of the Redis instance, e.g., `6379` | -- |
|
||||
| `SYNCHRONIZATION_REDIS_USERNAME` | Username for your Redis instance, e.g., `"default"` | -- |
|
||||
| `SYNCHRONIZATION_REDIS_PASSWORD` | Password for your Redis instance, e.g., `"yourRedisPassword"` | -- |
|
||||
| `SYNCHRONIZATION_REDIS_DB` | Database of your Redis instance to connect, e.g., `1` | -- |
|
||||
|
||||
<sup>[1]</sup> `redis` should be used in load-balanced installations of Directus
|
||||
|
||||
## Email
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
|
||||
Reference in New Issue
Block a user