Skip to main content

BackgroundTaskSpec

Trait BackgroundTaskSpec 

Source
pub trait BackgroundTaskSpec<State, Task, Config, Context, Error>: Sync
where Task: TaskRecord<Self::Kind>,
{ type Kind: Copy + Eq + Debug + Display + Send + Sync + 'static; type Lane: Copy + Eq + Debug + Send + Sync + 'static; type Payload: Serialize + DeserializeOwned + Clone + Send + Sync + 'static; type Result: Serialize + DeserializeOwned + Clone + Send + Sync + 'static; type PayloadEnvelope; type ResultEnvelope; const KIND: Self::Kind; // Required methods fn step_specs() -> &'static [TaskStepSpec]; fn lane() -> Self::Lane; fn wrap_payload(payload: Self::Payload) -> Self::PayloadEnvelope; fn wrap_result(result: Self::Result) -> Self::ResultEnvelope; fn process<'a>( state: &'a State, task: &'a Task, context: Context, ) -> TaskProcessFuture<'a, Error>; // Provided methods fn max_attempts(_runtime_config: &Config) -> i32 { ... } fn retry_class(_error: &Error) -> TaskRetryClass { ... } }
Expand description

Product-owned typed task specification.

The generic parameters keep Forge independent from product state, persisted task model, runtime config, execution context, error type, task kind enum, lane enum, and payload/result wrapper enums. Product crates implement this trait for each task kind and register those specs with crate::task_registry!.

Required Associated Constants§

Source

const KIND: Self::Kind

Task kind handled by this spec.

Required Associated Types§

Source

type Kind: Copy + Eq + Debug + Display + Send + Sync + 'static

Product-owned task kind enum.

Source

type Lane: Copy + Eq + Debug + Send + Sync + 'static

Product-owned task lane enum.

Source

type Payload: Serialize + DeserializeOwned + Clone + Send + Sync + 'static

Typed task payload.

Source

type Result: Serialize + DeserializeOwned + Clone + Send + Sync + 'static

Typed task result.

Source

type PayloadEnvelope

Product task payload envelope enum.

Source

type ResultEnvelope

Product task result envelope enum.

Required Methods§

Source

fn step_specs() -> &'static [TaskStepSpec]

Initial step specs for this task kind.

Source

fn lane() -> Self::Lane

Dispatch lane used by this task kind.

Source

fn wrap_payload(payload: Self::Payload) -> Self::PayloadEnvelope

Wraps the typed payload into the product payload envelope.

Source

fn wrap_result(result: Self::Result) -> Self::ResultEnvelope

Wraps the typed result into the product result envelope.

Source

fn process<'a>( state: &'a State, task: &'a Task, context: Context, ) -> TaskProcessFuture<'a, Error>

Processes the task.

Provided Methods§

Source

fn max_attempts(_runtime_config: &Config) -> i32

Maximum attempts for new tasks of this kind.

Source

fn retry_class(_error: &Error) -> TaskRetryClass

Classifies a task failure for retry behavior.

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§