pub trait StreamHandler:
Send
+ Sync
+ 'static {
type Error: Display + Send + Sync + 'static;
// Required method
fn handle_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
msg_id: &'life1 str,
data: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Trait for handling messages from a Redis Stream.
Services implement this trait with their domain-specific processing logic. The consumer framework handles XREADGROUP, XACK, XCLAIM, and dead-letter automatically based on the return value:
Ok(())— message is ACKed and removed from pending.Err(_)— message stays pending for retry via XCLAIM.
Required Associated Types§
Required Methods§
Sourcefn handle_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
msg_id: &'life1 str,
data: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
msg_id: &'life1 str,
data: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Process a single stream message.
msg_id is the Redis stream message ID (e.g. “1234567890-0”).
data is the value of the “data” field from the stream entry.
Return Ok(()) to acknowledge the message, or Err to leave it
pending for retry.