feat: Implement multi-node support with MQTT and mDNS for service discovery and coordination

This commit is contained in:
2026-02-23 02:30:12 -08:00
parent eeaa5045d0
commit 3343e955fd
29 changed files with 1878 additions and 35 deletions

View File

@@ -8,6 +8,9 @@ import type {
GatewayInfo,
ServiceActionResponse,
SSEHealthEvent,
MeshStatus,
NodeSummary,
NodeDetail,
ToolSummary,
ToolDetail,
} from "@/types"
@@ -107,6 +110,39 @@ export function useToolAction() {
})
}
export function useGatewayReload() {
const qc = useQueryClient()
return useMutation({
mutationFn: () => apiClient.post<{ status: string }>("/gateway/reload"),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ["gateway"] })
},
})
}
export function useNodes() {
return useQuery({
queryKey: ["nodes"],
queryFn: () => apiClient.get<NodeSummary[]>("/nodes"),
})
}
export function useNode(hostname: string) {
return useQuery({
queryKey: ["nodes", hostname],
queryFn: () => apiClient.get<NodeDetail>(`/nodes/${hostname}`),
enabled: !!hostname,
})
}
export function useMeshStatus() {
return useQuery({
queryKey: ["mesh"],
queryFn: () => apiClient.get<MeshStatus>("/mesh/status"),
refetchInterval: 30_000,
})
}
export function useTools() {
return useQuery({
queryKey: ["tools"],
@@ -140,6 +176,13 @@ export function useEventStream() {
qc.invalidateQueries({ queryKey: ["components"] })
})
es.addEventListener("mesh", () => {
// A remote node updated or went offline — refresh mesh, nodes, and gateway
qc.invalidateQueries({ queryKey: ["mesh"] })
qc.invalidateQueries({ queryKey: ["nodes"] })
qc.invalidateQueries({ queryKey: ["gateway"] })
})
es.onerror = () => {
// EventSource auto-reconnects; nothing to do
}