pub struct JobDispatcher { /* private fields */ }Expand description
Dispatches jobs to the queue.
Implementations§
Source§impl JobDispatcher
impl JobDispatcher
Sourcepub fn new(queue: JobQueue, registry: JobRegistry) -> Self
pub fn new(queue: JobQueue, registry: JobRegistry) -> Self
Create a new job dispatcher.
Sourcepub async fn dispatch<J: ForgeJob>(
&self,
args: J::Args,
) -> Result<Uuid, ForgeError>
pub async fn dispatch<J: ForgeJob>( &self, args: J::Args, ) -> Result<Uuid, ForgeError>
Dispatch a job immediately.
Sourcepub async fn dispatch_in<J: ForgeJob>(
&self,
delay: Duration,
args: J::Args,
) -> Result<Uuid, ForgeError>
pub async fn dispatch_in<J: ForgeJob>( &self, delay: Duration, args: J::Args, ) -> Result<Uuid, ForgeError>
Dispatch a job with a delay.
Sourcepub async fn dispatch_at<J: ForgeJob>(
&self,
at: DateTime<Utc>,
args: J::Args,
) -> Result<Uuid, ForgeError>
pub async fn dispatch_at<J: ForgeJob>( &self, at: DateTime<Utc>, args: J::Args, ) -> Result<Uuid, ForgeError>
Dispatch a job at a specific time.
Sourcepub async fn dispatch_by_name(
&self,
job_type: &str,
args: Value,
) -> Result<Uuid, ForgeError>
pub async fn dispatch_by_name( &self, job_type: &str, args: Value, ) -> Result<Uuid, ForgeError>
Dispatch job by name (dynamic).
Sourcepub async fn dispatch_idempotent<J: ForgeJob>(
&self,
idempotency_key: impl Into<String>,
args: J::Args,
) -> Result<Uuid, ForgeError>
pub async fn dispatch_idempotent<J: ForgeJob>( &self, idempotency_key: impl Into<String>, args: J::Args, ) -> Result<Uuid, ForgeError>
Dispatch job with idempotency key.
Sourcepub async fn dispatch_with_priority<J: ForgeJob>(
&self,
priority: JobPriority,
args: J::Args,
) -> Result<Uuid, ForgeError>
pub async fn dispatch_with_priority<J: ForgeJob>( &self, priority: JobPriority, args: J::Args, ) -> Result<Uuid, ForgeError>
Dispatch job with custom priority.
Trait Implementations§
Source§impl Clone for JobDispatcher
impl Clone for JobDispatcher
Source§fn clone(&self) -> JobDispatcher
fn clone(&self) -> JobDispatcher
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for JobDispatcher
impl !RefUnwindSafe for JobDispatcher
impl Send for JobDispatcher
impl Sync for JobDispatcher
impl Unpin for JobDispatcher
impl !UnwindSafe for JobDispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more