feat: change event naming schema

This commit is contained in:
2025-10-19 13:48:13 +02:00
parent 23289d9f09
commit 407b651b82
8 changed files with 74 additions and 49 deletions

View File

@@ -57,7 +57,6 @@ The cluster uses a UDP-based discovery protocol for automatic node detection:
- **Broadcast Address**: 255.255.255.255
- **Listen Interval**: `Config.cluster_listen_interval_ms` (default 10 ms)
- **Heartbeat Interval**: `Config.heartbeat_interval_ms` (default 5000 ms)
- **Node Update Broadcast Interval**: `Config.node_update_broadcast_interval_ms` (default 5000 ms)
### Message Formats
@@ -95,7 +94,6 @@ The `cluster_listen` task parses one UDP packet per run and dispatches by prefix
- **UDP Port**: `Config.udp_port` (default 4210)
- **Listen Interval**: `Config.cluster_listen_interval_ms` (default 10 ms)
- **Heartbeat Interval**: `Config.heartbeat_interval_ms` (default 5000 ms)
- **Node Update Broadcast Interval**: `Config.node_update_broadcast_interval_ms` (default 5000 ms)
### Node Status Categories
@@ -113,12 +111,9 @@ The system runs several background tasks at different intervals:
| Task | Interval (default) | Purpose |
|------|--------------------|---------|
| `cluster_discovery` | 1000 ms | Send UDP discovery packets |
| `cluster_listen` | 10 ms | Listen for discovery/heartbeat/node-info |
| `cluster_listen` | 10 ms | Listen for heartbeat/node-info messages |
| `status_update` | 1000 ms | Update node status categories, purge dead |
| `heartbeat` | 5000 ms | Broadcast heartbeat and update local resources |
| `cluster_update_members_info` | 10000 ms | Reserved; no-op (info via UDP) |
| `print_members` | 5000 ms | Log current member list |
### Task Management Features
@@ -135,12 +130,12 @@ The `NodeContext` provides an event-driven architecture for system-wide communic
```cpp
// Subscribe to events
ctx.on("node_discovered", [](void* data) {
ctx.on("node/discovered", [](void* data) {
NodeInfo* node = static_cast<NodeInfo*>(data);
// Handle new node discovery
});
ctx.on("cluster_updated", [](void* data) {
ctx.on("cluster/updated", [](void* data) {
// Handle cluster membership changes
});
```
@@ -149,13 +144,13 @@ ctx.on("cluster_updated", [](void* data) {
```cpp
// Publish events
ctx.fire("node_discovered", &newNode);
ctx.fire("cluster_updated", &clusterData);
ctx.fire("node/discovered", &newNode);
ctx.fire("cluster/updated", &clusterData);
```
### Available Events
- **`node_discovered`**: New node added or local node refreshed
- **`node/discovered`**: New node added or local node refreshed
## Resource Monitoring