[refactor](trx-client): create bootstrap frontend context

Demonstrate context-based frontend initialization in async_init.

Creates FrontendRegistrationContext and FrontendRuntimeContext at bootstrap
to establish the pattern for explicit frontend management instead of globals.

Full threading of context through spawn_frontend would require changing the
frontend trait signature and updating all frontend implementations - planned
for Phase 3C.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
2026-02-12 20:49:41 +01:00
parent 0a8a98ea54
commit adddfc1c3b
+8 -1
View File
@@ -23,7 +23,7 @@ use trx_core::audio::AudioStreamInfo;
use trx_core::rig::request::RigRequest; use trx_core::rig::request::RigRequest;
use trx_core::rig::state::RigState; use trx_core::rig::state::RigState;
use trx_core::DynResult; use trx_core::DynResult;
use trx_frontend::{is_frontend_registered, registered_frontends}; use trx_frontend::{is_frontend_registered, registered_frontends, FrontendRegistrationContext, FrontendRuntimeContext};
use trx_core::decode::DecodedMessage; use trx_core::decode::DecodedMessage;
use trx_frontend_http::{register_frontend as register_http_frontend, set_audio_channels, set_decode_channel}; use trx_frontend_http::{register_frontend as register_http_frontend, set_audio_channels, set_decode_channel};
use trx_frontend_http_json::{register_frontend as register_http_json_frontend, set_auth_tokens}; use trx_frontend_http_json::{register_frontend as register_http_json_frontend, set_auth_tokens};
@@ -100,6 +100,13 @@ struct AppState;
async fn async_init() -> DynResult<AppState> { async fn async_init() -> DynResult<AppState> {
tracing_subscriber::fmt().with_target(false).init(); 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.
let mut _frontend_reg_ctx = FrontendRegistrationContext::new();
let mut _frontend_runtime_ctx = FrontendRuntimeContext::new();
register_http_frontend(); register_http_frontend();
register_http_json_frontend(); register_http_json_frontend();
register_rigctl_frontend(); register_rigctl_frontend();