pub struct RouterBuilder { /* private fields */ }Expand description
Builder for creating routers with fluent API
Implementations§
Source§impl RouterBuilder
impl RouterBuilder
Sourcepub fn route_glob(self, pattern: &str, queue: &str) -> Self
pub fn route_glob(self, pattern: &str, queue: &str) -> Self
Add a rule that routes tasks matching a glob pattern to a queue
Sourcepub fn route_regex(self, pattern: &str, queue: &str) -> Result<Self, Error>
pub fn route_regex(self, pattern: &str, queue: &str) -> Result<Self, Error>
Add a rule that routes tasks matching a regex pattern to a queue
§Errors
Returns an error if the regex pattern is invalid.
Sourcepub fn route_exact(self, task_name: &str, queue: &str) -> Self
pub fn route_exact(self, task_name: &str, queue: &str) -> Self
Add a rule that routes a specific task to a queue
Sourcepub fn direct_route(self, task_name: &str, queue: &str) -> Self
pub fn direct_route(self, task_name: &str, queue: &str) -> Self
Add a direct route for a specific task
Sourcepub fn route_with_args(
self,
matcher: PatternMatcher,
queue: &str,
condition: ArgumentCondition,
) -> Self
pub fn route_with_args( self, matcher: PatternMatcher, queue: &str, condition: ArgumentCondition, ) -> Self
Add a rule that routes tasks based on argument conditions
§Example
use celers_core::router::{RouterBuilder, PatternMatcher, ArgumentCondition};
let router = RouterBuilder::new()
.route_with_args(
PatternMatcher::glob("process.*"),
"high_priority",
ArgumentCondition::kwarg_equals("priority", serde_json::json!("high")),
)
.route_with_args(
PatternMatcher::glob("process.*"),
"low_priority",
ArgumentCondition::kwarg_equals("priority", serde_json::json!("low")),
)
.default_queue("default")
.build();Sourcepub fn route_with_args_priority(
self,
matcher: PatternMatcher,
queue: &str,
condition: ArgumentCondition,
priority: i32,
) -> Self
pub fn route_with_args_priority( self, matcher: PatternMatcher, queue: &str, condition: ArgumentCondition, priority: i32, ) -> Self
Add a rule with both priority and argument condition
Sourcepub fn default_queue(self, queue: &str) -> Self
pub fn default_queue(self, queue: &str) -> Self
Set the default queue for unmatched tasks
Trait Implementations§
Source§impl Debug for RouterBuilder
impl Debug for RouterBuilder
Source§impl Default for RouterBuilder
impl Default for RouterBuilder
Source§fn default() -> RouterBuilder
fn default() -> RouterBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RouterBuilder
impl RefUnwindSafe for RouterBuilder
impl Send for RouterBuilder
impl Sync for RouterBuilder
impl Unpin for RouterBuilder
impl UnwindSafe for RouterBuilder
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