diff --git a/sgl-router/src/core/error.rs b/sgl-router/src/core/error.rs
index 04fa40c90..fbe033590 100644
--- a/sgl-router/src/core/error.rs
+++ b/sgl-router/src/core/error.rs
@@ -19,6 +19,8 @@ pub enum WorkerError {
WorkerAtCapacity { url: String },
/// Invalid URL format
InvalidUrl { url: String },
+ /// Connection failed
+ ConnectionFailed { url: String, reason: String },
}
impl fmt::Display for WorkerError {
@@ -42,6 +44,9 @@ impl fmt::Display for WorkerError {
WorkerError::InvalidUrl { url } => {
write!(f, "Invalid URL format: {}", url)
}
+ WorkerError::ConnectionFailed { url, reason } => {
+ write!(f, "Connection failed for worker {}: {}", url, reason)
+ }
}
}
}
diff --git a/sgl-router/src/core/worker.rs b/sgl-router/src/core/worker.rs
index 722510fc2..bf61e83a5 100644
--- a/sgl-router/src/core/worker.rs
+++ b/sgl-router/src/core/worker.rs
@@ -220,6 +220,16 @@ pub trait Worker: Send + Sync + fmt::Debug {
.get("chat_template")
.map(|s| s.as_str())
}
+
+ /// Get or create a gRPC client for this worker
+ /// Returns None for HTTP workers, Some(client) for gRPC workers
+ async fn get_grpc_client(&self) -> WorkerResult