Struct ChainIter

Source
pub struct ChainIter { /* private fields */ }
Expand description

A pseudo iterator used to know which middleware should be called next. This is created by the Chain type.

Implementations§

Source§

impl ChainIter

Source

pub async fn next( &self, job: &Job, worker: Arc<WorkerRef>, redis: RedisPool, ) -> Result<()>

Examples found in repository?
examples/demo.rs (line 109)
87    async fn call(
88        &self,
89        chain: ChainIter,
90        job: &Job,
91        worker: Arc<WorkerRef>,
92        redis: RedisPool,
93    ) -> Result<()> {
94        let args: std::result::Result<(FiltereExpiredUsersArgs,), serde_json::Error> =
95            serde_json::from_value(job.args.clone());
96
97        // If we can safely deserialize then attempt to filter based on user guid.
98        if let Ok((filter,)) = args {
99            if filter.is_expired() {
100                error!({
101                    "class" = &job.class,
102                    "jid" = &job.jid,
103                    "user_guid" = filter.user_guid
104                }, "Detected an expired user, skipping this job");
105                return Ok(());
106            }
107        }
108
109        chain.next(job, worker, redis).await
110    }
More examples
Hide additional examples
examples/consumer-demo.rs (line 86)
64    async fn call(
65        &self,
66        chain: ChainIter,
67        job: &Job,
68        worker: Arc<WorkerRef>,
69        redis: Pool<RedisConnectionManager>,
70    ) -> Result<()> {
71        let args: std::result::Result<(FiltereExpiredUsersArgs,), serde_json::Error> =
72            serde_json::from_value(job.args.clone());
73
74        // If we can safely deserialize then attempt to filter based on user guid.
75        if let Ok((filter,)) = args {
76            if filter.is_expired() {
77                error!({
78                    "class" = &job.class,
79                    "jid" = &job.jid,
80                    "user_guid" = filter.user_guid,
81                }, "Detected an expired user, skipping this job");
82                return Ok(());
83            }
84        }
85
86        chain.next(job, worker, redis).await
87    }
examples/producer-demo.rs (line 88)
64    async fn call(
65        &self,
66        chain: ChainIter,
67        job: &Job,
68        worker: Arc<WorkerRef>,
69        redis: Pool<RedisConnectionManager>,
70    ) -> Result<()> {
71        let args: std::result::Result<(FiltereExpiredUsersArgs,), serde_json::Error> =
72            serde_json::from_value(job.args.clone());
73
74        // If we can safely deserialize then attempt to filter based on user guid.
75        if let Ok((filter,)) = args {
76            if filter.is_expired() {
77                error!({
78                        "class" = &job.class,
79                        "jid" = &job.jid,
80                        "user_guid" = filter.user_guid
81                    },
82                    "Detected an expired user, skipping this job"
83                );
84                return Ok(());
85            }
86        }
87
88        chain.next(job, worker, redis).await
89    }

Trait Implementations§

Source§

impl Clone for ChainIter

Source§

fn clone(&self) -> ChainIter

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,