feat(FN-3454): add typed mesh snapshot API consumed by nodes view
Implements a typed mesh snapshot API in `@fusion/core` (`CentralCore.getMeshSnapshot`, `MeshSnapshot` type) and wires it through the dashboard nodes view via a new `useMeshState` hook, substantially simplifying `MeshTopology.tsx` by replacing internal state management with the centralized snapshot. Fusion-Task-Id: FN-3454
This commit is contained in:
@@ -1361,6 +1361,7 @@ export class CentralCore extends EventEmitter<CentralCoreEvents> {
|
||||
nodeId: node.id,
|
||||
nodeName: node.name,
|
||||
nodeUrl: node.url,
|
||||
nodeType: node.type,
|
||||
status: node.status,
|
||||
metrics: node.systemMetrics ?? null,
|
||||
lastSeen: node.updatedAt,
|
||||
@@ -1369,6 +1370,36 @@ export class CentralCore extends EventEmitter<CentralCoreEvents> {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Return mesh snapshots for all locally known nodes from the central registry.
|
||||
* This is a local-only read path and performs no remote fan-out.
|
||||
*/
|
||||
async getLocalMeshSnapshot(): Promise<NodeMeshState[]> {
|
||||
this.ensureInitialized();
|
||||
const nodes = await this.listNodes();
|
||||
const snapshots = await Promise.all(
|
||||
nodes.map(async (node) => {
|
||||
try {
|
||||
return await this.getMeshState(node.id);
|
||||
} catch {
|
||||
return {
|
||||
nodeId: node.id,
|
||||
nodeName: node.name,
|
||||
nodeUrl: node.url,
|
||||
nodeType: node.type,
|
||||
status: node.status,
|
||||
metrics: node.systemMetrics ?? null,
|
||||
lastSeen: node.updatedAt,
|
||||
connectedAt: node.createdAt,
|
||||
knownPeers: [],
|
||||
} satisfies NodeMeshState;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect a fresh local mesh state snapshot.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user