aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/process_mail.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/process_mail.rs b/src/process_mail.rs
index 90fdd2a..f1ad40d 100644
--- a/src/process_mail.rs
+++ b/src/process_mail.rs
@@ -24,15 +24,24 @@ impl MailProcessor {
// TODO: Check againts self.rx.is_closed() instead to stop the program before consuming all
// of the queue. Store the emails not yet processed and restore the queue upon startup.
while let Some(mail) = self.rx.recv().await {
- let mut db_guard = self.db.lock().await;
- db_guard.execute(MailQuery::Insert(&mail))?;
- drop(db_guard);
-
- todo!();
+ // TODO: should this be replaced with a send to another actor to pipeline the work? Is
+ // the complexity worth the speedup?
+ match self.do_processing(mail).await {
+ Ok(_) => todo!(),
+ Err(_) => todo!(),
+ }
}
Ok(())
}
+
+ async fn do_processing(&mut self, mail: Mail) -> Result<()> {
+ let mut db_guard = self.db.lock().await;
+ db_guard.execute(MailQuery::Insert(&mail))?;
+ drop(db_guard);
+
+ todo!();
+ }
}
mod tests {
XMR address: 854DmXNrxULU3ZFJVs4Wc8PFhbq29RhqHhY8W6cdWrtFN3qmooKyyeYPcDzZTNRxphhJ5UzASQfAdEMwSteVqymk28aLhqj