pub trait MessageBackend: Send + Sync {
// Required methods
fn receive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<ReceiveResult<Value>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ack<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn nack<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 str,
requeue: bool,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait for message backend implementations.
Backends are responsible for receiving messages from external sources (RabbitMQ, Redis Streams, etc.) and providing acknowledgment handles.
Required Methods§
Sourcefn receive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<ReceiveResult<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<ReceiveResult<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive the next message with detailed status information.
This is the primary receive method that provides explicit semantics for different receive outcomes (shutdown, connection lost, retryable errors, etc.).
§Returns
Ok(ReceiveResult)- Contains the receive outcomeErr(WorkerError)- Fatal error occurred
Sourcefn ack<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ack<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Acknowledge a message by ID.
This is used for batch acknowledgments or when the AckHandle is not available. For single message acks, prefer using the AckHandle on ReceivedMessage.
§Arguments
message_id- The ID of the message to acknowledge
Sourcefn nack<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 str,
requeue: bool,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn nack<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 str,
requeue: bool,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Negative acknowledge a message by ID.
§Arguments
message_id- The ID of the message to negative-acknowledgerequeue- If true, requeue the message for redelivery
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = WorkerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform a health check on the backend.
§Returns
Ok(())- Backend is healthyErr(WorkerError)- Backend is unhealthy
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".