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]>,
| 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) { |
no test coverage detected