pub trait Task:
Serialize
+ DeserializeOwned
+ 'static {
const TASK_KEY: &'static str;
const TASK_QUEUE: &'static str;
// Required method
fn run(self) -> TaskFuture;
// Provided methods
fn retry_policy(&self) -> RetryPolicy { ... }
fn delay_seconds(&self) -> u32 { ... }
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.
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§
Sourcefn retry_policy(&self) -> RetryPolicy
fn retry_policy(&self) -> RetryPolicy
Returns the retry policy for this task instance. Default is exponential backoff with base 2 and max 3 retries.
Sourcefn delay_seconds(&self) -> u32
fn delay_seconds(&self) -> u32
Returns the delay in seconds before executing a Once task. Default is 3 seconds.
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.