pub trait BackgroundTaskSpec<State, Task, Config, Context, Error>: Syncwhere
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§
Required Associated Types§
Sourcetype PayloadEnvelope
type PayloadEnvelope
Product task payload envelope enum.
Sourcetype ResultEnvelope
type ResultEnvelope
Product task result envelope enum.
Required Methods§
Sourcefn step_specs() -> &'static [TaskStepSpec]
fn step_specs() -> &'static [TaskStepSpec]
Initial step specs for this task kind.
Sourcefn wrap_payload(payload: Self::Payload) -> Self::PayloadEnvelope
fn wrap_payload(payload: Self::Payload) -> Self::PayloadEnvelope
Wraps the typed payload into the product payload envelope.
Sourcefn wrap_result(result: Self::Result) -> Self::ResultEnvelope
fn wrap_result(result: Self::Result) -> Self::ResultEnvelope
Wraps the typed result into the product result envelope.
Sourcefn process<'a>(
state: &'a State,
task: &'a Task,
context: Context,
) -> TaskProcessFuture<'a, Error>
fn process<'a>( state: &'a State, task: &'a Task, context: Context, ) -> TaskProcessFuture<'a, Error>
Processes the task.
Provided Methods§
Sourcefn max_attempts(_runtime_config: &Config) -> i32
fn max_attempts(_runtime_config: &Config) -> i32
Maximum attempts for new tasks of this kind.
Sourcefn retry_class(_error: &Error) -> TaskRetryClass
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.