Skip to content

Commit

Permalink
Add some logs when an error occurs in quote syncer (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofux authored Oct 30, 2023
1 parent dd5a406 commit 89196a0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/src/presentation/cron/quotes_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{sync::Arc, time::Duration};
use anyhow::Result;
use domain::currencies;
use infrastructure::{coinmarketcap, dbclient};
use olog::info;
use olog::{error, info, IntoField};
use tokio::time::Instant;
use tokio_cron_scheduler::Job;

Expand All @@ -12,7 +12,15 @@ use crate::{application::quotes::sync::Usecase, Config};
pub async fn bootstrap(config: Config) -> Result<Job> {
let job = Job::new_repeated_async(sleep_duration(), move |_id, _lock| {
let cloned_config = config.clone();
Box::pin(async move { _bootstrap(cloned_config.clone()).await.unwrap() })
Box::pin(async move {
_bootstrap(cloned_config.clone())
.await
.map_err(|e: anyhow::Error| {
error!(error = e.to_field(), "Error in quotes syncer job");
e
})
.unwrap()
})
})?;

Ok(job)
Expand Down

0 comments on commit 89196a0

Please sign in to comment.