From ab9604dee9d304a0a9f3debb95452f2148c7b64a Mon Sep 17 00:00:00 2001 From: Stanislaw Grams Date: Thu, 12 Feb 2026 20:53:47 +0100 Subject: [PATCH] [refactor](trx-client): create and thread FrontendRuntimeContext through bootstrap Create FrontendRuntimeContext as Arc during async_init and pass it to all spawn_frontend calls, enabling explicit context-based initialization. Changes: - Create frontend_runtime_ctx as Arc - Pass context to all spawn_frontend invocations in the frontend loop - Update comment to reflect Phase 3C completion This completes the threading of context through the client bootstrap, moving away from global mutable state for audio channels, decode channels, and authentication tokens. Co-Authored-By: Claude Haiku 4.5 Signed-off-by: Stanislaw Grams --- src/trx-client/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/trx-client/src/main.rs b/src/trx-client/src/main.rs index edf58af..fc8974b 100644 --- a/src/trx-client/src/main.rs +++ b/src/trx-client/src/main.rs @@ -98,14 +98,14 @@ fn main() -> DynResult<()> { struct AppState; async fn async_init() -> DynResult { + use std::sync::Arc; + tracing_subscriber::fmt().with_target(false).init(); - // Phase 3B: Create bootstrap context for explicit initialization. - // This replaces reliance on global mutable state, though currently - // built-in frontends still register on globals for plugin compatibility. - // Full de-globalization would require threading context through spawn_frontend. + // Phase 3: Create bootstrap context for explicit initialization. + // This replaces reliance on global mutable state by threading context through spawn_frontend. let mut _frontend_reg_ctx = FrontendRegistrationContext::new(); - let mut _frontend_runtime_ctx = FrontendRuntimeContext::new(); + let frontend_runtime_ctx = Arc::new(FrontendRuntimeContext::new()); register_http_frontend(); register_http_json_frontend(); @@ -248,7 +248,7 @@ async fn async_init() -> DynResult { info!("Audio disabled in config, decode will not be available"); } - // Spawn frontends + // Spawn frontends with runtime context for frontend in &frontends { let frontend_state_rx = state_rx.clone(); let addr = match frontend.as_str() { @@ -265,6 +265,7 @@ async fn async_init() -> DynResult { tx.clone(), callsign.clone(), addr, + frontend_runtime_ctx.clone(), )?; }