pub trait Task:
Serialize
+ DeserializeOwned
+ 'static {
const TASK_KEY: &'static str;
const TASK_QUEUE: &'static str;
const RETRY_POLICY: RetryPolicy = _;
const DELAY_SECONDS: u32 = 3u32;
// Required method
fn run(self) -> TaskFuture;
// Provided methods
fn validate(&self, kind: &TaskKind) -> Result<(), String> { ... }
fn new_meta(&self, kind: TaskKind) -> 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 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.