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>

source

pub fn choose_filtered<R>( self, rng: &mut R, predicate: impl Fn(&NodeRef<'a>) -> bool ) -> Option<NodeRef<'a>>
where R: Rng + ?Sized,

Chooses a random replica that satisfies the given predicate.

source

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

pub fn is_empty(&self) -> bool

Returns true if the replica set contains no elements.

Complexity same as of ReplicaSet::len.

source§

impl<'a> ReplicaSet<'a>

Trait Implementations§

source§

impl<'a> Debug for ReplicaSet<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T> From<T> for ReplicaSet<'a>
where T: Into<ReplicasArray<'a>>,

source§

fn from(item: T) -> Self

Converts to this type from the input type.
source§

impl<'a> IntoIterator for ReplicaSet<'a>

source§

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 Item = &'a Arc<Node>

The type of the elements being iterated over.
§

type IntoIter = ReplicaSetIterator<'a>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more