Skip to main content

BatchTaskHandler

Trait BatchTaskHandler 

Source
pub trait BatchTaskHandler:
    Serialize
    + for<'de> Deserialize<'de>
    + Send
    + Sync
    + 'static {
    const IDENTIFIER: &'static str;

    // Required method
    fn run_batch(
        items: Vec<Self>,
        ctx: WorkerContext,
    ) -> impl Future<Output = impl IntoBatchTaskHandlerResult> + Send + 'static;

    // Provided method
    fn definition() -> JobDefinition
       where Self: Sized { ... }
}
Expand description

Core trait for defining batch task handlers.

Implement this when a single database job should contain an array of item payloads and the worker should retry only the failed items after partial success. Self is the item payload type, not Vec<Self>.

Required Associated Constants§

Source

const IDENTIFIER: &'static str

Unique identifier for this batch task type.

Required Methods§

Source

fn run_batch( items: Vec<Self>, ctx: WorkerContext, ) -> impl Future<Output = impl IntoBatchTaskHandlerResult> + Send + 'static

Execute a batch of item payloads.

Provided Methods§

Source

fn definition() -> JobDefinition
where Self: Sized,

Returns a reusable registration value for this batch task handler.

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.

Implementors§