pub struct RoutingKeyMiddleware { /* private fields */ }Expand description
Middleware for dynamic routing key assignment.
Assigns routing keys to messages based on custom logic or message content. Useful for implementing dynamic routing strategies.
§Examples
use celers_kombu::{RoutingKeyMiddleware, MessageMiddleware};
// Use task name as routing key
let middleware = RoutingKeyMiddleware::new(|msg| {
format!("tasks.{}", msg.headers.task)
});
assert_eq!(middleware.name(), "routing_key");Implementations§
Source§impl RoutingKeyMiddleware
impl RoutingKeyMiddleware
Sourcepub fn new<F>(key_generator: F) -> Self
pub fn new<F>(key_generator: F) -> Self
Create a new routing key middleware with a custom key generator
Sourcepub fn from_task_name() -> Self
pub fn from_task_name() -> Self
Create a routing key from task name
Sourcepub fn from_task_and_priority() -> Self
pub fn from_task_and_priority() -> Self
Create a routing key from task name with priority
Trait Implementations§
Source§impl MessageMiddleware for RoutingKeyMiddleware
impl MessageMiddleware for RoutingKeyMiddleware
Source§fn before_publish<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 mut Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_publish<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 mut Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process message before publishing
Auto Trait Implementations§
impl Freeze for RoutingKeyMiddleware
impl !RefUnwindSafe for RoutingKeyMiddleware
impl Send for RoutingKeyMiddleware
impl Sync for RoutingKeyMiddleware
impl Unpin for RoutingKeyMiddleware
impl UnsafeUnpin for RoutingKeyMiddleware
impl !UnwindSafe for RoutingKeyMiddleware
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