pub struct Sharder {
pub nr_shards: ShardCount,
pub msb_ignore: u8,
}
Fields§
§nr_shards: ShardCount
§msb_ignore: u8
Implementations§
Source§impl Sharder
impl Sharder
pub fn new(nr_shards: ShardCount, msb_ignore: u8) -> Self
pub fn shard_of(&self, token: Token) -> Shard
Sourcepub fn shard_of_source_port(&self, source_port: u16) -> Shard
pub fn shard_of_source_port(&self, source_port: u16) -> Shard
If we connect to Scylla using Scylla’s shard aware port, then Scylla assigns a shard to the connection based on the source port. This calculates the assigned shard.
Sourcepub fn draw_source_port_for_shard(&self, shard: Shard) -> u16
pub fn draw_source_port_for_shard(&self, shard: Shard) -> u16
Randomly choose a source port p
such that shard == shard_of_source_port(p)
.
Sourcepub fn iter_source_ports_for_shard(
&self,
shard: Shard,
) -> impl Iterator<Item = u16>
pub fn iter_source_ports_for_shard( &self, shard: Shard, ) -> impl Iterator<Item = u16>
Returns iterator over source ports p
such that shard == shard_of_source_port(p)
.
Starts at a random port and goes forward by nr_shards
. After reaching maximum wraps back around.
Stops once all possible ports have been returned
Trait Implementations§
impl Eq for Sharder
impl StructuralPartialEq for Sharder
Auto Trait Implementations§
impl Freeze for Sharder
impl RefUnwindSafe for Sharder
impl Send for Sharder
impl Sync for Sharder
impl Unpin for Sharder
impl UnwindSafe for Sharder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more