pub struct InMemoryBus { /* private fields */ }Expand description
In-memory bus backed by tokio::sync::broadcast.
Implementations§
Source§impl InMemoryBus
impl InMemoryBus
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new bus with the given channel capacity. Lagged receivers will skip missed events (lossy).
Sourcepub fn default_capacity() -> Self
pub fn default_capacity() -> Self
Default capacity suitable for most single-process deployments.
Trait Implementations§
Source§impl EventBus for InMemoryBus
impl EventBus for InMemoryBus
Source§fn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Publish an event to all subscribers.
Source§fn subscribe(&self) -> Box<dyn EventSubscriber>
fn subscribe(&self) -> Box<dyn EventSubscriber>
Create a new subscriber that receives all future events.
Source§fn subscriber_count(&self) -> usize
fn subscriber_count(&self) -> usize
Number of active subscribers.
Source§fn replay_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_topic: Option<&'life1 str>,
_since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn replay_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_topic: Option<&'life1 str>,
_since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Replay events since a given event ID (exclusive). Returns events in order.
If
since_id is None, replays all events. If the bus does not support
persistence, returns an empty vec.Source§fn gc_older_than<'life0, 'async_trait>(
&'life0 self,
_max_age: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn gc_older_than<'life0, 'async_trait>(
&'life0 self,
_max_age: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete events older than the given age. Returns count of deleted events.
No-op for buses that don’t support persistence.
Auto Trait Implementations§
impl Freeze for InMemoryBus
impl RefUnwindSafe for InMemoryBus
impl Send for InMemoryBus
impl Sync for InMemoryBus
impl Unpin for InMemoryBus
impl UnsafeUnpin for InMemoryBus
impl UnwindSafe for InMemoryBus
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