Open a new WAL segment file with a specific starting LSN. Used by `SegmentedWal` when rolling to a new segment. The file must not already exist (or be empty). The writer will assign LSNs starting from `start_lsn`.
(
path: &Path,
config: WalWriterConfig,
start_lsn: u64,
)
| 223 | /// not already exist (or be empty). The writer will assign LSNs starting |
| 224 | /// from `start_lsn`. |
| 225 | pub fn open_with_start_lsn( |
| 226 | path: &Path, |
| 227 | config: WalWriterConfig, |
| 228 | start_lsn: u64, |
| 229 | ) -> Result<Self> { |
| 230 | let mut opts = OpenOptions::new(); |
| 231 | opts.create(true).write(true).append(false); |
| 232 | |
| 233 | #[cfg(not(target_arch = "wasm32"))] |
| 234 | if config.use_direct_io { |
| 235 | opts.custom_flags(libc::O_DIRECT); |
| 236 | } |
| 237 | |
| 238 | let file = opts.open(path)?; |
| 239 | let buffer = AlignedBuf::new(config.write_buffer_size, config.alignment)?; |
| 240 | |
| 241 | let double_write = open_dwb_for(&config, path); |
| 242 | |
| 243 | Ok(Self { |
| 244 | file, |
| 245 | buffer, |
| 246 | file_offset: 0, |
| 247 | next_lsn: AtomicU64::new(start_lsn), |
| 248 | sealed: false, |
| 249 | config, |
| 250 | encryption_ring: None, |
| 251 | segment_preamble: None, |
| 252 | double_write, |
| 253 | }) |
| 254 | } |
| 255 | |
| 256 | /// Open a WAL writer with O_DIRECT disabled (for testing on tmpfs, etc.). |
| 257 | pub fn open_without_direct_io(path: &Path) -> Result<Self> { |
nothing calls this directly
no test coverage detected