Emit a write event to the Event Plane. Called after a successful write (PointPut, PointDelete, PointUpdate, BatchInsert, BulkDelete, atomic KV ops, etc.). The Data Plane NEVER blocks here — if the ring buffer is full, the event is dropped and the Event Plane will detect the gap via sequence numbers and replay from WAL. Prefer [`CoreLoop::emit_put_event`] for any handler that performs a put-style
(
&mut self,
task: &super::super::task::ExecutionTask,
collection: &str,
op: crate::event::WriteOp,
row_id: &str,
new_value: Option<&[u8]>,
old_
| 91 | /// determined by the operation itself (kv-atomic increment, CAS, plain |
| 92 | /// delete) rather than by inspecting pre/post state. |
| 93 | pub(in crate::data::executor) fn emit_write_event( |
| 94 | &mut self, |
| 95 | task: &super::super::task::ExecutionTask, |
| 96 | collection: &str, |
| 97 | op: crate::event::WriteOp, |
| 98 | row_id: &str, |
| 99 | new_value: Option<&[u8]>, |
| 100 | old_value: Option<&[u8]>, |
| 101 | ) { |
| 102 | let producer = match self.event_producer.as_mut() { |
| 103 | Some(p) => p, |
| 104 | None => return, // Event Plane not configured. |
| 105 | }; |
| 106 | |
| 107 | self.event_sequence += 1; |
| 108 | |
| 109 | let (system_time_ms, valid_time_ms) = |
| 110 | crate::event::bitemporal_extract::extract_stamps(new_value.or(old_value)); |
| 111 | |
| 112 | let event = crate::event::WriteEvent { |
| 113 | sequence: self.event_sequence, |
| 114 | collection: Arc::from(collection), |
| 115 | op, |
| 116 | row_id: crate::event::types::RowId::new(row_id), |
| 117 | lsn: self.watermark, |
| 118 | tenant_id: task.request.tenant_id, |
| 119 | vshard_id: task.request.vshard_id, |
| 120 | source: task.request.event_source, |
| 121 | new_value: new_value.map(Arc::from), |
| 122 | old_value: old_value.map(Arc::from), |
| 123 | system_time_ms, |
| 124 | valid_time_ms, |
| 125 | user_id: task.request.user_id.clone(), |
| 126 | statement_digest: task.request.statement_digest.clone(), |
| 127 | }; |
| 128 | |
| 129 | producer.emit(event); |
| 130 | } |
| 131 | |
| 132 | /// Emit a heartbeat event to advance the Event Plane's partition watermark. |
| 133 | /// |
no test coverage detected