Stream the `range` of transaction offsets from the commitlog in `repo` as raw commitlog data. The stream contains segment headers as they are encountered scanning the `range`. Only whole [`commit::StoredCommit`]s are yielded, so a `range` that doesn't fall on commit boundaries may yield extra data. Only the headers of the source commitlog are inspected (in order to be able to satisfy the `range
(repo: R, range: impl RangeBounds<u64>)
| 39 | /// If the commitlog is empty, that is does not contain any commits, the |
| 40 | /// returned stream yields nothing. |
| 41 | pub fn commits<R>(repo: R, range: impl RangeBounds<u64>) -> impl Stream<Item = io::Result<Bytes>> |
| 42 | where |
| 43 | R: AsyncRepo + Send + 'static, |
| 44 | { |
| 45 | let mut range = RangeFromMaybeToInclusive::from_range_bounds(range); |
| 46 | let retain = move |segments: Vec<_>| retain_range(&segments, range); |
| 47 | try_stream! { |
| 48 | let segments = repo.existing_offsets().map(retain)?; |
| 49 | for segment_offset in segments { |
| 50 | if range.start < segment_offset { |
| 51 | range.start = segment_offset; |
| 52 | } |
| 53 | trace!("segment: segment={} start={}", segment_offset, range.start); |
| 54 | |
| 55 | let segment = repo.open_segment_reader_async(segment_offset).await?; |
| 56 | |
| 57 | for await chunk in read_segment(repo.clone(), segment, segment_offset, range) { |
| 58 | yield chunk.inspect_err(|e| warn!("error reading segment {segment_offset}: {e}"))?; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | fn read_segment( |
| 65 | repo: impl Repo + Send + 'static, |
nothing calls this directly
no test coverage detected
searching dependent graphs…