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

Function push_write_event

nodedb/src/control/trigger/batch/collector.rs:326–351  ·  view source on GitHub ↗

Convert a [`WriteEvent`] into a [`TriggerBatchRow`] and push to the collector. Returns `Some(TriggerBatch)` if the push completes or flushes a batch. Returns `None` for non-triggerable events or if the batch isn't full yet. Stores raw bytes from the WriteEvent — no deserialization at ingestion time. The row decodes lazily when a trigger body or WHEN clause accesses the fields.

(
    collector: &mut TriggerBatchCollector,
    event: &crate::event::types::WriteEvent,
)

Source from the content-addressed store, hash-verified

324/// Stores raw bytes from the WriteEvent — no deserialization at ingestion time.
325/// The row decodes lazily when a trigger body or WHEN clause accesses the fields.
326pub fn push_write_event(
327 collector: &mut TriggerBatchCollector,
328 event: &crate::event::types::WriteEvent,
329) -> Option<TriggerBatch> {
330 use crate::event::types::{EventSource, WriteOp};
331
332 // Only User-originated events fire triggers.
333 if !matches!(event.source, EventSource::User) {
334 return None;
335 }
336
337 let op_str = match event.op {
338 WriteOp::Insert => "INSERT",
339 WriteOp::Update => "UPDATE",
340 WriteOp::Delete => "DELETE",
341 _ => return None,
342 };
343
344 let row = TriggerBatchRow::from_raw(
345 event.new_value.clone(),
346 event.old_value.clone(),
347 event.row_id.as_str().to_string(),
348 );
349
350 collector.push(&event.collection, op_str, event.tenant_id.as_u64(), row)
351}
352
353#[cfg(test)]
354mod tests {

Callers 1

accumulate_data_eventFunction · 0.85

Calls 5

to_stringMethod · 0.80
cloneMethod · 0.45
as_strMethod · 0.45
pushMethod · 0.45
as_u64Method · 0.45

Tested by

no test coverage detected