Read events from a specific partition, starting after `from_lsn`. Partition = vShard ID. Scans the buffer and filters by partition.
(
&self,
partition_id: u32,
from_lsn: u64,
limit: usize,
)
| 140 | /// Read events from a specific partition, starting after `from_lsn`. |
| 141 | /// Partition = vShard ID. Scans the buffer and filters by partition. |
| 142 | pub fn read_partition_from_lsn( |
| 143 | &self, |
| 144 | partition_id: u32, |
| 145 | from_lsn: u64, |
| 146 | limit: usize, |
| 147 | ) -> Vec<Arc<CdcEvent>> { |
| 148 | let events = self.events.read().unwrap_or_else(|p| p.into_inner()); |
| 149 | events |
| 150 | .iter() |
| 151 | .filter(|e| e.partition == partition_id && e.lsn > from_lsn) |
| 152 | .take(limit) |
| 153 | .cloned() |
| 154 | .collect() |
| 155 | } |
| 156 | |
| 157 | /// Compact the buffer: deduplicate by key field, keeping only the latest |
| 158 | /// event per key value. DELETE events are retained as tombstones until |