diff --git a/sgl-router/Cargo.toml b/sgl-router/Cargo.toml index 950094317..20518902c 100644 --- a/sgl-router/Cargo.toml +++ b/sgl-router/Cargo.toml @@ -8,6 +8,9 @@ default = ["grpc-client"] grpc-client = [] grpc-server = [] +[lints.rust] +unused_qualifications = "warn" + [lib] name = "sglang_router_rs" # Pure Rust library: Just omit crate-type (defaults to rlib) diff --git a/sgl-router/build.rs b/sgl-router/build.rs index 48e7e324c..a2be5d125 100644 --- a/sgl-router/build.rs +++ b/sgl-router/build.rs @@ -18,11 +18,11 @@ fn main() -> Result<(), Box> { // Add a module-level attribute for documentation and clippy warnings .server_mod_attribute( "sglang.grpc.scheduler", - "#[allow(unused, clippy::mixed_attributes_style)]", + "#[allow(unused, unused_qualifications, clippy::mixed_attributes_style)]", ) .client_mod_attribute( "sglang.grpc.scheduler", - "#[allow(unused, clippy::mixed_attributes_style)]", + "#[allow(unused, unused_qualifications, clippy::mixed_attributes_style)]", ) // Compile the proto file with the custom config .compile_protos_with_config( diff --git a/sgl-router/src/data_connector/conversation_item_oracle_store.rs b/sgl-router/src/data_connector/conversation_item_oracle_store.rs index fb3b0bc57..64c1b2503 100644 --- a/sgl-router/src/data_connector/conversation_item_oracle_store.rs +++ b/sgl-router/src/data_connector/conversation_item_oracle_store.rs @@ -286,8 +286,7 @@ impl Manager for ConversationItemOracleConnectionManager { fn create( &self, - ) -> impl std::future::Future> + Send - { + ) -> impl std::future::Future> + Send { let params = self.params.clone(); async move { let mut conn = Connection::connect( diff --git a/sgl-router/src/routers/http/openai_router.rs b/sgl-router/src/routers/http/openai_router.rs new file mode 100644 index 000000000..e69de29bb diff --git a/sgl-router/tests/responses_api_test.rs b/sgl-router/tests/responses_api_test.rs index 0ab4d720e..1019a6846 100644 --- a/sgl-router/tests/responses_api_test.rs +++ b/sgl-router/tests/responses_api_test.rs @@ -1,5 +1,6 @@ // Integration test for Responses API +use axum::http::StatusCode; use sglang_router_rs::protocols::spec::{ GenerationRequest, ReasoningEffort, ResponseInput, ResponseReasoningParam, ResponseStatus, ResponseTool, ResponseToolType, ResponsesRequest, ResponsesResponse, ServiceTier, ToolChoice, @@ -99,11 +100,11 @@ async fn test_non_streaming_mcp_minimal_e2e_with_persistence() { parallel_tool_calls: true, previous_response_id: None, reasoning: None, - service_tier: sglang_router_rs::protocols::spec::ServiceTier::Auto, + service_tier: ServiceTier::Auto, store: true, stream: false, temperature: Some(0.2), - tool_choice: sglang_router_rs::protocols::spec::ToolChoice::default(), + tool_choice: ToolChoice::default(), tools: vec![ResponseTool { r#type: ResponseToolType::Mcp, server_url: Some(mcp.url()), @@ -115,7 +116,7 @@ async fn test_non_streaming_mcp_minimal_e2e_with_persistence() { }], top_logprobs: 0, top_p: None, - truncation: sglang_router_rs::protocols::spec::Truncation::Disabled, + truncation: Truncation::Disabled, user: None, request_id: "resp_test_mcp_e2e".to_string(), priority: 0, @@ -132,7 +133,7 @@ async fn test_non_streaming_mcp_minimal_e2e_with_persistence() { .route_responses(None, &req, req.model.as_deref()) .await; - assert_eq!(resp.status(), axum::http::StatusCode::OK); + assert_eq!(resp.status(), StatusCode::OK); let body_bytes = axum::body::to_bytes(resp.into_body(), usize::MAX) .await @@ -289,7 +290,7 @@ async fn test_conversations_crud_basic() { // Create let create_body = serde_json::json!({ "metadata": { "project": "alpha" } }); let create_resp = router.create_conversation(None, &create_body).await; - assert_eq!(create_resp.status(), axum::http::StatusCode::OK); + assert_eq!(create_resp.status(), StatusCode::OK); let create_bytes = axum::body::to_bytes(create_resp.into_body(), usize::MAX) .await .unwrap(); @@ -300,7 +301,7 @@ async fn test_conversations_crud_basic() { // Get let get_resp = router.get_conversation(None, conv_id).await; - assert_eq!(get_resp.status(), axum::http::StatusCode::OK); + assert_eq!(get_resp.status(), StatusCode::OK); let get_bytes = axum::body::to_bytes(get_resp.into_body(), usize::MAX) .await .unwrap(); @@ -312,7 +313,7 @@ async fn test_conversations_crud_basic() { let upd_resp = router .update_conversation(None, conv_id, &update_body) .await; - assert_eq!(upd_resp.status(), axum::http::StatusCode::OK); + assert_eq!(upd_resp.status(), StatusCode::OK); let upd_bytes = axum::body::to_bytes(upd_resp.into_body(), usize::MAX) .await .unwrap(); @@ -322,7 +323,7 @@ async fn test_conversations_crud_basic() { // Delete let del_resp = router.delete_conversation(None, conv_id).await; - assert_eq!(del_resp.status(), axum::http::StatusCode::OK); + assert_eq!(del_resp.status(), StatusCode::OK); let del_bytes = axum::body::to_bytes(del_resp.into_body(), usize::MAX) .await .unwrap(); @@ -331,7 +332,7 @@ async fn test_conversations_crud_basic() { // Get again -> 404 let not_found = router.get_conversation(None, conv_id).await; - assert_eq!(not_found.status(), axum::http::StatusCode::NOT_FOUND); + assert_eq!(not_found.status(), StatusCode::NOT_FOUND); } #[test] @@ -662,11 +663,7 @@ async fn test_multi_turn_loop_with_mcp() { let response = router.route_responses(None, &req, None).await; // Check status - assert_eq!( - response.status(), - axum::http::StatusCode::OK, - "Request should succeed" - ); + assert_eq!(response.status(), StatusCode::OK, "Request should succeed"); // Read the response body use axum::body::to_bytes; @@ -837,7 +834,7 @@ async fn test_max_tool_calls_limit() { }; let response = router.route_responses(None, &req, None).await; - assert_eq!(response.status(), axum::http::StatusCode::OK); + assert_eq!(response.status(), StatusCode::OK); use axum::body::to_bytes; let response_body = response.into_body(); @@ -1037,7 +1034,7 @@ async fn test_streaming_with_mcp_tool_calls() { // Verify streaming response assert_eq!( response.status(), - axum::http::StatusCode::OK, + StatusCode::OK, "Streaming request should succeed" ); @@ -1312,7 +1309,7 @@ async fn test_streaming_multi_turn_with_mcp() { }; let response = router.route_responses(None, &req, None).await; - assert_eq!(response.status(), axum::http::StatusCode::OK); + assert_eq!(response.status(), StatusCode::OK); use axum::body::to_bytes; let body_bytes = to_bytes(response.into_body(), usize::MAX).await.unwrap(); diff --git a/sgl-router/tests/test_openai_routing.rs b/sgl-router/tests/test_openai_routing.rs index f65ed5ace..3e288928e 100644 --- a/sgl-router/tests/test_openai_routing.rs +++ b/sgl-router/tests/test_openai_routing.rs @@ -96,7 +96,7 @@ async fn test_openai_router_creation() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await; @@ -146,7 +146,7 @@ async fn test_openai_router_models() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -226,7 +226,7 @@ async fn test_openai_router_responses_with_mock() { None, storage.clone(), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -487,7 +487,7 @@ async fn test_openai_router_responses_streaming_with_mock() { None, storage.clone(), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -592,7 +592,7 @@ async fn test_unsupported_endpoints() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -634,7 +634,7 @@ async fn test_openai_router_chat_completion_with_mock() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -677,7 +677,7 @@ async fn test_openai_e2e_with_server() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -748,7 +748,7 @@ async fn test_openai_router_chat_streaming_with_mock() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -802,7 +802,7 @@ async fn test_openai_router_circuit_breaker() { Some(cb_config), Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap(); @@ -831,7 +831,7 @@ async fn test_openai_router_models_auth_forwarding() { None, Arc::new(MemoryResponseStorage::new()), Arc::new(MemoryConversationStorage::new()), - Arc::new(sglang_router_rs::data_connector::MemoryConversationItemStorage::new()), + Arc::new(MemoryConversationItemStorage::new()), ) .await .unwrap();