fix: fabric-bridge build - use NodeRunner::run, get writer config from node base class
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace dmf_node {
|
||||
@@ -21,8 +22,8 @@ public:
|
||||
virtual std::vector<PortDef> input_ports() const = 0;
|
||||
virtual std::vector<PortDef> output_ports() const = 0;
|
||||
virtual void configure(const nlohmann::json& params) = 0;
|
||||
virtual void on_add_writer(const std::string& port_id, mxlFlowWriter writer) = 0;
|
||||
virtual void on_add_reader(const std::string& port_id, mxlFlowReader reader) = 0;
|
||||
virtual void on_add_writer(const std::string& port_id, mxlFlowWriter writer) {}
|
||||
virtual void on_add_reader(const std::string& port_id, mxlFlowReader reader) {}
|
||||
virtual void on_remove_writer(const std::string& port_id) = 0;
|
||||
virtual void on_remove_reader(const std::string& port_id) = 0;
|
||||
virtual void process() = 0;
|
||||
@@ -31,8 +32,15 @@ public:
|
||||
void set_mxl_instance(mxlInstance instance) { mxl_instance_ = instance; }
|
||||
mxlInstance get_mxl_instance() const { return mxl_instance_; }
|
||||
|
||||
void set_writer_config(const std::string& port_id, const mxlFlowConfigInfo& config) { writer_configs_[port_id] = config; }
|
||||
void set_reader_config(const std::string& port_id, const mxlFlowConfigInfo& config) { reader_configs_[port_id] = config; }
|
||||
const mxlFlowConfigInfo* get_writer_config(const std::string& port_id) const { auto it = writer_configs_.find(port_id); return it != writer_configs_.end() ? &it->second : nullptr; }
|
||||
const mxlFlowConfigInfo* get_reader_config(const std::string& port_id) const { auto it = reader_configs_.find(port_id); return it != reader_configs_.end() ? &it->second : nullptr; }
|
||||
|
||||
private:
|
||||
mxlInstance mxl_instance_ = nullptr;
|
||||
std::unordered_map<std::string, mxlFlowConfigInfo> writer_configs_;
|
||||
std::unordered_map<std::string, mxlFlowConfigInfo> reader_configs_;
|
||||
};
|
||||
|
||||
} // namespace dmf_node
|
||||
|
||||
@@ -116,10 +116,10 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
spdlog::error("Failed to create flow writer for flow {}: status={}", flow_id, static_cast<int>(status));
|
||||
return {{"ok", false}, {"error", "failed to create flow writer"}};
|
||||
}
|
||||
spdlog::info("Created flow writer on port '{}' flow {} (created={})", port_id, flow_id, created);
|
||||
spdlog::info("Created flow writer on port '{}' flow {} (created={})", port_id, flow_id, created);
|
||||
flow_resources.push_back({port_id, writer, nullptr});
|
||||
node->set_writer_config(port_id, config_info);
|
||||
node->on_add_writer(port_id, writer);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("add_reader", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
@@ -132,10 +132,12 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
spdlog::error("Failed to create flow reader for flow {}: status={}", flow_id, static_cast<int>(status));
|
||||
return {{"ok", false}, {"error", "failed to create flow reader"}};
|
||||
}
|
||||
spdlog::info("Created flow reader on port '{}' flow {}", port_id, flow_id);
|
||||
spdlog::info("Created flow reader on port '{}' flow {}", port_id, flow_id);
|
||||
flow_resources.push_back({port_id, nullptr, reader});
|
||||
mxlFlowConfigInfo config{};
|
||||
mxlFlowReaderGetConfigInfo(reader, &config);
|
||||
node->set_reader_config(port_id, config);
|
||||
node->on_add_reader(port_id, reader);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("remove_writer", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
|
||||
Reference in New Issue
Block a user