pub struct DocumentQueue { /* private fields */ }Expand description
A bounded in-memory queue of documents awaiting delivery.
When it fills, the oldest documents are dropped. Dropping the newest would be easier but wrong: during an outage the recent events are the ones describing what is going wrong, and they are what a beta debugger needs.
Implementations§
Source§impl DocumentQueue
impl DocumentQueue
pub fn new(capacity: usize) -> Self
Sourcepub fn push(&mut self, document: ForwardDocument)
pub fn push(&mut self, document: ForwardDocument)
Add a document, evicting the oldest if the queue is full.
Sourcepub fn take_batch(
&mut self,
max_documents: usize,
max_bytes: usize,
) -> Vec<ForwardDocument>
pub fn take_batch( &mut self, max_documents: usize, max_bytes: usize, ) -> Vec<ForwardDocument>
Take the next batch, bounded by both document count and approximate size.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DocumentQueue
impl RefUnwindSafe for DocumentQueue
impl Send for DocumentQueue
impl Sync for DocumentQueue
impl Unpin for DocumentQueue
impl UnsafeUnpin for DocumentQueue
impl UnwindSafe for DocumentQueue
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> 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> ⓘ
Converts
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> ⓘ
Converts
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