pub struct SubscriptionEventLoopState<T, R, S> { /* private fields */ }Expand description
The state machine for the subscription event loop.
This is made generic and removed from the subscription event loop to make it
possible for users to implement their own event loop that doesn’t depend on the
Session, which can allow for several useful features that we are unlikely to implement
in the Session itself, such as:
- Backpressure, letting users replace the
publishimplementation with one that waits for the consumer to be ready before passing the publish response to the event loop. - Custom subscription caches, for example for persisting subscription state.
Implementations§
Source§impl<T: Future<Output = Result<bool, StatusCode>>, R: Fn() -> T, S: SubscriptionCache> SubscriptionEventLoopState<T, R, S>
impl<T: Future<Output = Result<bool, StatusCode>>, R: Fn() -> T, S: SubscriptionCache> SubscriptionEventLoopState<T, R, S>
Sourcepub fn new(
session_id: u32,
trigger_publish_recv: Receiver<Instant>,
publish_limits_rx: Receiver<PublishLimits>,
publish_source: R,
subscription_cache: S,
) -> Self
pub fn new( session_id: u32, trigger_publish_recv: Receiver<Instant>, publish_limits_rx: Receiver<PublishLimits>, publish_source: R, subscription_cache: S, ) -> Self
Construct a new subscription cache.
§Arguments
session_id- The session id for logging purposes.trigger_publish_recv- A channel used to transmit external publish triggers. This is used to trigger publish outside of the normal schedule, for example when a new subscription is created.publish_limits_rx- A channel used to receive updates to publish limits.publish_source- A function that produces a future that performs a publish operation.subscription_cache- An implementation of the SubscriptionCache trait.
Sourcepub async fn iter_loop(&mut self) -> SubscriptionActivity
pub async fn iter_loop(&mut self) -> SubscriptionActivity
Run an iteration of the event loop, returning each time a publish message is received.
Auto Trait Implementations§
impl<T, R, S> !Freeze for SubscriptionEventLoopState<T, R, S>
impl<T, R, S> !RefUnwindSafe for SubscriptionEventLoopState<T, R, S>
impl<T, R, S> Send for SubscriptionEventLoopState<T, R, S>
impl<T, R, S> Sync for SubscriptionEventLoopState<T, R, S>
impl<T, R, S> Unpin for SubscriptionEventLoopState<T, R, S>
impl<T, R, S> UnsafeUnpin for SubscriptionEventLoopState<T, R, S>where
R: UnsafeUnpin,
S: UnsafeUnpin,
impl<T, R, S> !UnwindSafe for SubscriptionEventLoopState<T, R, S>
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