feat(cluster): use node/discovered event to update memberlist
This commit is contained in:
@@ -68,7 +68,7 @@ The cluster uses a UDP-based discovery protocol for automatic node detection:
|
||||
- **Heartbeat**: `CLUSTER_HEARTBEAT:<hostname>`
|
||||
- Sender: each node, broadcast to 255.255.255.255:`udp_port` on interval
|
||||
- Purpose: prompt peers to reply with their node info and keep liveness
|
||||
- **Node Info**: `CLUSTER_NODE_INFO:<hostname>:<json>`
|
||||
- **Node Info**: `CLUSTER_NODE_INFO:<hostname>:<json>`git add
|
||||
- Sender: node receiving a heartbeat; unicast to heartbeat sender IP
|
||||
- JSON fields: freeHeap, chipId, sdkVersion, cpuFreqMHz, flashChipSize, optional labels
|
||||
|
||||
@@ -140,7 +140,7 @@ 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
|
||||
});
|
||||
@@ -154,13 +154,13 @@ ctx.on("cluster_updated", [](void* data) {
|
||||
|
||||
```cpp
|
||||
// Publish events
|
||||
ctx.fire("node_discovered", &newNode);
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user