pub struct CrossChainEventBus { /* private fields */ }Expand description
Fan-out broadcast bus that aggregates events from all managed chains.
Multiple subscribers can each receive every event via
tokio::sync::broadcast. If a subscriber falls behind and the buffer
fills, lagged events are dropped for that subscriber (the channel returns
broadcast::error::RecvError::Lagged).
Implementations§
Source§impl CrossChainEventBus
impl CrossChainEventBus
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new bus with the given channel capacity.
capacity is the maximum number of events buffered per subscriber
before the oldest events are dropped. A value of 1024 is a reasonable
default for most use cases.
Sourcepub fn push(&self, chain: &str, event: DecodedEvent) -> usize
pub fn push(&self, chain: &str, event: DecodedEvent) -> usize
Push an event from chain onto the bus.
Returns the number of active subscribers that received the event. If there are no subscribers, the event is silently discarded.
Sourcepub fn subscribe(&self) -> CrossChainReceiver
pub fn subscribe(&self) -> CrossChainReceiver
Subscribe to the event bus.
Each subscriber receives a clone of every event pushed after the subscription is created.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Returns the number of active subscribers.
Trait Implementations§
Source§impl Clone for CrossChainEventBus
impl Clone for CrossChainEventBus
Source§fn clone(&self) -> CrossChainEventBus
fn clone(&self) -> CrossChainEventBus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more