apalis_sql/
ext.rs

1use apalis_core::task::builder::TaskBuilder;
2
3use crate::context::SqlContext;
4
5/// Extension traits for [`TaskBuilder`]
6pub trait TaskBuilderExt {
7    /// Set the max number of attempts for the task being built.
8    #[must_use]
9    fn max_attempts(self, attempts: u32) -> Self;
10
11    /// Set the priority for the task being built.
12    #[must_use]
13    fn priority(self, priority: i32) -> Self;
14}
15
16impl<Args, Pool, IdType> TaskBuilderExt for TaskBuilder<Args, SqlContext<Pool>, IdType> {
17    fn max_attempts(mut self, attempts: u32) -> Self {
18        self.ctx = self.ctx.with_max_attempts(attempts as i32);
19        self
20    }
21
22    fn priority(mut self, priority: i32) -> Self {
23        self.ctx = self.ctx.with_priority(priority);
24        self
25    }
26}