Skip to content

Commit

Permalink
Optimize email sending by doing it in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
PolpOnline committed Jan 7, 2025
1 parent 72a2ff9 commit d36b047
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/backend/src/workers/email_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ impl Worker<()> for EmailWorker {
}
});

for email in emails {
let emails_fut = emails.map(|email| async {
match self.smtp_client.send(email).await {
Ok(_) => {}
Err(e) => error!("Scheduled task: Error sending email: {}", e),
Ok(_) => Ok(()),
Err(e) => {
error!("Scheduled task: Error sending email: {}", e);
Err(e)
}
}
}
});

futures::future::join_all(emails_fut).await;

let down_ids = down_services
.iter()
Expand Down

0 comments on commit d36b047

Please sign in to comment.