pub trait Queue<TKey, TMsg>: Send + 'static{
// Required methods
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn pop_front(&mut self) -> Option<Job<TKey, TMsg>>;
fn discard_oldest(&mut self) -> Option<Job<TKey, TMsg>>;
fn peek(&self) -> Option<&Job<TKey, TMsg>>;
fn push_back(&mut self, job: Job<TKey, TMsg>);
fn remove_expired_items(
&mut self,
discard_handler: &Option<Arc<dyn DiscardHandler<TKey, TMsg>>>,
) -> usize;
// Provided method
fn is_job_discardable(&self, _key: &TKey) -> bool { ... }
}Expand description
Implementation of backing queue for factory messages when workers are all busy
Required Methods§
Sourcefn pop_front(&mut self) -> Option<Job<TKey, TMsg>>
fn pop_front(&mut self) -> Option<Job<TKey, TMsg>>
Pop the next message from the front of the queue
Sourcefn discard_oldest(&mut self) -> Option<Job<TKey, TMsg>>
fn discard_oldest(&mut self) -> Option<Job<TKey, TMsg>>
Try and discard a message according to the queue semantics
in an overload scenario (e.g. lowest priority if priority
queueing). In a basic queueing scenario, this is equivalent
to pop_front
Sourcefn remove_expired_items(
&mut self,
discard_handler: &Option<Arc<dyn DiscardHandler<TKey, TMsg>>>,
) -> usize
fn remove_expired_items( &mut self, discard_handler: &Option<Arc<dyn DiscardHandler<TKey, TMsg>>>, ) -> usize
Remove expired items from the queue
discard_handler- The handler to call for each discarded job. Will be called with DiscardReason::TtlExpired.
Returns the number of elements removed from the queue
Provided Methods§
Sourcefn is_job_discardable(&self, _key: &TKey) -> bool
fn is_job_discardable(&self, _key: &TKey) -> bool
Determine if a given job can be discarded. Default is true for all jobs.
This can be overridden to customize discard semantics.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".