pub struct QuorumGroup { /* private fields */ }Expand description
A quorum of members holding versioned registers for strong-tier keys.
Implementations§
Source§impl QuorumGroup
impl QuorumGroup
pub fn size(&self) -> usize
pub fn online_count(&self) -> usize
Sourcepub fn partition(&mut self, member_id: &str) -> bool
pub fn partition(&mut self, member_id: &str) -> bool
Take a member offline (simulate it being on the far side of a partition).
Sourcepub fn read(
&self,
key: &str,
) -> Result<(Option<Vec<u8>>, u64), UnavailableReason>
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.
Sourcepub fn cas(
&mut self,
key: &str,
expected_version: u64,
new_value: Vec<u8>,
) -> StrongResult
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.
Sourcepub fn claim_unique(&mut self, key: &str, owner: &[u8]) -> StrongResult
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.
Sourcepub fn init_seats(&mut self, key: &str, count: u64) -> StrongResult
pub fn init_seats(&mut self, key: &str, count: u64) -> StrongResult
Initialize a non-negative resource key with count units.
Sourcepub fn acquire_seat(&mut self, key: &str) -> StrongResult
pub fn acquire_seat(&mut self, key: &str) -> StrongResult
Acquire one unit of a non-negative resource. RejectReason::Exhausted at
zero — never oversells.
Sourcepub fn seats_remaining(&self, key: &str) -> Result<u64, UnavailableReason>
pub fn seats_remaining(&self, key: &str) -> Result<u64, UnavailableReason>
The units remaining for a resource key.