Persist the last-processed LSN for a given core.
(&self, core_id: usize, lsn: Lsn)
| 98 | |
| 99 | /// Persist the last-processed LSN for a given core. |
| 100 | pub fn save(&self, core_id: usize, lsn: Lsn) -> crate::Result<()> { |
| 101 | let key = core_key(core_id); |
| 102 | let value = lsn.as_u64().to_le_bytes(); |
| 103 | |
| 104 | let txn = self.db.begin_write().map_err(|e| crate::Error::Storage { |
| 105 | engine: "event_plane".into(), |
| 106 | detail: format!("begin_write: {e}"), |
| 107 | })?; |
| 108 | { |
| 109 | let mut table = txn |
| 110 | .open_table(WATERMARKS) |
| 111 | .map_err(|e| crate::Error::Storage { |
| 112 | engine: "event_plane".into(), |
| 113 | detail: format!("open_table: {e}"), |
| 114 | })?; |
| 115 | table |
| 116 | .insert(key.as_str(), value.as_slice()) |
| 117 | .map_err(|e| crate::Error::Storage { |
| 118 | engine: "event_plane".into(), |
| 119 | detail: format!("insert watermark core {core_id}: {e}"), |
| 120 | })?; |
| 121 | } |
| 122 | txn.commit().map_err(|e| crate::Error::Storage { |
| 123 | engine: "event_plane".into(), |
| 124 | detail: format!("commit watermark core {core_id}: {e}"), |
| 125 | })?; |
| 126 | |
| 127 | Ok(()) |
| 128 | } |
| 129 | |
| 130 | /// Load watermarks for all cores (0..num_cores). |
| 131 | pub fn load_all(&self, num_cores: usize) -> crate::Result<Vec<Lsn>> { |