-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Victor Login <batazor111@gmail.com>
- Loading branch information
Showing
7 changed files
with
182 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
boundaries/billing/currency/src/usecases/load_exchange_rates_cron/cron.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use tokio_cron_scheduler::{Job, JobScheduler}; | ||
use std::sync::Arc; | ||
use crate::usecases::exchange_rate::fetcher::RateFetcherUseCase; | ||
use tracing::{info, error}; | ||
|
||
async fn run_currency_update_job( | ||
rate_fetcher_use_case: Arc<RateFetcherUseCase> | ||
) { | ||
info!("Starting exchange rate update job..."); | ||
|
||
let from_currency = "USD"; // Example currencies | ||
let to_currency = "EUR"; | ||
|
||
match rate_fetcher_use_case.fetch_rate(from_currency, to_currency).await { | ||
Some(exchange_rate) => { | ||
info!( | ||
"Successfully fetched exchange rate for {} to {}: {}", | ||
from_currency, to_currency, exchange_rate.rate | ||
); | ||
// Additional logic to store in cache/database if needed | ||
} | ||
None => { | ||
error!( | ||
"Failed to fetch exchange rate for {} to {}", | ||
from_currency, to_currency | ||
); | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod currency_conversion; | ||
pub mod exchange_rate; | ||
mod load_exchange_rates_cron; | ||
// pub mod discrepancies; | ||
// pub mod load_exchange_rates; | ||
// pub mod load_exchange_rates_cron; |