Struct scylla::transport::locator::ReplicaSet
source · pub struct ReplicaSet<'a> { /* private fields */ }
Expand description
Represents a set of replicas for a given token and strategy;
This container can only be created by calling ReplicaLocator::replicas_for_token
, and it
can borrow precomputed replica lists living in the locator.
Implementations§
source§impl<'a> ReplicaSet<'a>
impl<'a> ReplicaSet<'a>
sourcepub fn choose_filtered<R>(
self,
rng: &mut R,
predicate: impl Fn(&(NodeRef<'a>, Shard)) -> bool,
) -> Option<(NodeRef<'a>, Shard)>
pub fn choose_filtered<R>( self, rng: &mut R, predicate: impl Fn(&(NodeRef<'a>, Shard)) -> bool, ) -> Option<(NodeRef<'a>, Shard)>
Chooses a random replica that satisfies the given predicate.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Gets the size of the set.
If the set represents SimpleStrategy
replicas that were filtered by datacenter, this
function will have O(R) complexity, where R is the replication factor of that strategy.
If the set represents NetworkTopologyStrategy
replicas that were not filtered by
datacenter, this function will have O(D) complexity where D is the number of known
datacenters.
In all other cases, the complexity is O(1)
source§impl<'a> ReplicaSet<'a>
impl<'a> ReplicaSet<'a>
pub fn into_replicas_ordered(self) -> ReplicasOrdered<'a>
Trait Implementations§
source§impl<'a> Debug for ReplicaSet<'a>
impl<'a> Debug for ReplicaSet<'a>
source§impl<'a> IntoIterator for ReplicaSet<'a>
impl<'a> IntoIterator for ReplicaSet<'a>
source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Converts the replica set into iterator. Order defined by that iterator does not have to match the order set by the token ring.
Iterating through ReplicaSet
using this method is far more efficient than invoking the
get
method sequentially.
§type IntoIter = ReplicaSetIterator<'a>
type IntoIter = ReplicaSetIterator<'a>
Auto Trait Implementations§
impl<'a> Freeze for ReplicaSet<'a>
impl<'a> !RefUnwindSafe for ReplicaSet<'a>
impl<'a> Send for ReplicaSet<'a>
impl<'a> Sync for ReplicaSet<'a>
impl<'a> Unpin for ReplicaSet<'a>
impl<'a> !UnwindSafe for ReplicaSet<'a>
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
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>
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>
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