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
impl ChainIter
Sourcepub async fn next(
&self,
job: &Job,
worker: Arc<WorkerRef>,
redis: RedisPool,
) -> Result<()>
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
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§
Auto Trait Implementations§
impl Freeze for ChainIter
impl !RefUnwindSafe for ChainIter
impl Send for ChainIter
impl Sync for ChainIter
impl Unpin for ChainIter
impl !UnwindSafe for ChainIter
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