Narrow core ranking public surface

This commit is contained in:
fawney19
2026-04-27 16:05:00 +08:00
parent 9da47ceb22
commit 51c3beb614
5 changed files with 18 additions and 25 deletions

View File

@@ -39,12 +39,9 @@ pub use model::{
}; };
pub use provider::{build_provider_concurrent_limit_map, should_skip_provider_quota}; pub use provider::{build_provider_concurrent_limit_map, should_skip_provider_quota};
pub use ranking::{ pub use ranking::{
apply_scheduler_candidate_ranking, candidate_priority_slot, candidates_share_priority_group, apply_scheduler_candidate_ranking, SchedulerRankableCandidate, SchedulerRankingContext,
compare_candidate_identity_for_ranking, compare_candidate_priority_slot, SchedulerRankingMode, SchedulerRankingOutcome, SchedulerTunnelAffinityBucket,
scheduler_candidate_ranking_order, scheduler_ranking_outcomes, SchedulerRankableCandidate, RANKING_REASON_CACHED_AFFINITY, RANKING_REASON_CROSS_FORMAT, RANKING_REASON_LOCAL_TUNNEL,
SchedulerRankingContext, SchedulerRankingMode, SchedulerRankingOutcome,
SchedulerTunnelAffinityBucket, RANKING_REASON_CACHED_AFFINITY, RANKING_REASON_CROSS_FORMAT,
RANKING_REASON_LOCAL_TUNNEL,
}; };
pub use request_candidate::{ pub use request_candidate::{
build_execution_request_candidate_seed, build_local_request_candidate_status_record, build_execution_request_candidate_seed, build_local_request_candidate_status_record,

View File

@@ -2,7 +2,7 @@ use std::cmp::Ordering;
use super::types::SchedulerRankableCandidate; use super::types::SchedulerRankableCandidate;
pub fn compare_format_state( pub(super) fn compare_format_state(
left: &SchedulerRankableCandidate, left: &SchedulerRankableCandidate,
right: &SchedulerRankableCandidate, right: &SchedulerRankableCandidate,
) -> Ordering { ) -> Ordering {

View File

@@ -4,13 +4,10 @@ mod priority;
mod reasons; mod reasons;
mod types; mod types;
pub use format::compare_format_state; use modes::{apply_load_balance_rotation, compare_rankable_candidates};
pub use modes::{apply_load_balance_rotation, compare_rankable_candidates}; use priority::candidate_priority_slot;
pub use priority::{ use reasons::{demoted_by as ranking_demoted_by, promoted_by as ranking_promoted_by};
candidate_priority_slot, candidates_share_priority_group, compare_candidate_priority_slot,
};
pub use reasons::{ pub use reasons::{
demoted_by as ranking_demoted_by, promoted_by as ranking_promoted_by,
RANKING_REASON_CACHED_AFFINITY, RANKING_REASON_CROSS_FORMAT, RANKING_REASON_LOCAL_TUNNEL, RANKING_REASON_CACHED_AFFINITY, RANKING_REASON_CROSS_FORMAT, RANKING_REASON_LOCAL_TUNNEL,
}; };
pub use types::{ pub use types::{
@@ -18,7 +15,7 @@ pub use types::{
SchedulerRankingOutcome, SchedulerTunnelAffinityBucket, SchedulerRankingOutcome, SchedulerTunnelAffinityBucket,
}; };
pub fn compare_candidate_identity_for_ranking( fn compare_candidate_identity_for_ranking(
left: &SchedulerRankableCandidate, left: &SchedulerRankableCandidate,
right: &SchedulerRankableCandidate, right: &SchedulerRankableCandidate,
) -> std::cmp::Ordering { ) -> std::cmp::Ordering {
@@ -32,7 +29,7 @@ pub fn compare_candidate_identity_for_ranking(
) )
} }
pub fn scheduler_candidate_ranking_order( fn scheduler_candidate_ranking_order(
candidates: &[SchedulerRankableCandidate], candidates: &[SchedulerRankableCandidate],
context: SchedulerRankingContext, context: SchedulerRankingContext,
) -> Vec<usize> { ) -> Vec<usize> {
@@ -44,7 +41,7 @@ pub fn scheduler_candidate_ranking_order(
order order
} }
pub fn scheduler_ranking_outcomes( fn scheduler_ranking_outcomes(
candidates: &[SchedulerRankableCandidate], candidates: &[SchedulerRankableCandidate],
context: SchedulerRankingContext, context: SchedulerRankingContext,
) -> Vec<SchedulerRankingOutcome> { ) -> Vec<SchedulerRankingOutcome> {

View File

@@ -1,12 +1,11 @@
use std::cmp::Ordering; use std::cmp::Ordering;
use super::compare_candidate_identity_for_ranking;
use super::format::compare_format_state;
use super::priority::{candidates_share_priority_group, compare_candidate_priority_slot};
use super::types::{SchedulerRankableCandidate, SchedulerRankingContext, SchedulerRankingMode}; use super::types::{SchedulerRankableCandidate, SchedulerRankingContext, SchedulerRankingMode};
use super::{
candidates_share_priority_group, compare_candidate_identity_for_ranking,
compare_candidate_priority_slot, compare_format_state,
};
pub fn compare_rankable_candidates( pub(super) fn compare_rankable_candidates(
left: &SchedulerRankableCandidate, left: &SchedulerRankableCandidate,
right: &SchedulerRankableCandidate, right: &SchedulerRankableCandidate,
context: SchedulerRankingContext, context: SchedulerRankingContext,
@@ -79,7 +78,7 @@ fn compare_health(
.then_with(|| right.health_score.total_cmp(&left.health_score)) .then_with(|| right.health_score.total_cmp(&left.health_score))
} }
pub fn apply_load_balance_rotation( pub(super) fn apply_load_balance_rotation(
sorted_indices: &mut [usize], sorted_indices: &mut [usize],
candidates: &[SchedulerRankableCandidate], candidates: &[SchedulerRankableCandidate],
context: SchedulerRankingContext, context: SchedulerRankingContext,

View File

@@ -4,7 +4,7 @@ use crate::SchedulerPriorityMode;
use super::types::SchedulerRankableCandidate; use super::types::SchedulerRankableCandidate;
pub fn candidate_priority_slot( pub(super) fn candidate_priority_slot(
candidate: &SchedulerRankableCandidate, candidate: &SchedulerRankableCandidate,
priority_mode: SchedulerPriorityMode, priority_mode: SchedulerPriorityMode,
) -> i32 { ) -> i32 {
@@ -16,7 +16,7 @@ pub fn candidate_priority_slot(
} }
} }
pub fn compare_candidate_priority_slot( pub(super) fn compare_candidate_priority_slot(
left: &SchedulerRankableCandidate, left: &SchedulerRankableCandidate,
right: &SchedulerRankableCandidate, right: &SchedulerRankableCandidate,
priority_mode: SchedulerPriorityMode, priority_mode: SchedulerPriorityMode,
@@ -35,7 +35,7 @@ pub fn compare_candidate_priority_slot(
} }
} }
pub fn candidates_share_priority_group( pub(super) fn candidates_share_priority_group(
left: &SchedulerRankableCandidate, left: &SchedulerRankableCandidate,
right: &SchedulerRankableCandidate, right: &SchedulerRankableCandidate,
priority_mode: SchedulerPriorityMode, priority_mode: SchedulerPriorityMode,