pub trait Task:
Send
+ Sync
+ Serialize
+ DeserializeOwned
+ 'static {
type Output: Serialize + DeserializeOwned + Send;
const NAME: &'static str;
const QUEUE: &'static str = "default";
const MAX_RETRIES: u32 = 3;
// Required method
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 TaskContext,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, KojinError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn backoff() -> BackoffStrategy { ... }
fn signature(&self) -> Signature { ... }
}Expand description
A unit of work that can be enqueued and executed by a worker.
Required Associated Constants§
Provided Associated Constants§
Sourceconst MAX_RETRIES: u32 = 3
const MAX_RETRIES: u32 = 3
Maximum number of retry attempts.
Required Associated Types§
Sourcetype Output: Serialize + DeserializeOwned + Send
type Output: Serialize + DeserializeOwned + Send
The output type of the task.
Required Methods§
Sourcefn run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 TaskContext,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, KojinError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 TaskContext,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, KojinError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Execute the task.
Provided Methods§
Sourcefn backoff() -> BackoffStrategy
fn backoff() -> BackoffStrategy
Backoff strategy for retries.
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.