Super tiny move error.rs (#14944)
This commit is contained in:
@@ -318,8 +318,7 @@ impl RouterMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn record_request_duration(duration: Duration) {
|
pub fn record_request_duration(duration: Duration) {
|
||||||
histogram!("sgl_router_request_duration_seconds")
|
histogram!("sgl_router_request_duration_seconds").record(duration.as_secs_f64());
|
||||||
.record(duration.as_secs_f64());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn record_request_error(route: &str, error_type: &str) {
|
pub fn record_request_error(route: &str, error_type: &str) {
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
use axum::response::Response;
|
use axum::response::Response;
|
||||||
|
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
context::ExecutionResult, error, proto_wrapper::ProtoGenerateComplete, utils,
|
error,
|
||||||
|
grpc::{context::ExecutionResult, proto_wrapper::ProtoGenerateComplete, utils},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Collect and merge responses from execution result
|
/// Collect and merge responses from execution result
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use crate::{
|
|||||||
responses::{ResponseTool, ResponseToolType, ResponsesRequest, ResponsesResponse},
|
responses::{ResponseTool, ResponseToolType, ResponsesRequest, ResponsesResponse},
|
||||||
},
|
},
|
||||||
routers::{
|
routers::{
|
||||||
grpc::error,
|
error,
|
||||||
openai::{conversations::persist_conversation_items, mcp::ensure_request_mcp_client},
|
openai::{conversations::persist_conversation_items, mcp::ensure_request_mcp_client},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::PipelineStage;
|
use super::PipelineStage;
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
context::{ClientSelection, RequestContext, WorkerSelection},
|
context::{ClientSelection, RequestContext, WorkerSelection},
|
||||||
error, utils,
|
utils,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Client acquisition stage: Get gRPC clients from selected workers
|
/// Client acquisition stage: Get gRPC clients from selected workers
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::PipelineStage;
|
use super::PipelineStage;
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
context::{DispatchMetadata, RequestContext, RequestType, WorkerSelection},
|
|
||||||
error,
|
error,
|
||||||
|
grpc::context::{DispatchMetadata, RequestContext, RequestType, WorkerSelection},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Dispatch metadata stage: Prepare metadata for dispatch
|
/// Dispatch metadata stage: Prepare metadata for dispatch
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ use axum::response::Response;
|
|||||||
use tracing::{error, info_span, Instrument};
|
use tracing::{error, info_span, Instrument};
|
||||||
|
|
||||||
use super::PipelineStage;
|
use super::PipelineStage;
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
context::{ClientSelection, ExecutionResult, RequestContext},
|
|
||||||
error,
|
error,
|
||||||
|
grpc::{
|
||||||
|
context::{ClientSelection, ExecutionResult, RequestContext},
|
||||||
proto_wrapper::{ProtoGenerateRequest, ProtoStream},
|
proto_wrapper::{ProtoGenerateRequest, ProtoStream},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
type StreamResult = Result<ProtoStream, Box<dyn std::error::Error + Send + Sync>>;
|
type StreamResult = Result<ProtoStream, Box<dyn std::error::Error + Send + Sync>>;
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ use super::PipelineStage;
|
|||||||
use crate::{
|
use crate::{
|
||||||
core::{ConnectionMode, Worker, WorkerRegistry, WorkerType},
|
core::{ConnectionMode, Worker, WorkerRegistry, WorkerType},
|
||||||
policies::PolicyRegistry,
|
policies::PolicyRegistry,
|
||||||
routers::grpc::{
|
routers::{
|
||||||
context::{RequestContext, WorkerSelection},
|
|
||||||
error,
|
error,
|
||||||
|
grpc::context::{RequestContext, WorkerSelection},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ use crate::{
|
|||||||
ResponseStatus, ResponseUsage, ResponsesRequest, ResponsesResponse, ResponsesUsage,
|
ResponseStatus, ResponseUsage, ResponsesRequest, ResponsesResponse, ResponsesUsage,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routers::grpc::{
|
routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::{response_collection, response_formatting},
|
common::{response_collection, response_formatting},
|
||||||
context::{DispatchMetadata, ExecutionResult},
|
context::{DispatchMetadata, ExecutionResult},
|
||||||
error,
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,16 +54,18 @@ use crate::{
|
|||||||
ResponsesUsage, StringOrContentParts,
|
ResponsesUsage, StringOrContentParts,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routers::grpc::{
|
routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::responses::{
|
common::responses::{
|
||||||
build_sse_response, ensure_mcp_connection, persist_response_if_needed,
|
build_sse_response, ensure_mcp_connection, persist_response_if_needed,
|
||||||
streaming::{OutputItemType, ResponseStreamEventEmitter},
|
streaming::{OutputItemType, ResponseStreamEventEmitter},
|
||||||
},
|
},
|
||||||
context::SharedComponents,
|
context::SharedComponents,
|
||||||
error,
|
|
||||||
harmony::{processor::ResponsesIterationResult, streaming::HarmonyStreamingProcessor},
|
harmony::{processor::ResponsesIterationResult, streaming::HarmonyStreamingProcessor},
|
||||||
pipeline::RequestPipeline,
|
pipeline::RequestPipeline,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Maximum number of tool execution iterations to prevent infinite loops
|
/// Maximum number of tool execution iterations to prevent infinite loops
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ use crate::{
|
|||||||
common::{Tool, ToolChoice, ToolChoiceValue},
|
common::{Tool, ToolChoice, ToolChoiceValue},
|
||||||
responses::ResponsesRequest,
|
responses::ResponsesRequest,
|
||||||
},
|
},
|
||||||
routers::grpc::{
|
routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::{responses::utils::extract_tools_from_response_tools, stages::PipelineStage},
|
common::{responses::utils::extract_tools_from_response_tools, stages::PipelineStage},
|
||||||
context::{PreparationOutput, RequestContext, RequestType},
|
context::{PreparationOutput, RequestContext, RequestType},
|
||||||
error, utils,
|
utils,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ use axum::response::Response;
|
|||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::{helpers, PipelineStage},
|
common::stages::{helpers, PipelineStage},
|
||||||
context::{ClientSelection, RequestContext, RequestType, WorkerSelection},
|
context::{ClientSelection, RequestContext, RequestType, WorkerSelection},
|
||||||
error,
|
|
||||||
proto_wrapper::ProtoGenerateRequest,
|
proto_wrapper::ProtoGenerateRequest,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Harmony Request Building stage: Convert Harmony tokens to gRPC request
|
/// Harmony Request Building stage: Convert Harmony tokens to gRPC request
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::super::{HarmonyResponseProcessor, HarmonyStreamingProcessor};
|
use super::super::{HarmonyResponseProcessor, HarmonyStreamingProcessor};
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{FinalResponse, RequestContext, RequestType},
|
context::{FinalResponse, RequestContext, RequestType},
|
||||||
error,
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Harmony Response Processing stage: Parse and format Harmony responses
|
/// Harmony Response Processing stage: Parse and format Harmony responses
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use crate::{grpc_client::sglang_proto::MultimodalInputs, protocols::common::Stri
|
|||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub mod error;
|
|
||||||
pub mod harmony;
|
pub mod harmony;
|
||||||
pub mod pd_router;
|
pub mod pd_router;
|
||||||
pub mod pipeline;
|
pub mod pipeline;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use tracing::error;
|
|||||||
use super::{
|
use super::{
|
||||||
common::stages::*,
|
common::stages::*,
|
||||||
context::*,
|
context::*,
|
||||||
error, harmony,
|
harmony,
|
||||||
regular::{processor, stages::*, streaming},
|
regular::{processor, stages::*, streaming},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -22,6 +22,7 @@ use crate::{
|
|||||||
generate::GenerateRequest,
|
generate::GenerateRequest,
|
||||||
},
|
},
|
||||||
reasoning_parser::ParserFactory as ReasoningParserFactory,
|
reasoning_parser::ParserFactory as ReasoningParserFactory,
|
||||||
|
routers::error,
|
||||||
tokenizer::traits::Tokenizer,
|
tokenizer::traits::Tokenizer,
|
||||||
tool_parser::ParserFactory as ToolParserFactory,
|
tool_parser::ParserFactory as ToolParserFactory,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ use crate::{
|
|||||||
generate::{GenerateMetaInfo, GenerateRequest, GenerateResponse},
|
generate::{GenerateMetaInfo, GenerateRequest, GenerateResponse},
|
||||||
},
|
},
|
||||||
reasoning_parser::ParserFactory as ReasoningParserFactory,
|
reasoning_parser::ParserFactory as ReasoningParserFactory,
|
||||||
routers::grpc::{
|
routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::{response_collection, response_formatting},
|
common::{response_collection, response_formatting},
|
||||||
context::{DispatchMetadata, ExecutionResult},
|
context::{DispatchMetadata, ExecutionResult},
|
||||||
error,
|
|
||||||
proto_wrapper::ProtoGenerateComplete,
|
proto_wrapper::ProtoGenerateComplete,
|
||||||
utils,
|
utils,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
tokenizer::{
|
tokenizer::{
|
||||||
stop::{SequenceDecoderOutput, StopSequenceDecoder},
|
stop::{SequenceDecoderOutput, StopSequenceDecoder},
|
||||||
traits::Tokenizer,
|
traits::Tokenizer,
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ use crate::{
|
|||||||
ResponsesUsage,
|
ResponsesUsage,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routers::grpc::{
|
routers::{
|
||||||
common::responses::{
|
error,
|
||||||
|
grpc::common::responses::{
|
||||||
build_sse_response, ensure_mcp_connection, persist_response_if_needed,
|
build_sse_response, ensure_mcp_connection, persist_response_if_needed,
|
||||||
streaming::ResponseStreamEventEmitter,
|
streaming::ResponseStreamEventEmitter,
|
||||||
},
|
},
|
||||||
error,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ use crate::{
|
|||||||
ResponsesResponse,
|
ResponsesResponse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routers::grpc::{
|
routers::{
|
||||||
common::responses::streaming::{OutputItemType, ResponseStreamEventEmitter},
|
|
||||||
error,
|
error,
|
||||||
|
grpc::common::responses::streaming::{OutputItemType, ResponseStreamEventEmitter},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ use tracing::error;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::chat::ChatCompletionRequest,
|
protocols::chat::ChatCompletionRequest,
|
||||||
routers::grpc::{
|
routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{PreparationOutput, RequestContext},
|
context::{PreparationOutput, RequestContext},
|
||||||
error, utils,
|
utils,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
client::GrpcClient,
|
client::GrpcClient,
|
||||||
common::stages::{helpers, PipelineStage},
|
common::stages::{helpers, PipelineStage},
|
||||||
context::{ClientSelection, RequestContext, WorkerSelection},
|
context::{ClientSelection, RequestContext, WorkerSelection},
|
||||||
error,
|
|
||||||
proto_wrapper::ProtoGenerateRequest,
|
proto_wrapper::ProtoGenerateRequest,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Chat request building stage
|
/// Chat request building stage
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ use async_trait::async_trait;
|
|||||||
use axum::response::Response;
|
use axum::response::Response;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{FinalResponse, RequestContext},
|
context::{FinalResponse, RequestContext},
|
||||||
error,
|
|
||||||
regular::{processor, streaming},
|
regular::{processor, streaming},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Chat response processing stage
|
/// Chat response processing stage
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ use tracing::error;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::{common::InputIds, generate::GenerateRequest},
|
protocols::{common::InputIds, generate::GenerateRequest},
|
||||||
routers::grpc::{
|
routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{PreparationOutput, RequestContext},
|
context::{PreparationOutput, RequestContext},
|
||||||
error, utils,
|
utils,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tokenizer::traits::Tokenizer,
|
tokenizer::traits::Tokenizer,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
client::GrpcClient,
|
client::GrpcClient,
|
||||||
common::stages::{helpers, PipelineStage},
|
common::stages::{helpers, PipelineStage},
|
||||||
context::{ClientSelection, RequestContext, WorkerSelection},
|
context::{ClientSelection, RequestContext, WorkerSelection},
|
||||||
error,
|
|
||||||
proto_wrapper::ProtoGenerateRequest,
|
proto_wrapper::ProtoGenerateRequest,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Generate request building stage
|
/// Generate request building stage
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ use async_trait::async_trait;
|
|||||||
use axum::response::Response;
|
use axum::response::Response;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{FinalResponse, RequestContext},
|
context::{FinalResponse, RequestContext},
|
||||||
error,
|
|
||||||
regular::{processor, streaming},
|
regular::{processor, streaming},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Generate response processing stage
|
/// Generate response processing stage
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::{chat::ChatPreparationStage, generate::GeneratePreparationStage};
|
use super::{chat::ChatPreparationStage, generate::GeneratePreparationStage};
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error as grpc_error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{RequestContext, RequestType},
|
context::{RequestContext, RequestType},
|
||||||
error as grpc_error,
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Preparation stage (delegates to endpoint-specific implementations)
|
/// Preparation stage (delegates to endpoint-specific implementations)
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::{chat::ChatRequestBuildingStage, generate::GenerateRequestBuildingStage};
|
use super::{chat::ChatRequestBuildingStage, generate::GenerateRequestBuildingStage};
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error as grpc_error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{RequestContext, RequestType},
|
context::{RequestContext, RequestType},
|
||||||
error as grpc_error,
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request building stage (delegates to endpoint-specific implementations)
|
/// Request building stage (delegates to endpoint-specific implementations)
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ use axum::response::Response;
|
|||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::{chat::ChatResponseProcessingStage, generate::GenerateResponseProcessingStage};
|
use super::{chat::ChatResponseProcessingStage, generate::GenerateResponseProcessingStage};
|
||||||
use crate::routers::grpc::{
|
use crate::routers::{
|
||||||
|
error,
|
||||||
|
grpc::{
|
||||||
common::stages::PipelineStage,
|
common::stages::PipelineStage,
|
||||||
context::{RequestContext, RequestType},
|
context::{RequestContext, RequestType},
|
||||||
error,
|
|
||||||
regular::{processor, streaming},
|
regular::{processor, streaming},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Response processing stage (delegates to endpoint-specific implementations)
|
/// Response processing stage (delegates to endpoint-specific implementations)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
client::GrpcClient,
|
client::GrpcClient,
|
||||||
error,
|
|
||||||
proto_wrapper::{ProtoGenerateComplete, ProtoStream},
|
proto_wrapper::{ProtoGenerateComplete, ProtoStream},
|
||||||
ProcessedMessages,
|
ProcessedMessages,
|
||||||
};
|
};
|
||||||
@@ -28,7 +27,7 @@ use crate::{
|
|||||||
ParserFactory as ReasoningParserFactory, PooledParser as ReasoningPooledParser,
|
ParserFactory as ReasoningParserFactory, PooledParser as ReasoningPooledParser,
|
||||||
ReasoningParser,
|
ReasoningParser,
|
||||||
},
|
},
|
||||||
routers::grpc::proto_wrapper::ProtoResponseVariant,
|
routers::{error, grpc::proto_wrapper::ProtoResponseVariant},
|
||||||
tokenizer::{
|
tokenizer::{
|
||||||
cache::CachedTokenizer,
|
cache::CachedTokenizer,
|
||||||
chat_template::{ChatTemplateContentFormat, ChatTemplateParams},
|
chat_template::{ChatTemplateContentFormat, ChatTemplateParams},
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use crate::protocols::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub mod conversations;
|
pub mod conversations;
|
||||||
|
pub mod error;
|
||||||
pub mod factory;
|
pub mod factory;
|
||||||
pub mod grpc;
|
pub mod grpc;
|
||||||
pub mod header_utils;
|
pub mod header_utils;
|
||||||
|
|||||||
Reference in New Issue
Block a user