Skip to main content

ForgeJob

Trait ForgeJob 

Source
pub trait ForgeJob:
    Send
    + Sync
    + 'static {
    type Args: DeserializeOwned + Serialize + Send + Sync;
    type Output: Serialize + Send;

    // Required methods
    fn info() -> JobInfo;
    fn execute(
        ctx: &JobContext,
        args: Self::Args,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + '_>>;

    // Provided method
    fn compensate<'a>(
        _ctx: &'a JobContext,
        _args: Self::Args,
        _reason: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>> { ... }
}
Expand description

Trait for FORGE job handlers.

Required Associated Types§

Source

type Args: DeserializeOwned + Serialize + Send + Sync

Input arguments type.

Source

type Output: Serialize + Send

Output result type.

Required Methods§

Source

fn info() -> JobInfo

Get job metadata.

Source

fn execute( ctx: &JobContext, args: Self::Args, ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + '_>>

Execute the job.

Provided Methods§

Source

fn compensate<'a>( _ctx: &'a JobContext, _args: Self::Args, _reason: &'a str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Compensate a cancelled job.

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§