pub struct ChangelogDrainer { /* private fields */ }Expand description
Drains a Ring 0 StateChangelogBuffer from Ring 1.
The drainer is the consumer side of the SPSC changelog buffer.
It pops entries to relieve Ring 0 backpressure and tracks
metadata for observability. Pending entries are cleared after
each successful checkpoint via clear_pending().
Implementations§
Source§impl ChangelogDrainer
impl ChangelogDrainer
Sourcepub fn new(buffer: Arc<StateChangelogBuffer>, max_batch_size: usize) -> Self
pub fn new(buffer: Arc<StateChangelogBuffer>, max_batch_size: usize) -> Self
Creates a new drainer for the given changelog buffer.
Sourcepub fn with_max_pending(self, max_pending: usize) -> Self
pub fn with_max_pending(self, max_pending: usize) -> Self
Sets the upper bound on pending entries.
When pending exceeds this limit during drain(),
older entries are discarded to prevent unbounded memory growth.
Sourcepub fn drain(&mut self) -> usize
pub fn drain(&mut self) -> usize
Drains available entries from the buffer into the pending batch.
If pending is at the max_pending limit, the oldest half of
pending entries are discarded to make room. Returns the number
of new entries drained from the buffer.
Sourcepub fn take_pending(&mut self) -> Vec<StateChangelogEntry>
pub fn take_pending(&mut self) -> Vec<StateChangelogEntry>
Takes the pending batch, leaving an empty pending buffer.
After calling this, the drainer’s pending buffer is cleared and ready to accumulate more entries. The allocation is NOT reused.
Sourcepub fn clear_pending(&mut self)
pub fn clear_pending(&mut self)
Clears the pending buffer, reusing the existing allocation.
Call this after a successful checkpoint to release the metadata entries — they’re no longer needed once the checkpoint has captured the full state.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Returns the number of pending (un-taken) entries.
Sourcepub fn pending(&self) -> &[StateChangelogEntry]
pub fn pending(&self) -> &[StateChangelogEntry]
Returns a reference to the pending entries.
Sourcepub fn total_drained(&self) -> u64
pub fn total_drained(&self) -> u64
Returns the total number of entries drained over the drainer’s lifetime.
Sourcepub fn buffer(&self) -> &StateChangelogBuffer
pub fn buffer(&self) -> &StateChangelogBuffer
Returns a reference to the underlying changelog buffer.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChangelogDrainer
impl !RefUnwindSafe for ChangelogDrainer
impl Send for ChangelogDrainer
impl Sync for ChangelogDrainer
impl Unpin for ChangelogDrainer
impl UnsafeUnpin for ChangelogDrainer
impl !UnwindSafe for ChangelogDrainer
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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