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