mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 11:02:54 +00:00
feat: Remove unused imports and suppress dead_code warnings across charging engine modules
- Remove unused AsyncCommands/error/ChargingSession/ErrorContext imports from credit_management - Remove unused ErrorContext/ChargingError imports from engine - Remove unused ErrorContext import from rating_billing and prefix unused variables with underscore - Remove unused ErrorContext import from rating_plans_repo - Remove unused Context import from errors/helpers - Remove unused info/debug/SystemTime imports from monitoring - Remove unused sleep
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use redis::AsyncCommands;
|
||||
use tracing::{info, warn, error, debug};
|
||||
use tracing::{info, warn, debug};
|
||||
|
||||
use super::types::{SubscriberAccount, UsageEvent, ChargingSession};
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext, validate_imsi, validate_session_id, validate_bytes};
|
||||
use super::types::{SubscriberAccount, UsageEvent};
|
||||
use crate::errors::{ChargingError, ChargingResult, validate_imsi, validate_session_id};
|
||||
|
||||
impl crate::charging::ChargingEngine {
|
||||
pub async fn get_balance(&self, ip: &str) -> ChargingResult<u64> {
|
||||
|
||||
@@ -4,7 +4,7 @@ use tracing::info;
|
||||
|
||||
use super::rating_plans_repo::RatingPlansRepo;
|
||||
use super::types::RatingPlan;
|
||||
use crate::errors::{ChargingResult, ErrorContext, ChargingError};
|
||||
use crate::errors::ChargingResult;
|
||||
|
||||
/// ChargingEngine coordinates Redis-backed hot-path state (balances, sessions)
|
||||
/// and Postgres-backed configuration (rating plans) via `RatingPlansRepo`.
|
||||
|
||||
@@ -2,13 +2,14 @@ use chrono::Utc;
|
||||
use tracing::{info, debug, warn};
|
||||
|
||||
use super::types::{UsageEvent, UsageType};
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext, validate_amount};
|
||||
use crate::errors::{ChargingError, ChargingResult, validate_amount};
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl super::ChargingEngine {
|
||||
pub async fn calculate_usage_cost(&self, event: &UsageEvent) -> ChargingResult<f64> {
|
||||
// Get subscriber account to determine rating plan
|
||||
let account = self.get_subscriber_account(&event.imsi).await?;
|
||||
let account = account.ok_or_else(|| ChargingError::SubscriberNotFound(event.imsi.clone()))?;
|
||||
let _account = account.ok_or_else(|| ChargingError::SubscriberNotFound(event.imsi.clone()))?;
|
||||
|
||||
// Get rating plan from Postgres (simplified - defaults to basic).
|
||||
let plan = self
|
||||
@@ -128,7 +129,7 @@ impl super::ChargingEngine {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn generate_invoice(&self, imsi: &str, billing_period: &str) -> ChargingResult<f64> {
|
||||
pub async fn generate_invoice(&self, imsi: &str, _billing_period: &str) -> ChargingResult<f64> {
|
||||
// Get all usage events for the billing period
|
||||
let mut conn = self.redis_client.get_multiplexed_async_connection().await
|
||||
.map_err(|e| crate::errors::ChargingError::RedisConnection(e.to_string()))?;
|
||||
|
||||
@@ -9,7 +9,7 @@ use sqlx::postgres::{PgPool, PgPoolOptions};
|
||||
use sqlx::Row;
|
||||
|
||||
use super::types::RatingPlan;
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext};
|
||||
use crate::errors::ChargingResult;
|
||||
|
||||
/// Repository for rating plans backed by Postgres.
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -56,6 +56,7 @@ pub struct RatingPlan {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub struct ChargingSession {
|
||||
pub session_id: String,
|
||||
pub imsi: String,
|
||||
@@ -69,6 +70,7 @@ pub struct ChargingSession {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub enum SessionStatus {
|
||||
Active,
|
||||
Completed,
|
||||
@@ -76,6 +78,7 @@ pub enum SessionStatus {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub struct ChargingRule {
|
||||
pub rule_id: String,
|
||||
pub name: String,
|
||||
@@ -85,6 +88,7 @@ pub struct ChargingRule {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Condition {
|
||||
pub field: String,
|
||||
pub operator: String,
|
||||
@@ -92,6 +96,7 @@ pub struct Condition {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Action {
|
||||
pub action_type: String,
|
||||
pub parameters: std::collections::HashMap<String, String>,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use anyhow::Context;
|
||||
|
||||
use super::types::ChargingError;
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ pub enum ChargingError {
|
||||
SubscriberNotFound(String),
|
||||
RatingPlanNotFound(String),
|
||||
InsufficientCredit { available: u64, requested: u64 },
|
||||
#[allow(dead_code)]
|
||||
UsageBlocked(String),
|
||||
InvalidInput(String),
|
||||
SerializationError(String),
|
||||
#[allow(dead_code)]
|
||||
ConfigurationError(String),
|
||||
InternalError(String),
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct AppState {
|
||||
pub charging_engine: std::sync::Arc<crate::charging::ChargingEngine>,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use tracing::{info, debug};
|
||||
use std::time::SystemTime;
|
||||
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext};
|
||||
use super::types::{SystemStats, HealthStatus};
|
||||
use crate::errors::ChargingResult;
|
||||
|
||||
impl crate::charging::ChargingEngine {
|
||||
pub async fn get_performance_metrics(&self) -> ChargingResult<PerformanceMetrics> {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use tokio::time::{interval, sleep};
|
||||
use tokio::time::interval;
|
||||
use tracing::{info, warn, error, debug};
|
||||
use std::time::Duration;
|
||||
use chrono::Datelike;
|
||||
|
||||
use crate::errors::{ChargingError, ChargingResult, ErrorContext, log_error};
|
||||
use crate::errors::{ChargingResult, log_error};
|
||||
use crate::monitoring::types::{SystemStats, HealthStatus};
|
||||
|
||||
impl crate::charging::ChargingEngine {
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct HealthStatus {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct PerformanceMetrics {
|
||||
pub connected_clients: u64,
|
||||
pub used_memory: u64,
|
||||
@@ -25,6 +26,7 @@ pub struct PerformanceMetrics {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct ErrorStats {
|
||||
pub total_errors: u64,
|
||||
pub error_types: std::collections::HashMap<String, u64>,
|
||||
|
||||
Reference in New Issue
Block a user