pub struct KafkaEventStream<C = DefaultConsumerContext, R = DefaultRuntime>where
C: ConsumerContext,{ /* private fields */ }Expand description
An event stream consuming from kafka.
Events are expected to be received with a json payload, and will be deserialized
with the thalo::aggregate::Aggregate::Event’s serde::de::DeserializeOwned implementation.
Implementations§
Source§impl<C, R> KafkaEventStream<C, R>where
C: ConsumerContext,
impl<C, R> KafkaEventStream<C, R>where
C: ConsumerContext,
Sourcepub fn new(topics: &[impl Display], consumer: StreamConsumer<C, R>) -> Self
pub fn new(topics: &[impl Display], consumer: StreamConsumer<C, R>) -> Self
Creates a new KafkaEventStream.
Sourcepub fn consumer(&self) -> Arc<StreamConsumer<C, R>>
pub fn consumer(&self) -> Arc<StreamConsumer<C, R>>
Get a reference to the stream consumer.
Sourcepub fn listen_events<A>(
&self,
) -> EventStreamResult<'_, Result<KafkaEventMessage<<A as Aggregate>::Event>, Error>, Error>
pub fn listen_events<A>( &self, ) -> EventStreamResult<'_, Result<KafkaEventMessage<<A as Aggregate>::Event>, Error>, Error>
Subscribes to topics and listens to events using the consumer, returning a stream of events.
Events are expected to be JSON thalo::event::EventEnvelopes, and will be deserialized.
For more documentation, see thalo::event_stream::EventStream.
Trait Implementations§
Source§impl<C, R: Clone> Clone for KafkaEventStream<C, R>where
C: ConsumerContext + Clone,
impl<C, R: Clone> Clone for KafkaEventStream<C, R>where
C: ConsumerContext + Clone,
Source§fn clone(&self) -> KafkaEventStream<C, R>
fn clone(&self) -> KafkaEventStream<C, R>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A, C, R> EventStream<A> for KafkaEventStream<C, R>
impl<A, C, R> EventStream<A> for KafkaEventStream<C, R>
Source§fn listen_events(&mut self) -> EventStreamResult<'_, Self::Item, Self::Error>
fn listen_events(&mut self) -> EventStreamResult<'_, Self::Item, Self::Error>
Continuously listen for events as an async stream for the given aggregate.
Auto Trait Implementations§
impl<C, R> Freeze for KafkaEventStream<C, R>
impl<C = DefaultConsumerContext, R = TokioRuntime> !RefUnwindSafe for KafkaEventStream<C, R>
impl<C, R> Send for KafkaEventStream<C, R>
impl<C, R> Sync for KafkaEventStream<C, R>
impl<C, R> Unpin for KafkaEventStream<C, R>
impl<C = DefaultConsumerContext, R = TokioRuntime> !UnwindSafe for KafkaEventStream<C, R>
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