pub struct RedisEventBus { /* private fields */ }Expand description
Redis-backed transient event publisher and reconnecting subscriber.
Implementations§
Source§impl RedisEventBus
impl RedisEventBus
Sourcepub fn from_url(
url: &str,
topic: impl Into<String>,
) -> Result<Self, RedisEventBusError>
pub fn from_url( url: &str, topic: impl Into<String>, ) -> Result<Self, RedisEventBusError>
Creates a bus from a Redis URL and logical topic.
Sourcepub fn from_client(client: Client, topic: impl Into<String>) -> Self
pub fn from_client(client: Client, topic: impl Into<String>) -> Self
Creates a bus from an existing Redis client.
Sourcepub fn with_reconnect_policy(self, policy: RedisEventReconnectPolicy) -> Self
pub fn with_reconnect_policy(self, policy: RedisEventReconnectPolicy) -> Self
Overrides the reconnect policy.
Sourcepub async fn publish(
&self,
payload: impl Into<String>,
) -> Result<(), RedisEventBusError>
pub async fn publish( &self, payload: impl Into<String>, ) -> Result<(), RedisEventBusError>
Publishes one opaque payload. Payload interpretation belongs to the product layer.
Sourcepub async fn subscribe(
&self,
) -> Result<RedisEventSubscription, RedisEventBusError>
pub async fn subscribe( &self, ) -> Result<RedisEventSubscription, RedisEventBusError>
Opens one Redis subscription attempt.
Sourcepub async fn run_subscription<F, Fut>(
&self,
shutdown: CancellationToken,
observer: Option<&dyn EventConnectionObserver>,
on_payload: F,
)
pub async fn run_subscription<F, Fut>( &self, shutdown: CancellationToken, observer: Option<&dyn EventConnectionObserver>, on_payload: F, )
Runs a reconnecting subscription until shutdown is cancelled.
Malformed Redis payloads are logged and skipped. The callback is responsible for decoding the product payload and deciding whether an event belongs to the current runtime.
Trait Implementations§
Source§impl Clone for RedisEventBus
impl Clone for RedisEventBus
Source§fn clone(&self) -> RedisEventBus
fn clone(&self) -> RedisEventBus
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl EventSubscriptionSource for RedisEventBus
impl EventSubscriptionSource for RedisEventBus
Source§type Subscription = RedisEventSubscription
type Subscription = RedisEventSubscription
One active transport subscription.
Source§type Error = RedisEventBusError
type Error = RedisEventBusError
Transport error returned by subscribe or receive.
Source§fn subscribe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Subscription, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Subscription, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Opens one subscription attempt.
Source§fn receive<'life0, 'life1, 'async_trait>(
&'life0 self,
subscription: &'life1 mut Self::Subscription,
) -> Pin<Box<dyn Future<Output = Result<Self::Item, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn receive<'life0, 'life1, 'async_trait>(
&'life0 self,
subscription: &'life1 mut Self::Subscription,
) -> Pin<Box<dyn Future<Output = Result<Self::Item, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Receives one item from an active subscription.
Auto Trait Implementations§
impl Freeze for RedisEventBus
impl RefUnwindSafe for RedisEventBus
impl Send for RedisEventBus
impl Sync for RedisEventBus
impl Unpin for RedisEventBus
impl UnsafeUnpin for RedisEventBus
impl UnwindSafe for RedisEventBus
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