refactor(replication): move resync classifiers into crate (#4170)

This commit is contained in:
Zhengchao An
2026-07-02 12:57:59 +08:00
committed by GitHub
parent 953a080b37
commit d666028cdc
7 changed files with 194 additions and 49 deletions
+15
View File
@@ -82,6 +82,14 @@ pub fn resized_worker_counts(
}
}
pub fn mrf_worker_size_to_count(size: i32) -> usize {
let non_negative = size.max(0);
match usize::try_from(non_negative) {
Ok(size) => size,
Err(_) => 0,
}
}
pub fn worker_counts_for_priority(
priority: &ReplicationPriority,
current_workers: usize,
@@ -189,6 +197,13 @@ mod tests {
);
}
#[test]
fn mrf_worker_size_to_count_clamps_negative_values() {
assert_eq!(mrf_worker_size_to_count(-1), 0);
assert_eq!(mrf_worker_size_to_count(0), 0);
assert_eq!(mrf_worker_size_to_count(3), 3);
}
#[test]
fn auto_priority_grows_toward_defaults() {
assert_eq!(