pub struct ConsumerRunner<T: Send + Sync + Clone + 'static> { /* private fields */ }Expand description
Manages the consumption loop as a tokio task.
Unlike ManagedConsumer,
ConsumerRunner owns the task handle directly and provides a simpler
run/stop interface without builder overhead.
Implementations§
Source§impl<T: Send + Sync + Clone + 'static> ConsumerRunner<T>
impl<T: Send + Sync + Clone + 'static> ConsumerRunner<T>
Sourcepub fn new(
consumer: Arc<dyn MessageConsumer<T>>,
handler: Arc<dyn MessageHandler<T>>,
) -> Self
pub fn new( consumer: Arc<dyn MessageConsumer<T>>, handler: Arc<dyn MessageHandler<T>>, ) -> Self
Create a new runner for the given consumer and handler.
Sourcepub fn with_metrics(self, metrics: Arc<dyn MetricsCollector>) -> Self
pub fn with_metrics(self, metrics: Arc<dyn MetricsCollector>) -> Self
Set the metrics collector.
Sourcepub const fn with_shutdown_timeout(self, timeout: Duration) -> Self
pub const fn with_shutdown_timeout(self, timeout: Duration) -> Self
Set the graceful shutdown timeout.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true when the consumption loop is running.
Auto Trait Implementations§
impl<T> !Freeze for ConsumerRunner<T>
impl<T> !RefUnwindSafe for ConsumerRunner<T>
impl<T> !UnwindSafe for ConsumerRunner<T>
impl<T> Send for ConsumerRunner<T>
impl<T> Sync for ConsumerRunner<T>
impl<T> Unpin for ConsumerRunner<T>
impl<T> UnsafeUnpin for ConsumerRunner<T>
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