pub struct PeerLogScanner { /* private fields */ }Expand description
A LogScanner backed by an in-memory queue of (vlsn, type, payload)
entries.
Entries are pushed by the ReplicaReceiver as they arrive from the
master (or from another peer). The PeerFeederRunner consumes entries
from this queue and streams them to a downstream replica.
§Bounded memory (F10)
The queue has two configurable bounds:
max_entries: maximum entry count (defaultDEFAULT_PEER_SCANNER_MAX_ENTRIES).max_bytes: maximum cumulative payload size in bytes (defaultDEFAULT_PEER_SCANNER_MAX_BYTES).
On push, if either bound is exceeded the oldest entries are
evicted from the front of the queue until both bounds are
satisfied. The evicted entries are no longer available for peer
streaming through this scanner; downstream peers that fall behind
the eviction window must catch up via the on-disk
EnvironmentLogScanner or via network restore. This matches
HA semantics where peer-to-peer log distribution is
best-effort and the on-disk log is the durable source.
Closes finding F10 of docs/src/internal/api-audit-2026-05-rep.md.
Thread safety: the queue is protected by a Mutex so that the receiver
thread (writer) and the feeder thread (reader) can operate concurrently.
Implementations§
Source§impl PeerLogScanner
impl PeerLogScanner
Sourcepub fn with_capacity(max_entries: usize, max_bytes: usize) -> Self
pub fn with_capacity(max_entries: usize, max_bytes: usize) -> Self
Create an empty scanner with explicit bounds.
max_entries and max_bytes are both honoured; whichever is
breached first triggers oldest-evicting on subsequent push
calls. Passing usize::MAX disables the corresponding bound
(not recommended in production).
Sourcepub fn push(&self, vlsn: u64, entry_type: u8, payload: Vec<u8>)
pub fn push(&self, vlsn: u64, entry_type: u8, payload: Vec<u8>)
Push a log entry into the scanner’s queue.
Called by the ReplicaReceiver each time an entry is applied.
Entries are expected to be pushed in VLSN order, but this method is
not enforcing: every entry is appended to the queue unconditionally
and the cached (first_vlsn, last_vlsn) range is widened to cover
the new VLSN. Out-of-order or duplicate entries are filtered later
by LogScanner::next_entry,
which skips entries with vlsn < from_vlsn.
F10 bound: after the new entry is appended, if the queue
exceeds either max_entries or max_bytes, the oldest entries
are evicted from the front until both bounds are satisfied. The
retained first_vlsn is updated to the new front-of-queue VLSN
so downstream peers that ask for an evicted VLSN range observe
log_range().first > from_vlsn and know they must catch up via
the durable log.
Sourcepub fn evicted_count(&self) -> u64
pub fn evicted_count(&self) -> u64
Cumulative number of entries dropped by the F10 bound since scanner construction. Useful for monitoring whether downstream peers are keeping up.
Sourcepub fn current_bytes(&self) -> usize
pub fn current_bytes(&self) -> usize
Current cumulative payload size in bytes (live snapshot).
Trait Implementations§
Source§impl Default for PeerLogScanner
impl Default for PeerLogScanner
Source§impl LogScanner for PeerLogScanner
impl LogScanner for PeerLogScanner
Auto Trait Implementations§
impl !Freeze for PeerLogScanner
impl !RefUnwindSafe for PeerLogScanner
impl Send for PeerLogScanner
impl Sync for PeerLogScanner
impl Unpin for PeerLogScanner
impl UnsafeUnpin for PeerLogScanner
impl UnwindSafe for PeerLogScanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more