pub struct PendingChain { /* private fields */ }Expand description
A chain of jobs on its way to the queue.
Await the chain to dispatch its first step. Awaiting returns a ChainDispatched for that
step. The errors and panics of awaiting are listed on queue::chain.
The queue dispatches each job once the job before it succeeds or deletes itself. A job that
releases itself runs again before the chain continues. A job that fails for good stops the
chain, and the worker that ran the job calls the chain’s catch callbacks
with the error. Inside a database transaction, the chain waits for the transaction to commit,
as a dispatch does.
use laravel::queue;
queue::chain((
ProcessPodcast { podcast_id },
OptimizePodcast { podcast_id },
))
.then(ReleasePodcast { podcast_id })
.on_queue("podcasts")
.catch(PodcastFailed { podcast_id })
.await?;Implementations§
Source§impl PendingChain
impl PendingChain
Sourcepub fn then<Kind>(self, jobs: impl IntoJobs<Kind>) -> PendingChain
pub fn then<Kind>(self, jobs: impl IntoJobs<Kind>) -> PendingChain
Run jobs in order once the steps before them have succeeded.
jobs is a job, a tuple of jobs, an iterable of jobs of one type, or a batch.
Sourcepub fn on_connection(self, connection: impl Into<String>) -> PendingChain
pub fn on_connection(self, connection: impl Into<String>) -> PendingChain
Push every job in the chain to this connection rather than the default one.
Sourcepub fn on_queue(self, queue: impl Into<String>) -> PendingChain
pub fn on_queue(self, queue: impl Into<String>) -> PendingChain
Push every job in the chain to this queue, rather than the queue that each job’s options or connection choose.
Sourcepub fn delay(self, delay: impl Into<Moment>) -> PendingChain
pub fn delay(self, delay: impl Into<Moment>) -> PendingChain
Delay the chain’s first job by a span such as 10.minutes(), or until a point in time.
The later jobs run as soon as the job before them finishes. Awaiting a delayed chain fails when the chain starts with a batch, and awaiting a batch fails when one of its jobs is a delayed chain.
Sourcepub fn catch(self, callback: impl ChainCatch) -> PendingChain
pub fn catch(self, callback: impl ChainCatch) -> PendingChain
Call callback’s catch method with the error if a job in the chain fails for good.
The chain stops after the failure, and the worker that ran the failed job calls the callback. Each call adds another callback.
Trait Implementations§
Source§impl Debug for PendingChain
impl Debug for PendingChain
impl IntoBatchJob for PendingChain
impl IntoBatchJobs for PendingChain
Source§impl IntoFuture for PendingChain
impl IntoFuture for PendingChain
Source§type Output = Result<ChainDispatched, Error>
type Output = Result<ChainDispatched, Error>
Source§type IntoFuture = Pin<Box<dyn Future<Output = Result<ChainDispatched, Error>> + Send>>
type IntoFuture = Pin<Box<dyn Future<Output = Result<ChainDispatched, Error>> + Send>>
Source§fn into_future(self) -> <PendingChain as IntoFuture>::IntoFuture
fn into_future(self) -> <PendingChain as IntoFuture>::IntoFuture
Auto Trait Implementations§
impl !RefUnwindSafe for PendingChain
impl !UnwindSafe for PendingChain
impl Forget for PendingChain
impl Freeze for PendingChainwhere
*const u8 is !null: Freeze,
PhantomData<Link>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<EncodedCallback>: Freeze,
*const ArcInner<Inner> is !null: Freeze,
PhantomData<ArcInner<Inner>>: Freeze,
&'static Location<'static>: Freeze,
impl Move for PendingChain
impl Send for PendingChain
impl Sync for PendingChain
impl Unpin for PendingChain
impl UnsafeUnpin for PendingChainwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Link>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<EncodedCallback>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
&'static Location<'static>: UnsafeUnpin,
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