Skip to main content

dispatch_sync

Function dispatch_sync 

Source
pub fn dispatch_sync<J>(
    job: J,
) -> impl Future<Output = Result<(), Error>> + Send
where J: Job,
Expand description

Run a job immediately in this process instead of queueing it.

The job runs the way the sync connection runs it. The dispatch_sync method that #[job] adds to each job calls this function. The job runs in a fresh application context that starts with the dispatching context’s values, and it doesn’t wait for a database transaction to commit. When the job fails, its failed hook runs.

§Errors

Returns the job’s error, or the error from encoding or decoding the job.

§Panics

Panics outside a request, a command, or an Application::scope.