From 8bb332964bb346ace7c515016bfcab13933d60d2 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Wed, 29 Apr 2026 04:23:11 +0300 Subject: [PATCH] refactor: Replace unwrap() with unwrap_or_else fallback in rate limiter configuration - Add fallback to default GovernorConfig (10 req/s, burst 20) if custom config fails - Replace unwrap() with unwrap_or_else providing sensible defaults - Add comment explaining fallback behavior for rate limiter initialization --- apps/charging-engine/src/routes.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/charging-engine/src/routes.rs b/apps/charging-engine/src/routes.rs index 0c13e64..7607b51 100644 --- a/apps/charging-engine/src/routes.rs +++ b/apps/charging-engine/src/routes.rs @@ -37,7 +37,14 @@ pub fn create_router(state: AppState) -> Router { .per_second(requests_per_second as u64) .burst_size(burst_size) .finish() - .unwrap(); + .unwrap_or_else(|_| { + // Fallback to default config if builder fails + GovernorConfigBuilder::default() + .per_second(10) + .burst_size(20) + .finish() + .expect("Default governor config should never fail") + }); Router::new() // Public routes (no auth required - for packet-gateway integration)