Skip to main content

QuorumGroup

Struct QuorumGroup 

Source
pub struct QuorumGroup { /* private fields */ }
Expand description

A quorum of members holding versioned registers for strong-tier keys.

Implementations§

Source§

impl QuorumGroup

Source

pub fn new<I, S>(member_ids: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

A group of the given members, all initially reachable.

Source

pub fn size(&self) -> usize

Source

pub fn majority(&self) -> usize

The number of members that must agree (a strict majority).

Source

pub fn online_count(&self) -> usize

Source

pub fn partition(&mut self, member_id: &str) -> bool

Take a member offline (simulate it being on the far side of a partition).

Source

pub fn heal(&mut self, member_id: &str) -> bool

Bring a member back online.

Source

pub fn read( &self, key: &str, ) -> Result<(Option<Vec<u8>>, u64), UnavailableReason>

Read the latest committed (value, version) for key from a quorum. The highest version across any reachable majority is the latest committed value (any two majorities overlap). Errors if a majority isn’t reachable.

Source

pub fn cas( &mut self, key: &str, expected_version: u64, new_value: Vec<u8>, ) -> StrongResult

Compare-and-set: commit new_value at expected_version + 1 to a majority, but only if the current committed version is still expected_version. Unavailable if no majority is reachable (nothing is written); Rejected if a concurrent writer already advanced the version.

Source

pub fn claim_unique(&mut self, key: &str, owner: &[u8]) -> StrongResult

Claim a uniqueness key for owner. Succeeds only if unclaimed; a second claimant is RejectReason::AlreadyClaimed.

Source

pub fn init_seats(&mut self, key: &str, count: u64) -> StrongResult

Initialize a non-negative resource key with count units.

Source

pub fn acquire_seat(&mut self, key: &str) -> StrongResult

Acquire one unit of a non-negative resource. RejectReason::Exhausted at zero — never oversells.

Source

pub fn seats_remaining(&self, key: &str) -> Result<u64, UnavailableReason>

The units remaining for a resource key.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V