feat: graph-level fanout — reuse flow UUID for same from_node+from_port
Edges that share the same source node and port now get the same MXL flow UUID. One writer, multiple independent readers — each tracks its own position in the ring buffer. Enables 1-to-N routing in graph.json without any splitter node. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-3
@@ -6,8 +6,10 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@@ -62,11 +64,18 @@ static dmf::FlowGraph load_graph(const std::string& path) {
|
|||||||
n.value("params", nlohmann::json::object())
|
n.value("params", nlohmann::json::object())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Edges sharing the same from_node+from_port reuse the same flow UUID,
|
||||||
|
// so one writer can be read by multiple consumers (MXL supports N readers per flow).
|
||||||
|
std::map<std::pair<std::string,std::string>, std::string> flow_ids;
|
||||||
for (const auto& e : j.at("edges")) {
|
for (const auto& e : j.at("edges")) {
|
||||||
|
auto from_node = e.at("from").get<std::string>();
|
||||||
|
auto from_port = e.at("from_port").get<std::string>();
|
||||||
|
auto key = std::make_pair(from_node, from_port);
|
||||||
|
if (!flow_ids.count(key)) flow_ids[key] = gen_uuid();
|
||||||
g.edges.push_back({
|
g.edges.push_back({
|
||||||
gen_uuid(),
|
flow_ids.at(key),
|
||||||
e.at("from").get<std::string>(),
|
from_node,
|
||||||
e.at("from_port").get<std::string>(),
|
from_port,
|
||||||
e.value("to", std::string{}),
|
e.value("to", std::string{}),
|
||||||
e.value("to_port", std::string{}),
|
e.value("to_port", std::string{}),
|
||||||
e.at("format")
|
e.at("format")
|
||||||
|
|||||||
Reference in New Issue
Block a user