Added callbacks for node errors and fifo overflow
Add new doc system which should/might deploy to pages.
This commit is contained in:
+19
-1
@@ -44,6 +44,9 @@ public:
|
||||
using DiagnosticsHandler =
|
||||
std::function<void(const std::vector<NodeSnapshot>&,
|
||||
const std::vector<ChannelSnapshot>&)>;
|
||||
using EventHandler =
|
||||
std::function<void(std::string_view node_name, NodeEvent,
|
||||
std::chrono::steady_clock::time_point)>;
|
||||
|
||||
// ── Builder API ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -111,6 +114,19 @@ public:
|
||||
for (auto& [name, _] : nodes_)
|
||||
if (color[name] == 0)
|
||||
dfs(name, color);
|
||||
if (event_handler_) {
|
||||
for (auto& name : topo_) {
|
||||
auto* node = nodes_.at(name);
|
||||
node->set_network_overflow_callback(
|
||||
[this, n = name](auto ts) {
|
||||
event_handler_(n, NodeEvent::Overflow, ts);
|
||||
});
|
||||
node->set_network_closed_callback(
|
||||
[this, n = name](auto ts) {
|
||||
event_handler_(n, NodeEvent::Closed, ts);
|
||||
});
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -194,8 +210,9 @@ public:
|
||||
watchdog_interval_ = interval;
|
||||
}
|
||||
|
||||
void set_error_handler(ErrorHandler h) { error_handler_ = std::move(h); }
|
||||
void set_error_handler(ErrorHandler h) { error_handler_ = std::move(h); }
|
||||
void set_diagnostics_handler(DiagnosticsHandler h) { diag_handler_ = std::move(h); }
|
||||
void set_event_handler(EventHandler h) { event_handler_ = std::move(h); }
|
||||
|
||||
void register_pool(const std::string& name, IPoolProbe* probe) {
|
||||
pool_probes_.emplace_back(name, probe);
|
||||
@@ -430,6 +447,7 @@ private:
|
||||
std::vector<std::pair<std::string, IPoolProbe*>> pool_probes_;
|
||||
ErrorHandler error_handler_;
|
||||
DiagnosticsHandler diag_handler_;
|
||||
EventHandler event_handler_;
|
||||
std::chrono::milliseconds watchdog_interval_{3000};
|
||||
std::jthread watchdog_;
|
||||
clock_t::time_point start_time_;
|
||||
|
||||
Reference in New Issue
Block a user