pub trait Task:
Serialize
+ DeserializeOwned
+ 'static {
const TASK_KEY: &'static str;
const TASK_QUEUE: &'static str;
const TASK_KIND: TaskKind;
const SCHEDULE: Option<&'static str> = None;
const TIMEZONE: Option<&'static str> = None;
const REPEAT_INTERVAL: Option<u32> = None;
const RETRY_POLICY: RetryPolicy = _;
const DELAY_SECONDS: u32 = 3u32;
// Required method
fn run(self) -> TaskFuture;
// Provided methods
fn validate(&self) -> Result<(), String> { ... }
fn new_meta(&self) -> TaskMeta { ... }
}Required Associated Constants§
Sourceconst TASK_KEY: &'static str
const TASK_KEY: &'static str
A unique identifier for this task.
This name must be unique and is used to identify the task.
Sourceconst TASK_QUEUE: &'static str
const TASK_QUEUE: &'static str
The default queue associated with this task.
This can be overridden at the individual task level. If a non-existent queue is specified, the task will not be processed.
Provided Associated Constants§
Sourceconst SCHEDULE: Option<&'static str> = None
const SCHEDULE: Option<&'static str> = None
Schedule expression for Cron tasks.
This field is required if TASK_KIND is TaskKind::Cron.
It defines the schedule on which the task should run.
Sourceconst TIMEZONE: Option<&'static str> = None
const TIMEZONE: Option<&'static str> = None
Timezone for the schedule expression.
This is required for TaskKind::Cron and specifies the timezone for the cron schedule.
Sourceconst REPEAT_INTERVAL: Option<u32> = None
const REPEAT_INTERVAL: Option<u32> = None
Repeat interval for Repeat tasks, in seconds.
This field is required if TASK_KIND is TaskKind::Repeat.
It defines the interval between consecutive executions of the task.
Sourceconst RETRY_POLICY: RetryPolicy = _
const RETRY_POLICY: RetryPolicy = _
The retry policy for this task.
Defines the strategy and maximum retry attempts in case of failure. Default is exponential backoff with a base of 2 and a maximum of 5 retries.
Sourceconst DELAY_SECONDS: u32 = 3u32
const DELAY_SECONDS: u32 = 3u32
Delay before executing a Once task, in seconds.
Specifies the delay before starting a Once task after it is scheduled.
Required Methods§
Sourcefn run(self) -> TaskFuture
fn run(self) -> TaskFuture
Executes the task with the given parameters.
Contains the logic required to perform the task. Takes parameters of type Self::Params
that can be used during execution.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.