From c3abc5ff5b10f9813cc653615dcad4af3762d1b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Mar 2026 22:42:49 +0000 Subject: [PATCH] [refactor](trx-frontend): add DecodeHistory type alias and use bounded channels Introduce DecodeHistory alias for the repeated Arc, T)>>> pattern (9 fields). Also switch VChanAudioCmd channel senders from UnboundedSender to Sender to prevent unbounded memory growth under backpressure. https://claude.ai/code/session_01XzurkeuUmamBuhQwxVy7T4 Signed-off-by: Claude --- src/trx-client/trx-frontend/src/lib.rs | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/trx-client/trx-frontend/src/lib.rs b/src/trx-client/trx-frontend/src/lib.rs index 213d8ec..f206dff 100644 --- a/src/trx-client/trx-frontend/src/lib.rs +++ b/src/trx-client/trx-frontend/src/lib.rs @@ -22,6 +22,11 @@ use trx_core::decode::{ use trx_core::rig::state::{RigSnapshot, SpectrumData}; use trx_core::{DynResult, RigRequest, RigState}; +/// Shared, timestamped decode history for a single decoder type. +/// +/// Each entry is `(record_time, optional_rig_id, decoded_message)`. +pub type DecodeHistory = Arc, T)>>>; + /// Command sent by the HTTP frontend to the audio-client task to manage a /// virtual channel's audio stream over the server's audio TCP connection. #[derive(Debug)] @@ -196,23 +201,23 @@ pub struct FrontendRuntimeContext { pub decode_rx: Option>, /// Decode history entry: (record_time, rig_id, message). /// AIS decode history - pub ais_history: Arc, AisMessage)>>>, + pub ais_history: DecodeHistory, /// VDES decode history - pub vdes_history: Arc, VdesMessage)>>>, + pub vdes_history: DecodeHistory, /// APRS decode history - pub aprs_history: Arc, AprsPacket)>>>, + pub aprs_history: DecodeHistory, /// HF APRS decode history - pub hf_aprs_history: Arc, AprsPacket)>>>, + pub hf_aprs_history: DecodeHistory, /// CW decode history - pub cw_history: Arc, CwEvent)>>>, + pub cw_history: DecodeHistory, /// FT8 decode history - pub ft8_history: Arc, Ft8Message)>>>, + pub ft8_history: DecodeHistory, /// FT4 decode history - pub ft4_history: Arc, Ft8Message)>>>, + pub ft4_history: DecodeHistory, /// FT2 decode history - pub ft2_history: Arc, Ft8Message)>>>, + pub ft2_history: DecodeHistory, /// WSPR decode history - pub wspr_history: Arc, WsprMessage)>>>, + pub wspr_history: DecodeHistory, /// Authentication tokens for HTTP-JSON frontend pub auth_tokens: HashSet, /// Active HTTP SSE clients (incremented on /events connect, decremented on disconnect). @@ -277,7 +282,7 @@ pub struct FrontendRuntimeContext { /// Per-rig audio stream info watch channels, keyed by rig_id. pub rig_audio_info: Arc>>>>, /// Per-rig virtual-channel command senders, keyed by rig_id. - pub rig_vchan_audio_cmd: Arc>>>, + pub rig_vchan_audio_cmd: Arc>>>, /// Per-virtual-channel Opus audio senders. /// Key: server-side virtual channel UUID. /// Value: `broadcast::Sender` that receives per-channel Opus packets @@ -286,7 +291,7 @@ pub struct FrontendRuntimeContext { /// Channel to send `VChanAudioCmd` to the audio-client task, which in turn /// forwards `VCHAN_SUB` / `VCHAN_UNSUB` frames over the audio TCP connection. /// `None` when no audio connection is active. - pub vchan_audio_cmd: Arc>>>, + pub vchan_audio_cmd: Arc>>>, /// Broadcast sender that fires whenever the server destroys a virtual /// channel (e.g. out-of-bandwidth after center-frequency retune). /// The HTTP frontend subscribes to clean up `ClientChannelManager`.