pub struct Consumer { /* private fields */ }Expand description
Consumer represents a message consumer that subscribes to a topic and receives messages. It handles communication with the message broker and manages the consumer’s state.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub async fn subscribe(&mut self) -> Result<()>
pub async fn subscribe(&mut self) -> Result<()>
Initializes the subscription to a non-partitioned or partitioned topic and starts the health check service.
This function establishes a gRPC connection with the brokers and requests to subscribe to the specified topic.
§Errors
If an error occurs during subscription or initialization, it is returned as part of the Err variant.
Sourcepub async fn receive(&mut self) -> Result<Receiver<StreamMessage>>
pub async fn receive(&mut self) -> Result<Receiver<StreamMessage>>
Starts receiving messages from the subscribed partitioned or non-partitioned topic.
This function continuously polls for new messages and handles them as long as the stop_signal has not been set to true.
§Returns
A Result with:
Ok(mpsc::Receiver<StreamMessage>)if the receive client is successfully created and ready to receive messages.Err(e)if the receive client cannot be created or if other issues occur.
pub async fn ack(&mut self, message: &StreamMessage) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Consumer
impl !RefUnwindSafe for Consumer
impl Send for Consumer
impl Sync for Consumer
impl Unpin for Consumer
impl !UnwindSafe for Consumer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request