MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / emit

Method emit

nodedb/src/event/bus.rs:64–125  ·  view source on GitHub ↗

Try to emit a write event. Returns `true` if enqueued, `false` if dropped. The Data Plane NEVER blocks waiting for the Event Plane to process — fire-and-forget into the ring buffer. Dropped events are WAL-backed: the Event Plane detects gaps via sequence numbers and replays from WAL. Updates backpressure state after each emit. When Suspended (>95%), events are dropped more aggressively (the Even

(&mut self, event: WriteEvent)

Source from the content-addressed store, hash-verified

62 /// events are dropped more aggressively (the Event Plane will enter
63 /// WAL Catchup Mode to recover).
64 pub fn emit(&mut self, event: WriteEvent) -> bool {
65 let util = self.inner.utilization();
66
67 // Update backpressure state.
68 if let Some(new_state) = self.backpressure.update(util) {
69 match new_state {
70 PressureState::Throttled => {
71 tracing::info!(
72 core = self.core_id,
73 utilization = util,
74 "event bus backpressure: THROTTLED (>85%)"
75 );
76 }
77 PressureState::Suspended => {
78 tracing::warn!(
79 core = self.core_id,
80 utilization = util,
81 "event bus backpressure: SUSPENDED (>95%) — events will be dropped, WAL catchup needed"
82 );
83 }
84 PressureState::Normal => {
85 tracing::info!(
86 core = self.core_id,
87 utilization = util,
88 "event bus backpressure: NORMAL"
89 );
90 }
91 }
92 }
93
94 match self.inner.try_push(event) {
95 Ok(()) => true,
96 Err(BridgeError::Full { .. }) => {
97 tracing::warn!(
98 core = self.core_id,
99 utilization = util,
100 "event bus full — event dropped (WAL-backed, will replay on gap)"
101 );
102 false
103 }
104 Err(BridgeError::Disconnected { .. }) => {
105 // Consumer dropped — Event Plane is gone (shutdown or lifecycle bug).
106 // Log once per producer; further events would just be noise.
107 if !self.disconnect_logged.swap(true, Ordering::Relaxed) {
108 tracing::warn!(
109 core = self.core_id,
110 "event bus consumer disconnected — Event Plane is not running; \
111 events will be silently dropped on this core until restart"
112 );
113 }
114 false
115 }
116 Err(e) => {
117 tracing::warn!(
118 core = self.core_id,
119 error = %e,
120 "event bus push failed — event dropped"
121 );

Calls 3

try_pushMethod · 0.80
utilizationMethod · 0.45
updateMethod · 0.45