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

Function accumulate_data_event

nodedb/src/event/consumer_helpers.rs:158–197  ·  view source on GitHub ↗

Dispatch a data write event (op.is_data_event() == true): advances wall-time watermark, batches triggers, routes CDC, updates permission cache, feeds streaming MVs and CRDT sync. Returns a completed trigger batch if the collector filled on this event.

(
    event: &WriteEvent,
    shared_state: &Arc<SharedState>,
    trigger_collector: &mut crate::control::trigger::batch::collector::TriggerBatchCollector,
    cdc_router: &Arc<super::cdc::CdcRouter>

Source from the content-addressed store, hash-verified

156///
157/// Returns a completed trigger batch if the collector filled on this event.
158pub fn accumulate_data_event(
159 event: &WriteEvent,
160 shared_state: &Arc<SharedState>,
161 trigger_collector: &mut crate::control::trigger::batch::collector::TriggerBatchCollector,
162 cdc_router: &Arc<super::cdc::CdcRouter>,
163) -> Option<crate::control::trigger::batch::collector::TriggerBatch> {
164 let event_time_ms = std::time::SystemTime::now()
165 .duration_since(std::time::UNIX_EPOCH)
166 .unwrap_or_default()
167 .as_millis() as u64;
168 shared_state.watermark_tracker.advance(
169 event.vshard_id.as_u32(),
170 event.lsn.as_u64(),
171 event_time_ms,
172 );
173
174 let batch =
175 crate::control::trigger::batch::collector::push_write_event(trigger_collector, event);
176
177 cdc_router.route_event(event, &shared_state.watermark_tracker);
178 crate::control::security::permission_tree::event_handler::handle_permission_event(
179 event,
180 &shared_state.permission_cache,
181 );
182 let matching_streams = shared_state
183 .stream_registry
184 .find_matching(event.tenant_id.as_u64(), &event.collection);
185 for stream_def in &matching_streams {
186 super::streaming_mv::processor::process_write_event_for_mvs(
187 event,
188 &shared_state.mv_registry,
189 &stream_def.name,
190 );
191 }
192 shared_state
193 .delta_packager
194 .package_and_enqueue(event, &shared_state.crdt_sync_delivery);
195
196 batch
197}

Callers 1

process_normal_batchFunction · 0.85

Calls 12

nowFunction · 0.85
push_write_eventFunction · 0.85
handle_permission_eventFunction · 0.85
duration_sinceMethod · 0.80
route_eventMethod · 0.80
find_matchingMethod · 0.80
package_and_enqueueMethod · 0.80
as_millisMethod · 0.45
advanceMethod · 0.45
as_u32Method · 0.45
as_u64Method · 0.45

Tested by

no test coverage detected