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>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>;
fn dispatch_by_name_at(
&self,
job_type: &str,
args: Value,
scheduled_at: DateTime<Utc>,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>;
fn dispatch_in_conn<'a>(
&'a self,
conn: &'a mut PgConnection,
job_type: &'a str,
args: Value,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>;
fn dispatch_in_conn_at<'a>(
&'a self,
conn: &'a mut PgConnection,
job_type: &'a str,
args: Value,
scheduled_at: DateTime<Utc>,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>;
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.
Required Methods§
Sourcefn dispatch_by_name(
&self,
job_type: &str,
args: Value,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
fn dispatch_by_name( &self, job_type: &str, args: Value, owner_subject: Option<String>, tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
Dispatch a job by its registered name.
Sourcefn dispatch_by_name_at(
&self,
job_type: &str,
args: Value,
scheduled_at: DateTime<Utc>,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
fn dispatch_by_name_at( &self, job_type: &str, args: Value, scheduled_at: DateTime<Utc>, owner_subject: Option<String>, tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
Dispatch a job at a specific time by its registered name.
The job will not be picked up by workers until scheduled_at is
reached. In all other respects it behaves like [dispatch_by_name].
Sourcefn dispatch_in_conn<'a>(
&'a self,
conn: &'a mut PgConnection,
job_type: &'a str,
args: Value,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
fn dispatch_in_conn<'a>( &'a self, conn: &'a mut PgConnection, job_type: &'a str, args: Value, owner_subject: Option<String>, tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
Dispatch a job on an existing connection — typically the live
transaction inside a MutationContext. The insert participates in
the surrounding transaction, so the job only becomes visible to
workers after commit and is rolled back on failure.
Sourcefn dispatch_in_conn_at<'a>(
&'a self,
conn: &'a mut PgConnection,
job_type: &'a str,
args: Value,
scheduled_at: DateTime<Utc>,
owner_subject: Option<String>,
tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
fn dispatch_in_conn_at<'a>( &'a self, conn: &'a mut PgConnection, job_type: &'a str, args: Value, scheduled_at: DateTime<Utc>, owner_subject: Option<String>, tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
Dispatch a job at a specific time on an existing connection.
Combines the transactional safety of [dispatch_in_conn] with
delayed scheduling. The job row is written inside the caller’s
transaction and workers will not pick it up until scheduled_at.