pub struct PendingDispatch<J> { /* private fields */ }Expand description
A job on its way to the queue.
Choose where the job goes, then await the PendingDispatch to push the job. Awaiting returns
the job’s JobId. The errors and panics of awaiting are listed on
queue::dispatch.
Inside a database transaction, Laravel holds the job until the transaction commits, and
discards the job if the transaction rolls back, so a worker never runs the job against
uncommitted data. Awaiting then returns as soon as the job is held. The job is pushed at most
once, even if the code that committed stops waiting, and the job is lost if the process exits
before the push. If the push fails, the transaction returns an
AfterCommitError, and the data stays committed.
use laravel::time::ToSpan;
ProcessPodcast { podcast_id: 42 }.dispatch().await?;
ProcessPodcast { podcast_id: 42 }
.dispatch()
.on_connection("database")
.on_queue("podcasts")
.delay(10.minutes())
.await?;Implementations§
Source§impl<J> PendingDispatch<J>where
J: Job,
impl<J> PendingDispatch<J>where
J: Job,
Sourcepub fn on_connection(self, connection: impl Into<String>) -> PendingDispatch<J>
pub fn on_connection(self, connection: impl Into<String>) -> PendingDispatch<J>
Push the job to this connection rather than the default one.
Sourcepub fn on_queue(self, queue: impl Into<String>) -> PendingDispatch<J>
pub fn on_queue(self, queue: impl Into<String>) -> PendingDispatch<J>
Push the job to this queue, rather than the queue that its options or connection choose.
Sourcepub fn delay(self, delay: impl Into<Moment>) -> PendingDispatch<J>
pub fn delay(self, delay: impl Into<Moment>) -> PendingDispatch<J>
Delay the job by a span such as 10.minutes(), or until a
Timestamp.
The sync connection ignores the delay and runs the job immediately. An SQS FIFO queue
refuses a delayed job.
Sourcepub fn on_group(self, group: impl Into<String>) -> PendingDispatch<J>
pub fn on_group(self, group: impl Into<String>) -> PendingDispatch<J>
Put the job in this message group on an SQS queue.
A FIFO queue runs a group’s jobs one at a time, in the order they were dispatched, and a released or retried job keeps its place at the front of its group. A standard queue divides its capacity fairly between groups. Other drivers ignore the group.
Sourcepub fn deduplication_id(self, id: impl Into<String>) -> PendingDispatch<J>
pub fn deduplication_id(self, id: impl Into<String>) -> PendingDispatch<J>
Give the job this deduplication ID on an SQS FIFO queue.
The FIFO queue drops any job dispatched with the same ID in the next five minutes. Other queues ignore the ID.
Trait Implementations§
Source§impl<J> Debug for PendingDispatch<J>where
J: Debug,
impl<J> Debug for PendingDispatch<J>where
J: Debug,
Source§impl<J> IntoFuture for PendingDispatch<J>where
J: Job,
impl<J> IntoFuture for PendingDispatch<J>where
J: Job,
Source§type IntoFuture = Pin<Box<dyn Future<Output = Result<JobId, Error>> + Send>>
type IntoFuture = Pin<Box<dyn Future<Output = Result<JobId, Error>> + Send>>
Source§fn into_future(self) -> <PendingDispatch<J> as IntoFuture>::IntoFuture
fn into_future(self) -> <PendingDispatch<J> as IntoFuture>::IntoFuture
Auto Trait Implementations§
impl<J> Forget for PendingDispatch<J>
impl<J> Freeze for PendingDispatch<J>
impl<J> Move for PendingDispatch<J>
impl<J> RefUnwindSafe for PendingDispatch<J>where
J: RefUnwindSafe,
impl<J> Send for PendingDispatch<J>
impl<J> Sync for PendingDispatch<J>
impl<J> Unpin for PendingDispatch<J>
impl<J> UnsafeUnpin for PendingDispatch<J>where
J: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static Location<'static>: UnsafeUnpin,
impl<J> UnwindSafe for PendingDispatch<J>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
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> ⓘ
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