pub struct NotificationBatcher { /* private fields */ }Expand description
Accumulates events per source and flushes as batches.
Used by the Ring 1 dispatcher to reduce per-event overhead when delivering to subscribers. Each source has its own buffer, so events from different sources are never mixed.
Implementations§
Source§impl NotificationBatcher
impl NotificationBatcher
Sourcepub fn new(config: BatchConfig) -> Self
pub fn new(config: BatchConfig) -> Self
Creates a new batcher with the given configuration.
Sourcepub fn add(
&mut self,
source_id: u32,
source_name: &str,
event: ChangeEvent,
) -> Option<ChangeEventBatch>
pub fn add( &mut self, source_id: u32, source_name: &str, event: ChangeEvent, ) -> Option<ChangeEventBatch>
Adds an event to the batcher.
Returns Some(ChangeEventBatch) if the batch is ready to deliver
(size or time trigger), or None if the event was buffered.
When batching is disabled, always returns a single-event batch.
Sourcepub fn flush_all(&mut self) -> Vec<(u32, ChangeEventBatch)>
pub fn flush_all(&mut self) -> Vec<(u32, ChangeEventBatch)>
Forces flush of all pending batches.
Returns a vec of (source_id, batch) for all non-empty buffers.
Sourcepub fn flush_expired(&mut self) -> Vec<(u32, ChangeEventBatch)>
pub fn flush_expired(&mut self) -> Vec<(u32, ChangeEventBatch)>
Flushes batches that have exceeded the max_batch_delay.
Returns a vec of (source_id, batch) for expired buffers.
Sourcepub fn buffered_count(&self) -> usize
pub fn buffered_count(&self) -> usize
Returns the number of buffered events across all sources.
Sourcepub fn config(&self) -> &BatchConfig
pub fn config(&self) -> &BatchConfig
Returns the configuration.
Auto Trait Implementations§
impl Freeze for NotificationBatcher
impl !RefUnwindSafe for NotificationBatcher
impl Send for NotificationBatcher
impl Sync for NotificationBatcher
impl Unpin for NotificationBatcher
impl !UnwindSafe for NotificationBatcher
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.