pub struct AdvancedSubscriber<Receiver> { /* private fields */ }Expand description
The extension to Subscriber that provides advanced functionalities
The AdvancedSubscriber is constructed over a regular Subscriber
through advanced method or by using
any other method of AdvancedSubscriberBuilder.
The AdvancedSubscriber works with AdvancedPublisher to provide additional functionalities such as:
- missing samples detection using periodic queries or heartbeat subscription configurable with
recoverymethod - recovering missing samples, configured with
historymethod (max age and sample count, late joiner detection and requesting) - liveliness-based subscriber detection with
subscriber_detectionmethod
§Examples
use zenoh_ext::{AdvancedSubscriberBuilderExt, HistoryConfig, RecoveryConfig};
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let subscriber = session
.declare_subscriber("key/expression")
.history(HistoryConfig::default().detect_late_publishers())
.recovery(RecoveryConfig::default().heartbeat())
.subscriber_detection()
.await
.unwrap();
let miss_listener = subscriber.sample_miss_listener().await.unwrap();
loop {
tokio::select! {
sample = subscriber.recv_async() => {
if let Ok(sample) = sample {
// ...
}
},
miss = miss_listener.recv_async() => {
if let Ok(miss) = miss {
// ...
}
},
}
}Implementations§
Source§impl<Handler> AdvancedSubscriber<Handler>
impl<Handler> AdvancedSubscriber<Handler>
Sourcepub fn id(&self) -> EntityGlobalId
pub fn id(&self) -> EntityGlobalId
Returns the EntityGlobalId of this AdvancedSubscriber.
Sourcepub fn key_expr(&self) -> &KeyExpr<'static>
pub fn key_expr(&self) -> &KeyExpr<'static>
Returns the KeyExpr this subscriber subscribes to.
Sourcepub fn handler(&self) -> &Handler
pub fn handler(&self) -> &Handler
Returns a reference to this subscriber’s handler.
Sourcepub fn handler_mut(&mut self) -> &mut Handler
pub fn handler_mut(&mut self) -> &mut Handler
Returns a mutable reference to this subscriber’s handler.
Sourcepub fn sample_miss_listener(
&self,
) -> SampleMissListenerBuilder<'_, DefaultHandler>
pub fn sample_miss_listener( &self, ) -> SampleMissListenerBuilder<'_, DefaultHandler>
Declares a listener to detect missed samples.
Missed samples can only be detected from AdvancedPublisher that
enable sample_miss_detection.
Sourcepub fn detect_publishers(
&self,
) -> LivelinessSubscriberBuilder<'_, '_, DefaultHandler>
pub fn detect_publishers( &self, ) -> LivelinessSubscriberBuilder<'_, '_, DefaultHandler>
Declares a listener to detect matching publishers.
Only AdvancedPublisher that enable
publisher_detection can be detected.
Trait Implementations§
Source§impl<Receiver> Deref for AdvancedSubscriber<Receiver>
Available on crate feature unstable only.
impl<Receiver> Deref for AdvancedSubscriber<Receiver>
unstable only.Auto Trait Implementations§
impl<Receiver> Freeze for AdvancedSubscriber<Receiver>where
Receiver: Freeze,
impl<Receiver> !RefUnwindSafe for AdvancedSubscriber<Receiver>
impl<Receiver> Send for AdvancedSubscriber<Receiver>where
Receiver: Send,
impl<Receiver> Sync for AdvancedSubscriber<Receiver>where
Receiver: Sync,
impl<Receiver> Unpin for AdvancedSubscriber<Receiver>where
Receiver: Unpin,
impl<Receiver> !UnwindSafe for AdvancedSubscriber<Receiver>
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
Access::load.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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random to avoid conflict with the new gen keyword in Rust 2024.Rng::random.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_rangeRng::random_range.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore to a RngReadAdapter.