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
5dccf697
Unverified
Commit
5dccf697
authored
Oct 22, 2025
by
Simo Lin
Committed by
GitHub
Oct 22, 2025
Browse files
[router] create worker removal step and clean up worker manager (#11921)
parent
eec9e471
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
18 deletions
+27
-18
sgl-router/tests/common/mod.rs
sgl-router/tests/common/mod.rs
+27
-2
sgl-router/tests/request_formats_test.rs
sgl-router/tests/request_formats_test.rs
+0
-8
sgl-router/tests/streaming_tests.rs
sgl-router/tests/streaming_tests.rs
+0
-8
No files found.
sgl-router/tests/common/mod.rs
View file @
5dccf697
...
@@ -66,7 +66,7 @@ pub fn create_test_context(config: RouterConfig) -> Arc<AppContext> {
...
@@ -66,7 +66,7 @@ pub fn create_test_context(config: RouterConfig) -> Arc<AppContext> {
let
worker_job_queue
=
Arc
::
new
(
OnceLock
::
new
());
let
worker_job_queue
=
Arc
::
new
(
OnceLock
::
new
());
let
workflow_engine
=
Arc
::
new
(
OnceLock
::
new
());
let
workflow_engine
=
Arc
::
new
(
OnceLock
::
new
());
Arc
::
new
(
AppContext
::
new
(
let
app_context
=
Arc
::
new
(
AppContext
::
new
(
config
,
config
,
client
,
client
,
rate_limiter
,
rate_limiter
,
...
@@ -81,7 +81,32 @@ pub fn create_test_context(config: RouterConfig) -> Arc<AppContext> {
...
@@ -81,7 +81,32 @@ pub fn create_test_context(config: RouterConfig) -> Arc<AppContext> {
load_monitor
,
load_monitor
,
worker_job_queue
,
worker_job_queue
,
workflow_engine
,
workflow_engine
,
))
));
// Initialize JobQueue after AppContext is created
let
weak_context
=
Arc
::
downgrade
(
&
app_context
);
let
job_queue
=
sglang_router_rs
::
core
::
JobQueue
::
new
(
sglang_router_rs
::
core
::
JobQueueConfig
::
default
(),
weak_context
,
);
app_context
.worker_job_queue
.set
(
job_queue
)
.expect
(
"JobQueue should only be initialized once"
);
// Initialize WorkflowEngine and register workflows
use
sglang_router_rs
::
core
::
workflow
::{
create_worker_registration_workflow
,
create_worker_removal_workflow
,
WorkflowEngine
,
};
let
engine
=
Arc
::
new
(
WorkflowEngine
::
new
());
engine
.register_workflow
(
create_worker_registration_workflow
());
engine
.register_workflow
(
create_worker_removal_workflow
());
app_context
.workflow_engine
.set
(
engine
)
.expect
(
"WorkflowEngine should only be initialized once"
);
app_context
}
}
// Tokenizer download configuration
// Tokenizer download configuration
...
...
sgl-router/tests/request_formats_test.rs
View file @
5dccf697
...
@@ -7,7 +7,6 @@ use reqwest::Client;
...
@@ -7,7 +7,6 @@ use reqwest::Client;
use
serde_json
::
json
;
use
serde_json
::
json
;
use
sglang_router_rs
::{
use
sglang_router_rs
::{
config
::{
RouterConfig
,
RoutingMode
},
config
::{
RouterConfig
,
RoutingMode
},
core
::
WorkerManager
,
routers
::{
RouterFactory
,
RouterTrait
},
routers
::{
RouterFactory
,
RouterTrait
},
};
};
...
@@ -51,13 +50,6 @@ impl TestContext {
...
@@ -51,13 +50,6 @@ impl TestContext {
let
app_context
=
common
::
create_test_context
(
config
.clone
());
let
app_context
=
common
::
create_test_context
(
config
.clone
());
// Initialize workers in the registry before creating router
if
!
worker_urls
.is_empty
()
{
WorkerManager
::
initialize_workers
(
&
config
,
&
app_context
.worker_registry
,
None
)
.await
.expect
(
"Failed to initialize workers"
);
}
let
router
=
RouterFactory
::
create_router
(
&
app_context
)
.await
.unwrap
();
let
router
=
RouterFactory
::
create_router
(
&
app_context
)
.await
.unwrap
();
let
router
=
Arc
::
from
(
router
);
let
router
=
Arc
::
from
(
router
);
...
...
sgl-router/tests/streaming_tests.rs
View file @
5dccf697
...
@@ -8,7 +8,6 @@ use reqwest::Client;
...
@@ -8,7 +8,6 @@ use reqwest::Client;
use
serde_json
::
json
;
use
serde_json
::
json
;
use
sglang_router_rs
::{
use
sglang_router_rs
::{
config
::{
RouterConfig
,
RoutingMode
},
config
::{
RouterConfig
,
RoutingMode
},
core
::
WorkerManager
,
routers
::{
RouterFactory
,
RouterTrait
},
routers
::{
RouterFactory
,
RouterTrait
},
};
};
...
@@ -52,13 +51,6 @@ impl TestContext {
...
@@ -52,13 +51,6 @@ impl TestContext {
let
app_context
=
common
::
create_test_context
(
config
.clone
());
let
app_context
=
common
::
create_test_context
(
config
.clone
());
// Initialize workers in the registry before creating router
if
!
worker_urls
.is_empty
()
{
WorkerManager
::
initialize_workers
(
&
config
,
&
app_context
.worker_registry
,
None
)
.await
.expect
(
"Failed to initialize workers"
);
}
let
router
=
RouterFactory
::
create_router
(
&
app_context
)
.await
.unwrap
();
let
router
=
RouterFactory
::
create_router
(
&
app_context
)
.await
.unwrap
();
let
router
=
Arc
::
from
(
router
);
let
router
=
Arc
::
from
(
router
);
...
...
Prev
1
2
Next
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