feat: introduce cluster events

This commit is contained in:
2025-05-17 20:07:51 +02:00
parent de8af61ba7
commit e30f167766
13 changed files with 190 additions and 62 deletions

View File

@@ -132,6 +132,7 @@ All endpoints except `/health` require authentication via an API token passed in
| GET | `/cluster/members` | Get the cluster members |
| POST | `/cluster/join` | Join cluster nodes |
| POST | `/cluster/leave` | Leave the cluster |
| POST | `/cluster/event` | Send a cluster event |
### Response Codes
@@ -144,6 +145,25 @@ All endpoints except `/health` require authentication via an API token passed in
### Request/Response Format
All endpoints use JSON for request and response payloads.
## Cluster Events
Cluster events are used for broadcast messages to all nodes in the cluster. They are sent as HTTP POST requests to the `/cluster/event` endpoint.
The request body should be a JSON object with the following fields:
- `name`: The name of the event
- `payload`: The payload of the event, optional
The response will be a JSON object with the following fields:
- `status`: The status of the event. This is a string, either "success" or "error".
- `error`: If the status is "error", this field will contain a string describing the error. This field is optional.
Following events are implemented:
| Event Name | Description | Payload |
|------------|----------------------|---------|
| restart | Restart the cluster | N/A |
| shutdown | Shutdown the cluster | N/A |
## Examples
### Connect to a WiFi Access Point