From 4cf2bbd084300c0e7fa9715a04f08e0db9858e46 Mon Sep 17 00:00:00 2001 From: Chang Su Date: Mon, 5 Jan 2026 19:53:28 -0800 Subject: [PATCH] [router] Remove deadcode and add note for unused API completeness methods (#16528) --- .../grpc/common/stages/dispatch_metadata.rs | 1 - sgl-model-gateway/src/routers/grpc/context.rs | 28 +++---------------- .../src/routers/grpc/harmony/types.rs | 3 +- .../routers/grpc/regular/responses/context.rs | 9 +----- sgl-model-gateway/src/routers/grpc/router.rs | 1 - 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/sgl-model-gateway/src/routers/grpc/common/stages/dispatch_metadata.rs b/sgl-model-gateway/src/routers/grpc/common/stages/dispatch_metadata.rs index 067945d73..53c5ef980 100644 --- a/sgl-model-gateway/src/routers/grpc/common/stages/dispatch_metadata.rs +++ b/sgl-model-gateway/src/routers/grpc/common/stages/dispatch_metadata.rs @@ -66,7 +66,6 @@ impl PipelineStage for DispatchMetadataStage { model, created, weight_version: Some(weight_version), - is_streaming: ctx.is_streaming(), }); Ok(None) diff --git a/sgl-model-gateway/src/routers/grpc/context.rs b/sgl-model-gateway/src/routers/grpc/context.rs index b0fcbed8d..49a2404fd 100644 --- a/sgl-model-gateway/src/routers/grpc/context.rs +++ b/sgl-model-gateway/src/routers/grpc/context.rs @@ -153,8 +153,6 @@ pub(crate) struct DispatchMetadata { pub model: String, pub created: u64, pub weight_version: Option, - #[allow(dead_code)] - pub is_streaming: bool, } /// Load guards for worker load tracking @@ -368,13 +366,13 @@ impl RequestContext { } } +/// Some methods are kept for API completeness even if currently unused. +#[allow(dead_code)] impl WorkerSelection { - #[allow(dead_code)] pub fn is_dual(&self) -> bool { matches!(self, Self::Dual { .. }) } - #[allow(dead_code)] pub fn single(&self) -> Option<&Arc> { match self { Self::Single { worker } => Some(worker), @@ -401,7 +399,6 @@ impl WorkerSelection { } } - #[allow(dead_code)] #[allow(clippy::type_complexity)] pub fn dual(&self) -> Option<(&Arc, &Arc)> { match self { @@ -410,7 +407,6 @@ impl WorkerSelection { } } - #[allow(dead_code)] pub fn prefill_worker(&self) -> Option<&Arc> { match self { Self::Dual { prefill, .. } => Some(prefill), @@ -418,7 +414,6 @@ impl WorkerSelection { } } - #[allow(dead_code)] pub fn decode_worker(&self) -> Option<&Arc> { match self { Self::Dual { decode, .. } => Some(decode), @@ -427,12 +422,9 @@ impl WorkerSelection { } } +/// Some methods are kept for API completeness even if currently unused. +#[allow(dead_code)] impl ClientSelection { - #[allow(dead_code)] - pub fn is_dual(&self) -> bool { - matches!(self, Self::Dual { .. }) - } - pub fn single(&self) -> Option<&GrpcClient> { match self { Self::Single { client } => Some(client), @@ -447,14 +439,6 @@ impl ClientSelection { } } - #[allow(dead_code)] - pub fn dual(&self) -> Option<(&GrpcClient, &GrpcClient)> { - match self { - Self::Dual { prefill, decode } => Some((prefill, decode)), - _ => None, - } - } - pub fn dual_mut(&mut self) -> Option<(&mut GrpcClient, &mut GrpcClient)> { match self { Self::Dual { prefill, decode } => Some((prefill, decode)), @@ -462,7 +446,6 @@ impl ClientSelection { } } - #[allow(dead_code)] pub fn prefill_client(&self) -> Option<&GrpcClient> { match self { Self::Dual { prefill, .. } => Some(prefill), @@ -470,7 +453,6 @@ impl ClientSelection { } } - #[allow(dead_code)] pub fn prefill_client_mut(&mut self) -> Option<&mut GrpcClient> { match self { Self::Dual { prefill, .. } => Some(prefill), @@ -478,7 +460,6 @@ impl ClientSelection { } } - #[allow(dead_code)] pub fn decode_client(&self) -> Option<&GrpcClient> { match self { Self::Dual { decode, .. } => Some(decode), @@ -486,7 +467,6 @@ impl ClientSelection { } } - #[allow(dead_code)] pub fn decode_client_mut(&mut self) -> Option<&mut GrpcClient> { match self { Self::Dual { decode, .. } => Some(decode), diff --git a/sgl-model-gateway/src/routers/grpc/harmony/types.rs b/sgl-model-gateway/src/routers/grpc/harmony/types.rs index 42b525278..18b1e6d55 100644 --- a/sgl-model-gateway/src/routers/grpc/harmony/types.rs +++ b/sgl-model-gateway/src/routers/grpc/harmony/types.rs @@ -15,6 +15,7 @@ pub(crate) struct HarmonyMessage { pub content: String, } +/// Some methods are kept for API completeness even if currently unused. #[allow(dead_code)] impl HarmonyMessage { pub fn new(role: impl Into, content: impl Into) -> Self { @@ -110,7 +111,6 @@ pub(crate) struct HarmonyChannelOutput { /// /// Represents incremental updates as tokens are parsed from the stream. #[derive(Debug, Clone)] -#[allow(dead_code)] pub(crate) struct HarmonyChannelDelta { /// Delta for analysis/reasoning content pub analysis_delta: Option, @@ -122,6 +122,7 @@ pub(crate) struct HarmonyChannelDelta { pub final_delta: Option, /// Whether this is the final delta + #[allow(dead_code)] pub is_final: bool, } diff --git a/sgl-model-gateway/src/routers/grpc/regular/responses/context.rs b/sgl-model-gateway/src/routers/grpc/regular/responses/context.rs index 2fdc371e7..fc2eb1e3e 100644 --- a/sgl-model-gateway/src/routers/grpc/regular/responses/context.rs +++ b/sgl-model-gateway/src/routers/grpc/regular/responses/context.rs @@ -8,7 +8,6 @@ use std::{collections::HashMap, sync::Arc}; use tokio::{sync::RwLock, task::JoinHandle}; use crate::{ - core::WorkerRegistry, data_connector::{ConversationItemStorage, ConversationStorage, ResponseStorage}, grpc_client::SglangSchedulerClient, mcp::McpManager, @@ -36,13 +35,9 @@ pub(crate) struct ResponsesContext { /// Chat pipeline for executing requests pub pipeline: Arc, - /// Shared components (tokenizer, parsers, worker_registry) + /// Shared components (tokenizer, parsers) pub components: Arc, - /// Worker registry for validation - #[allow(dead_code)] - pub worker_registry: Arc, - /// Response storage backend pub response_storage: Arc, @@ -64,7 +59,6 @@ impl ResponsesContext { pub fn new( pipeline: Arc, components: Arc, - worker_registry: Arc, response_storage: Arc, conversation_storage: Arc, conversation_item_storage: Arc, @@ -73,7 +67,6 @@ impl ResponsesContext { Self { pipeline, components, - worker_registry, response_storage, conversation_storage, conversation_item_storage, diff --git a/sgl-model-gateway/src/routers/grpc/router.rs b/sgl-model-gateway/src/routers/grpc/router.rs index 3cb508196..d9c19beaf 100644 --- a/sgl-model-gateway/src/routers/grpc/router.rs +++ b/sgl-model-gateway/src/routers/grpc/router.rs @@ -116,7 +116,6 @@ impl GrpcRouter { responses::ResponsesContext::new( Arc::new(pipeline.clone()), shared_components.clone(), - worker_registry.clone(), ctx.response_storage.clone(), ctx.conversation_storage.clone(), ctx.conversation_item_storage.clone(),