pub trait BackgroundJob:
Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static {
type Context: Clone + Send + 'static;
const JOB_NAME: &'static str;
const PRIORITY: i16 = 0i16;
const DEDUPLICATED: bool = false;
const QUEUE: &'static str = DEFAULT_QUEUE;
// Required method
fn run(&self, ctx: Self::Context) -> impl Future<Output = Result<()>> + Send;
// Provided method
fn enqueue<'a>(
&'a self,
pool: &'a PgPool,
) -> BoxFuture<'a, Result<Option<i64>, EnqueueError>> { ... }
}
Expand description
The main trait for defining background jobs. Trait for defining background jobs that can be enqueued and executed asynchronously.
Required Associated Constants§
Provided Associated Constants§
Sourceconst PRIORITY: i16 = 0i16
const PRIORITY: i16 = 0i16
Default priority of the task.
[Self::enqueue_with_priority
] can be used to override the priority value.
Sourceconst DEDUPLICATED: bool = false
const DEDUPLICATED: bool = false
Whether the job should be deduplicated.
If true, the job will not be enqueued if there is already an unstarted job with the same data.
Required Associated Types§
Required Methods§
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.