diff options
| author | Mroik <mroik@delayed.space> | 2026-07-05 13:37:44 +0300 |
|---|---|---|
| committer | Mroik <mroik@delayed.space> | 2026-07-05 13:37:44 +0300 |
| commit | d8b4f3b3e52edccc332df4600985e9bc2ce510d3 (patch) | |
| tree | cb5f0eab008cda6c0b511dd2c701263bdaf62f55 /src/process_mail.rs | |
| parent | 938379d6d7f03747c8d7aeac4be534c9e20cfd05 (diff) | |
Signed-off-by: Mroik <mroik@delayed.space>
Diffstat (limited to 'src/process_mail.rs')
| -rw-r--r-- | src/process_mail.rs | 19 |
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 { |
