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

Method emit_put_event

nodedb/src/data/executor/core_loop/event_emit.rs:41–71  ·  view source on GitHub ↗

Emit a point write/overwrite/update event derived from the new bytes produced by the handler and the prior bytes returned from storage. Shared by every handler that runs a put-style mutation against a document engine: PointPut, Upsert (both branches), batched PointPut, columnar-row overwrite. Each of these knows its *new* bytes and receives *prior* bytes from the storage API; the Event Plane payl

(
        &mut self,
        task: &super::super::task::ExecutionTask,
        tid: u64,
        collection: &str,
        row_id: &str,
        new_stored: &[u8],
        prior_stored: Option<&[u8]>,

Source from the content-addressed store, hash-verified

39 /// applying the strict→msgpack shim, and the `WriteOp` tag is computed
40 /// from their presence.
41 pub(in crate::data::executor) fn emit_put_event(
42 &mut self,
43 task: &super::super::task::ExecutionTask,
44 tid: u64,
45 collection: &str,
46 row_id: &str,
47 new_stored: &[u8],
48 prior_stored: Option<&[u8]>,
49 ) {
50 let new_converted = self.resolve_event_payload(tid, collection, new_stored);
51 let old_converted =
52 prior_stored.and_then(|p| self.resolve_event_payload(tid, collection, p));
53 let old_bytes: Option<&[u8]> = match (prior_stored, old_converted.as_deref()) {
54 (Some(_), Some(c)) => Some(c),
55 (Some(raw), None) => Some(raw),
56 (None, _) => None,
57 };
58 let op = if old_bytes.is_some() {
59 crate::event::WriteOp::Update
60 } else {
61 crate::event::WriteOp::Insert
62 };
63 self.emit_write_event(
64 task,
65 collection,
66 op,
67 row_id,
68 Some(new_converted.as_deref().unwrap_or(new_stored)),
69 old_bytes,
70 );
71 }
72
73 /// Set the Event Plane producer (called after open, before event loop).
74 pub fn set_event_producer(&mut self, producer: crate::event::bus::EventProducer) {

Callers 5

execute_upsertMethod · 0.80
poll_write_batchMethod · 0.80
execute_point_updateMethod · 0.80
execute_point_insertMethod · 0.80
execute_point_putMethod · 0.80

Calls 2

resolve_event_payloadMethod · 0.80
emit_write_eventMethod · 0.80

Tested by

no test coverage detected