pub struct Router { /* private fields */ }Expand description
Task router for directing tasks to appropriate queues
Implementations§
Source§impl Router
impl Router
Sourcepub fn with_default_queue(queue: impl Into<String>) -> Self
pub fn with_default_queue(queue: impl Into<String>) -> Self
Create a router with a default queue
Sourcepub fn add_rule(&mut self, rule: RouteRule)
pub fn add_rule(&mut self, rule: RouteRule)
Add a routing rule
Rules are sorted by priority (higher priority rules are evaluated first)
Sourcepub fn add_direct_route(
&mut self,
task_name: impl Into<String>,
result: RouteResult,
)
pub fn add_direct_route( &mut self, task_name: impl Into<String>, result: RouteResult, )
Add a direct route for a specific task
Direct routes take precedence over pattern-based rules
Sourcepub fn set_default_queue(&mut self, queue: impl Into<String>)
pub fn set_default_queue(&mut self, queue: impl Into<String>)
Set the default queue for unmatched tasks
Sourcepub fn route(&self, task_name: &str) -> Option<String>
pub fn route(&self, task_name: &str) -> Option<String>
Route a task to a queue
Returns None if no matching rule and no default queue
Sourcepub fn route_full(&self, task_name: &str) -> Option<RouteResult>
pub fn route_full(&self, task_name: &str) -> Option<RouteResult>
Route a task and get full routing information
Returns None if no matching rule and no default queue
Sourcepub fn route_with_args(
&self,
task_name: &str,
args: &[Value],
kwargs: &Map<String, Value>,
) -> Option<String>
pub fn route_with_args( &self, task_name: &str, args: &[Value], kwargs: &Map<String, Value>, ) -> Option<String>
Route a task with arguments to a queue
This method considers both task name patterns and argument conditions.
Returns None if no matching rule and no default queue.
Sourcepub fn route_full_with_args(
&self,
task_name: &str,
args: &[Value],
kwargs: &Map<String, Value>,
) -> Option<RouteResult>
pub fn route_full_with_args( &self, task_name: &str, args: &[Value], kwargs: &Map<String, Value>, ) -> Option<RouteResult>
Route a task with arguments and get full routing information
This method considers both task name patterns and argument conditions.
Returns None if no matching rule and no default queue.
Sourcepub fn remove_rules_by_queue(&mut self, queue: &str)
pub fn remove_rules_by_queue(&mut self, queue: &str)
Remove all rules matching a pattern