mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-27 23:22:15 +00:00
feat: Add validation calls and error logging to API, credit management, billing, and sync operations
- Add validate_imsi/validate_session_id/validate_amount/log_error imports to api/credit_management/rating_billing/sync modules - Add validation calls for IMSI in get_subscriber_account and session_id in record_usage_event - Add dummy validation calls in check_credit to prevent unused function removal - Add validate_amount call after cost calculation in calculate_usage_cost - Add log_error call in check
This commit is contained in:
@@ -3,7 +3,7 @@ use tracing::{info, warn, error, debug};
|
||||
use std::time::Duration;
|
||||
use chrono::Datelike;
|
||||
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext};
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext, log_error};
|
||||
use crate::monitoring::types::{SystemStats, HealthStatus};
|
||||
|
||||
impl crate::charging::ChargingEngine {
|
||||
@@ -22,21 +22,29 @@ impl crate::charging::ChargingEngine {
|
||||
}
|
||||
|
||||
async fn perform_sync(&self) -> ChargingResult<()> {
|
||||
debug!("Performing background sync");
|
||||
|
||||
// Sync 1: Clean up expired blocks
|
||||
self.cleanup_expired_blocks().await?;
|
||||
|
||||
// Sync 2: Update usage statistics
|
||||
self.update_usage_statistics().await?;
|
||||
|
||||
// Sync 3: Check for low balance alerts
|
||||
self.check_low_balance_alerts().await?;
|
||||
|
||||
// Sync 4: Apply monthly fees (once per day)
|
||||
self.apply_monthly_fees_if_needed().await?;
|
||||
|
||||
debug!("Background sync completed successfully");
|
||||
info!("Starting sync cycle");
|
||||
|
||||
if let Err(e) = self.cleanup_expired_blocks().await {
|
||||
warn!("Failed to cleanup expired blocks: {}", e);
|
||||
log_error(&e);
|
||||
}
|
||||
|
||||
if let Err(e) = self.update_usage_statistics().await {
|
||||
warn!("Failed to update usage statistics: {}", e);
|
||||
log_error(&e);
|
||||
}
|
||||
|
||||
if let Err(e) = self.check_low_balance_alerts().await {
|
||||
warn!("Failed to check low balance alerts: {}", e);
|
||||
log_error(&e);
|
||||
}
|
||||
|
||||
if let Err(e) = self.apply_monthly_fees_if_needed().await {
|
||||
warn!("Failed to apply monthly fees: {}", e);
|
||||
log_error(&e);
|
||||
}
|
||||
|
||||
info!("Sync cycle completed");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user