Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhmelody committed Feb 20, 2025
1 parent c1ffca5 commit b4f3535
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pingora-ketama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ where
const POINT_MULTIPLE: u32 = 160;

if buckets.is_empty() {
return Continuum { ring: Box::new([]), addrs: Box::new([]) };
return Continuum {
ring: Box::new([]),
addrs: Box::new([]),
};
}

// The total weight is multiplied by the factor of points to create many points per node.
Expand Down Expand Up @@ -198,7 +201,10 @@ where
ring.sort_unstable();
ring.dedup_by(|a, b| a.hash == b.hash);

Continuum { ring: ring.into_boxed_slice(), addrs: addrs.into_boxed_slice() }
Continuum {
ring: ring.into_boxed_slice(),
addrs: addrs.into_boxed_slice(),
}
}

/// Find the associated index for the given input.
Expand All @@ -216,7 +222,7 @@ where
} else {
i
}
},
}
}
}

Expand All @@ -232,7 +238,10 @@ where
/// This function is useful to find failover servers if the original ones are offline, which is
/// cheaper than rebuilding the entire hash ring.
pub fn node_iter(&self, hash_key: &[u8]) -> NodeIterator<Node> {
NodeIterator { idx: self.node_idx(hash_key), continuum: self }
NodeIterator {
idx: self.node_idx(hash_key),
continuum: self,
}
}

pub fn get_addr(&self, idx: &mut usize) -> Option<&Node> {
Expand Down

0 comments on commit b4f3535

Please # to comment.