[router] change grpc client from mutable to clone (#11394)
This commit is contained in:
@@ -554,7 +554,7 @@ impl Worker for BasicWorker {
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut client = grpc_client.lock().await;
|
let client = grpc_client.lock().await;
|
||||||
match time::timeout(timeout, client.health_check()).await {
|
match time::timeout(timeout, client.health_check()).await {
|
||||||
Ok(Ok(resp)) => {
|
Ok(Ok(resp)) => {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tonic::{transport::Channel, Request};
|
use tonic::{transport::Channel, Request, Streaming};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::protocols::spec::{
|
use crate::protocols::spec::{
|
||||||
@@ -54,18 +54,18 @@ impl SglangSchedulerClient {
|
|||||||
|
|
||||||
/// Submit a generation request (returns streaming response)
|
/// Submit a generation request (returns streaming response)
|
||||||
pub async fn generate(
|
pub async fn generate(
|
||||||
&mut self,
|
&self,
|
||||||
req: proto::GenerateRequest,
|
req: proto::GenerateRequest,
|
||||||
) -> Result<tonic::Streaming<proto::GenerateResponse>, Box<dyn std::error::Error + Send + Sync>>
|
) -> Result<Streaming<proto::GenerateResponse>, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
{
|
let mut client = self.client.clone();
|
||||||
let request = Request::new(req);
|
let request = Request::new(req);
|
||||||
let response = self.client.generate(request).await?;
|
let response = client.generate(request).await?;
|
||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform health check
|
/// Perform health check
|
||||||
pub async fn health_check(
|
pub async fn health_check(
|
||||||
&mut self,
|
&self,
|
||||||
) -> Result<proto::HealthCheckResponse, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<proto::HealthCheckResponse, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
debug!("Sending health check request");
|
debug!("Sending health check request");
|
||||||
let request = Request::new(proto::HealthCheckRequest {
|
let request = Request::new(proto::HealthCheckRequest {
|
||||||
@@ -75,43 +75,47 @@ impl SglangSchedulerClient {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
let response = self.client.health_check(request).await?;
|
let mut client = self.client.clone();
|
||||||
|
let response = client.health_check(request).await?;
|
||||||
debug!("Health check response received");
|
debug!("Health check response received");
|
||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Abort a request
|
/// Abort a request
|
||||||
pub async fn abort_request(
|
pub async fn abort_request(
|
||||||
&mut self,
|
&self,
|
||||||
request_id: String,
|
request_id: String,
|
||||||
reason: String,
|
reason: String,
|
||||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
let request = Request::new(proto::AbortRequest { request_id, reason });
|
let request = Request::new(proto::AbortRequest { request_id, reason });
|
||||||
|
|
||||||
self.client.abort(request).await?;
|
let mut client = self.client.clone();
|
||||||
|
client.abort(request).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get model information
|
/// Get model information
|
||||||
pub async fn get_model_info(
|
pub async fn get_model_info(
|
||||||
&mut self,
|
&self,
|
||||||
) -> Result<proto::GetModelInfoResponse, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<proto::GetModelInfoResponse, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
debug!("Requesting model info");
|
debug!("Requesting model info");
|
||||||
let request = Request::new(proto::GetModelInfoRequest {});
|
let request = Request::new(proto::GetModelInfoRequest {});
|
||||||
|
|
||||||
let response = self.client.get_model_info(request).await?;
|
let mut client = self.client.clone();
|
||||||
|
let response = client.get_model_info(request).await?;
|
||||||
debug!("Model info response received");
|
debug!("Model info response received");
|
||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get server information
|
/// Get server information
|
||||||
pub async fn get_server_info(
|
pub async fn get_server_info(
|
||||||
&mut self,
|
&self,
|
||||||
) -> Result<proto::GetServerInfoResponse, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<proto::GetServerInfoResponse, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
debug!("Requesting server info");
|
debug!("Requesting server info");
|
||||||
let request = Request::new(proto::GetServerInfoRequest {});
|
let request = Request::new(proto::GetServerInfoRequest {});
|
||||||
|
|
||||||
let response = self.client.get_server_info(request).await?;
|
let mut client = self.client.clone();
|
||||||
|
let response = client.get_server_info(request).await?;
|
||||||
debug!("Server info response received");
|
debug!("Server info response received");
|
||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user