Trait brokkr::Perform [−][src]
pub trait Perform where
Self: Encodable + RefUnwindSafe + 'static, { type Result: Encodable + RefUnwindSafe + 'static; type Error: Encodable + RefUnwindSafe + 'static; type Context: Clone + Send + Sync + RefUnwindSafe + 'static; fn process(&self, c: &Self::Context) -> Result<Self::Result, Self::Error>; }
The Perform
trait is used to mark a task as executable and encode the
logic associated with this task.
Associated Types
type Result: Encodable + RefUnwindSafe + 'static
The result type for this task.
type Error: Encodable + RefUnwindSafe + 'static
The error type for this task.
type Context: Clone + Send + Sync + RefUnwindSafe + 'static
The type of the context value that will be given to this job's handler. This should be used to share long-lived objects such as database connections, global variables, etc.
Required Methods
fn process(&self, c: &Self::Context) -> Result<Self::Result, Self::Error>
Processing logic for this task.
Returning the Result
type is considered a success for the task while
returning the Error
type will mark the job as failed, including the
serialised error in the job metadata.
You shoud try to avoid surfacing panics as much as possible, however if
this function does panic, the Worker
will catch it and mark the job as
panicked, including the panic payload in the metadata.