Skip to main content

JobDispatch

Trait JobDispatch 

Source
pub trait JobDispatch: Send + Sync {
    // Required methods
    fn get_info(&self, job_type: &str) -> Option<JobInfo>;
    fn dispatch_by_name(
        &self,
        job_type: &str,
        args: Value,
        owner_subject: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>;
    fn cancel(
        &self,
        job_id: Uuid,
        reason: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + '_>>;
}
Expand description

Trait for dispatching jobs from function contexts.

This trait allows mutation and action contexts to dispatch background jobs without directly depending on the runtime’s JobDispatcher.

Required Methods§

Source

fn get_info(&self, job_type: &str) -> Option<JobInfo>

Get job info by name for auth checking.

Source

fn dispatch_by_name( &self, job_type: &str, args: Value, owner_subject: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>

Dispatch a job by its registered name.

§Arguments
  • job_type - The registered name of the job type
  • args - JSON-serialized arguments for the job
§Returns

The UUID of the dispatched job

Source

fn cancel( &self, job_id: Uuid, reason: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + '_>>

Request cancellation for a job.

Implementors§