fix: sgl-router remove dead code (#8257)
This commit is contained in:
@@ -283,82 +283,6 @@ impl Router {
|
|||||||
HttpResponse::InternalServerError().body("All retry attempts failed")
|
HttpResponse::InternalServerError().body("All retry attempts failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn route_to_all(
|
|
||||||
&self,
|
|
||||||
client: &reqwest::Client,
|
|
||||||
route: &str,
|
|
||||||
req: &HttpRequest,
|
|
||||||
) -> HttpResponse {
|
|
||||||
// Get all worker URLs
|
|
||||||
let worker_urls = self.get_worker_urls();
|
|
||||||
|
|
||||||
// Send requests to all workers concurrently
|
|
||||||
let mut tasks = Vec::new();
|
|
||||||
for worker_url in &worker_urls {
|
|
||||||
let mut request_builder = client.post(format!("{}{}", worker_url, route));
|
|
||||||
|
|
||||||
// Copy headers from original request
|
|
||||||
for (name, value) in copy_request_headers(req) {
|
|
||||||
request_builder = request_builder.header(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.push(request_builder.send());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for all responses
|
|
||||||
let results = futures_util::future::join_all(tasks).await;
|
|
||||||
|
|
||||||
// Check if all succeeded
|
|
||||||
let all_success = results.iter().all(|r| {
|
|
||||||
r.as_ref()
|
|
||||||
.map(|res| res.status().is_success())
|
|
||||||
.unwrap_or(false)
|
|
||||||
});
|
|
||||||
|
|
||||||
if all_success {
|
|
||||||
HttpResponse::Ok().body("Operation completed on all servers")
|
|
||||||
} else {
|
|
||||||
HttpResponse::InternalServerError().body("Operation failed on one or more servers")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_all_loads(
|
|
||||||
&self,
|
|
||||||
client: &reqwest::Client,
|
|
||||||
_req: &HttpRequest,
|
|
||||||
) -> HttpResponse {
|
|
||||||
let urls = self.get_worker_urls();
|
|
||||||
let prefill_urls: Vec<String> = Vec::new();
|
|
||||||
let decode_urls = urls;
|
|
||||||
|
|
||||||
// Collect loads from all servers
|
|
||||||
let mut prefill_loads = Vec::new();
|
|
||||||
let mut decode_loads = Vec::new();
|
|
||||||
|
|
||||||
// Get prefill loads
|
|
||||||
for url in &prefill_urls {
|
|
||||||
let load = self.get_worker_load(client, url).await.unwrap_or(-1);
|
|
||||||
prefill_loads.push(serde_json::json!({
|
|
||||||
"engine": format!("(Prefill@{})", url),
|
|
||||||
"load": load as i64
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get decode loads
|
|
||||||
for url in &decode_urls {
|
|
||||||
let load = self.get_worker_load(client, url).await.unwrap_or(-1);
|
|
||||||
decode_loads.push(serde_json::json!({
|
|
||||||
"engine": format!("(Decode@{})", url),
|
|
||||||
"load": load as i64
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpResponse::Ok().json(serde_json::json!({
|
|
||||||
"prefill": prefill_loads,
|
|
||||||
"decode": decode_loads
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
// New method to route typed requests directly
|
// New method to route typed requests directly
|
||||||
pub async fn route_typed_request<
|
pub async fn route_typed_request<
|
||||||
T: crate::openai_api_types::GenerationRequest + serde::Serialize + Clone,
|
T: crate::openai_api_types::GenerationRequest + serde::Serialize + Clone,
|
||||||
|
|||||||
Reference in New Issue
Block a user