Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
bbf261ae
Unverified
Commit
bbf261ae
authored
Sep 04, 2025
by
Simo Lin
Committed by
GitHub
Sep 03, 2025
Browse files
[router] fix grpc connection mode detection (#9999)
parent
4f8a982d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
29 deletions
+5
-29
sgl-router/src/core/worker.rs
sgl-router/src/core/worker.rs
+1
-1
sgl-router/src/lib.rs
sgl-router/src/lib.rs
+2
-14
sgl-router/src/main.rs
sgl-router/src/main.rs
+2
-14
No files found.
sgl-router/src/core/worker.rs
View file @
bbf261ae
...
...
@@ -986,7 +986,7 @@ pub fn start_health_checker(
// Periodically reset load counters to prevent drift
// Only do this when we believe all workers should be idle
if
check_count
%
LOAD_RESET_INTERVAL
==
0
{
if
check_count
.is_multiple_of
(
LOAD_RESET_INTERVAL
)
{
let
max_load
=
workers_to_check
.iter
()
.map
(|
w
|
w
.load
())
.max
()
.unwrap_or
(
0
);
// Only reset if load appears to be very low (likely drift)
if
max_load
<=
2
{
...
...
sgl-router/src/lib.rs
View file @
bbf261ae
...
...
@@ -101,25 +101,13 @@ struct Router {
impl
Router
{
/// Determine connection mode from worker URLs
fn
determine_connection_mode
(
worker_urls
:
&
[
String
])
->
config
::
ConnectionMode
{
//
Check if any URL is a gRPC endpoint (starts with grpc:// or has port that commonly indicates gRPC)
//
Only consider it gRPC if explicitly specified with grpc:// or grpcs:// scheme
for
url
in
worker_urls
{
if
url
.starts_with
(
"grpc://"
)
||
url
.starts_with
(
"grpcs://"
)
{
return
config
::
ConnectionMode
::
Grpc
;
}
// Also check for common gRPC ports if the scheme isn't specified
if
let
Ok
(
parsed_url
)
=
url
::
Url
::
parse
(
url
)
{
if
let
Some
(
port
)
=
parsed_url
.port
()
{
// Common gRPC ports
if
port
==
50051
||
port
==
9090
||
((
50000
..=
50100
)
.contains
(
&
port
))
{
return
config
::
ConnectionMode
::
Grpc
;
}
}
}
else
if
url
.contains
(
":50051"
)
||
url
.contains
(
":9090"
)
||
url
.contains
(
":5000"
)
{
// Fallback check for URLs that might not parse correctly
return
config
::
ConnectionMode
::
Grpc
;
}
}
// Default to HTTP
// Default to HTTP
for all other cases (including http://, https://, or no scheme)
config
::
ConnectionMode
::
Http
}
...
...
sgl-router/src/main.rs
View file @
bbf261ae
...
...
@@ -286,25 +286,13 @@ struct CliArgs {
impl
CliArgs
{
/// Determine connection mode from worker URLs
fn
determine_connection_mode
(
worker_urls
:
&
[
String
])
->
ConnectionMode
{
//
Check if any URL is a gRPC endpoint (starts with grpc:// or has port that commonly indicates gRPC)
//
Only consider it gRPC if explicitly specified with grpc:// or grpcs:// scheme
for
url
in
worker_urls
{
if
url
.starts_with
(
"grpc://"
)
||
url
.starts_with
(
"grpcs://"
)
{
return
ConnectionMode
::
Grpc
;
}
// Also check for common gRPC ports if the scheme isn't specified
if
let
Ok
(
parsed_url
)
=
url
::
Url
::
parse
(
url
)
{
if
let
Some
(
port
)
=
parsed_url
.port
()
{
// Common gRPC ports
if
port
==
50051
||
port
==
9090
||
((
50000
..=
50100
)
.contains
(
&
port
))
{
return
ConnectionMode
::
Grpc
;
}
}
}
else
if
url
.contains
(
":50051"
)
||
url
.contains
(
":9090"
)
||
url
.contains
(
":5000"
)
{
// Fallback check for URLs that might not parse correctly
return
ConnectionMode
::
Grpc
;
}
}
// Default to HTTP
// Default to HTTP
for all other cases (including http://, https://, or no scheme)
ConnectionMode
::
Http
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment