review: use ShardCount::count

This commit is contained in:
Vlad Lazar
2024-06-19 18:31:45 +01:00
parent 3a74253bcb
commit 9bcb8796a8
2 changed files with 5 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ use utils::id::TenantId;
pub struct ShardNumber(pub u8);
#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Copy, Serialize, Deserialize, Debug, Hash)]
pub struct ShardCount(pub u8);
pub struct ShardCount(u8);
/// Combination of ShardNumber and ShardCount. For use within the context of a particular tenant,
/// when we need to know which shard we're dealing with, but do not need to know the full

View File

@@ -5443,8 +5443,10 @@ impl Service {
match tids_by_node.get_mut(&node_id) {
Some(tids) => match tids.pop() {
Some(tid) => {
let max_promote_for_tenant =
std::cmp::max(tid.shard_count.0 as usize / locked.nodes.len(), 1);
let max_promote_for_tenant = std::cmp::max(
tid.shard_count.count() as usize / locked.nodes.len(),
1,
);
let promoted = promoted_per_tenant.entry(tid.tenant_id).or_default();
if *promoted < max_promote_for_tenant {
plan.push(tid);