Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sgl-router/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod error;
pub mod retry;
pub mod token_bucket;
pub mod worker;
pub mod worker_builder;
pub mod worker_registry;

// Re-export commonly used types at the module level
Expand All @@ -23,4 +24,5 @@ pub use worker::{
start_health_checker, BasicWorker, ConnectionMode, DPAwareWorker, HealthChecker, HealthConfig,
Worker, WorkerCollection, WorkerFactory, WorkerLoadGuard, WorkerType,
};
pub use worker_builder::{BasicWorkerBuilder, DPAwareWorkerBuilder};
pub use worker_registry::{WorkerId, WorkerRegistry, WorkerRegistryStats};
18 changes: 17 additions & 1 deletion sgl-router/src/core/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,22 @@ impl DPAwareWorker {
base_url,
}
}

/// Create a new DP-aware worker with a pre-configured base worker
/// This is primarily used by the builder pattern
pub fn with_base_worker(
base_worker: BasicWorker,
base_url: String,
dp_rank: usize,
dp_size: usize,
) -> Self {
Self {
base_worker,
dp_rank,
dp_size,
base_url,
}
}
}

#[async_trait]
Expand Down Expand Up @@ -1102,7 +1118,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 {
Expand Down
Loading
Loading