pub struct TrackedConsumer { /* private fields */ }Expand description
A wrapped lapin::Consumer that automatically reports job lifecycle events.
Each delivery is wrapped in a TrackedDelivery that reports job_started
when received (via a direct API call to get the server-assigned execution_id),
and job_completed/job_failed when acked/nacked.
Use next_tracked() to consume deliveries with full
lifecycle tracking.
§Example
use queuerious::QueuriousClient;
use queuerious_lapin::TrackedConsumer;
let client = std::sync::Arc::new(
QueuriousClient::builder()
.api_key("qk_your_key")
.build()?
);
let consumer = channel.basic_consume(
"my-queue", "my-consumer",
lapin::options::BasicConsumeOptions::default(),
lapin::types::FieldTable::default(),
).await?;
let mut tracked = TrackedConsumer::new(consumer, "my-queue", client);
while let Some(delivery) = tracked.next_tracked().await {
let delivery = delivery?;
// Process message...
delivery.ack(lapin::options::BasicAckOptions::default()).await?;
}Implementations§
Source§impl TrackedConsumer
impl TrackedConsumer
Sourcepub fn new(
consumer: Consumer,
queue_name: impl Into<String>,
client: Arc<QueuriousClient>,
) -> Self
pub fn new( consumer: Consumer, queue_name: impl Into<String>, client: Arc<QueuriousClient>, ) -> Self
Wrap a lapin consumer for automatic event tracking.
Sourcepub fn with_config(
consumer: Consumer,
queue_name: impl Into<String>,
client: Arc<QueuriousClient>,
config: LapinAdapterConfig,
) -> Self
pub fn with_config( consumer: Consumer, queue_name: impl Into<String>, client: Arc<QueuriousClient>, config: LapinAdapterConfig, ) -> Self
Wrap a lapin consumer with custom configuration.
Sourcepub async fn next_tracked(
&mut self,
) -> Option<Result<TrackedDelivery, TrackedConsumerError>>
pub async fn next_tracked( &mut self, ) -> Option<Result<TrackedDelivery, TrackedConsumerError>>
Process the next delivery with full lifecycle tracking.
Reports job_started via a direct API call and obtains the server-assigned
execution_id, enabling accurate job_completed/job_failed tracking
when the returned TrackedDelivery is acked or nacked.
Returns None when the consumer stream ends.
Auto Trait Implementations§
impl Freeze for TrackedConsumer
impl !RefUnwindSafe for TrackedConsumer
impl Send for TrackedConsumer
impl Sync for TrackedConsumer
impl Unpin for TrackedConsumer
impl UnsafeUnpin for TrackedConsumer
impl !UnwindSafe for TrackedConsumer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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