pub struct EventRouter { /* private fields */ }
Expand description
Core archivist internal event router that supports multiple event producers and multiple event consumers.
Implementations§
Source§impl EventRouter
impl EventRouter
Sourcepub fn add_producer<T>(&mut self, config: ProducerConfig<'_, T>)where
T: EventProducer,
pub fn add_producer<T>(&mut self, config: ProducerConfig<'_, T>)where
T: EventProducer,
Registers an event producer with the given configuration specifying the types of events the given producer is allowed to emit.
Sourcepub fn add_consumer<T>(&mut self, config: ConsumerConfig<'_, T>)
pub fn add_consumer<T>(&mut self, config: ConsumerConfig<'_, T>)
Registers an event consumer with the given configuration specifying the types of events the given consumer will receive.
Sourcepub fn start(
self,
) -> Result<(TerminateHandle, impl Future<Output = ()>), RouterError>
pub fn start( self, ) -> Result<(TerminateHandle, impl Future<Output = ()>), RouterError>
Starts listening for events emitted by the registered producers and dispatching them to registered consumers.
First, validates that for every event type that will be dispatched, there exists at least one consumer. And that for every event that will be consumed, there exists at least one producer.
Afterwards, listens to events emitted by producers. When an event arrives it sends it to all consumers of the event. Since all events are singletons, the first consumer that was registered will get the singleton data and the rest won’t.
Auto Trait Implementations§
impl Freeze for EventRouter
impl !RefUnwindSafe for EventRouter
impl Send for EventRouter
impl Sync for EventRouter
impl Unpin for EventRouter
impl !UnwindSafe for EventRouter
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> IntoAny for T
impl<T> IntoAny for T
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 more