pub struct QuorumSystem<T: Element> { /* private fields */ }Expand description
A read-write quorum system.
Implementations§
Source§impl<T: Element> QuorumSystem<T>
impl<T: Element> QuorumSystem<T>
Sourcepub fn from_reads(reads: Expr<T>) -> Self
pub fn from_reads(reads: Expr<T>) -> Self
Build a quorum system from reads only; writes are the dual.
Sourcepub fn from_writes(writes: Expr<T>) -> Self
pub fn from_writes(writes: Expr<T>) -> Self
Build a quorum system from writes only; reads are the dual.
Sourcepub fn new(reads: Expr<T>, writes: Expr<T>) -> Result<Self>
pub fn new(reads: Expr<T>, writes: Expr<T>) -> Result<Self>
Build a quorum system from both read and write expressions.
§Errors
Returns Error::NonOverlappingQuorums unless every read quorum
intersects every write quorum.
Sourcepub fn read_quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>
pub fn read_quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>
Iterate over all read quorums.
Sourcepub fn write_quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>
pub fn write_quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>
Iterate over all write quorums.
Sourcepub fn is_read_quorum(&self, xs: &HashSet<T>) -> bool
pub fn is_read_quorum(&self, xs: &HashSet<T>) -> bool
Whether xs contains a read quorum.
Sourcepub fn is_write_quorum(&self, xs: &HashSet<T>) -> bool
pub fn is_write_quorum(&self, xs: &HashSet<T>) -> bool
Whether xs contains a write quorum.
Sourcepub fn node(&self, x: &T) -> Result<&Node<T>>
pub fn node(&self, x: &T) -> Result<&Node<T>>
Look up a node by its identifier.
§Errors
Returns Error::InvalidQuorumSystem if x is not in the system.
Sourcepub fn resilience(&self) -> usize
pub fn resilience(&self) -> usize
The resilience of the system: the minimum of read and write resilience.
Sourcepub fn read_resilience(&self) -> usize
pub fn read_resilience(&self) -> usize
The resilience of the read expression.
Sourcepub fn write_resilience(&self) -> usize
pub fn write_resilience(&self) -> usize
The resilience of the write expression.
Sourcepub fn uniform_strategy(&self, f: usize) -> Result<Strategy<T>>
pub fn uniform_strategy(&self, f: usize) -> Result<Strategy<T>>
A strategy that picks uniformly among the minimal f-resilient
quorums.
§Errors
Returns Error::NoStrategyFound if there are no f-resilient read
or write quorums.
Sourcepub fn make_strategy(
&self,
sigma_r: BTreeMap<Quorum<T>, f64>,
sigma_w: BTreeMap<Quorum<T>, f64>,
) -> Result<Strategy<T>>
pub fn make_strategy( &self, sigma_r: BTreeMap<Quorum<T>, f64>, sigma_w: BTreeMap<Quorum<T>, f64>, ) -> Result<Strategy<T>>
Build a strategy from explicit quorum weights.
Each key is a list of node identifiers (order and duplicates do not matter); weights for the same set are added together, and weights are normalized to sum to 1. Zero-weight quorums are dropped.
§Errors
Returns Error::InvalidQuorumSystem if a key is not a read (or
write) quorum, a weight is negative or not finite, or all weights are
zero.
Sourcepub fn strategy(
&self,
objective: Objective,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
limits: &StrategyLimits,
f: usize,
) -> Result<Strategy<T>>
pub fn strategy( &self, objective: Objective, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, limits: &StrategyLimits, f: usize, ) -> Result<Strategy<T>>
Compute the optimal strategy by linear programming.
Minimizes objective subject to limits, considering only
f-resilient quorums (quorums that still contain a quorum after any
f of their nodes fail). Exactly one of read_fraction and
write_fraction must be Some.
§Errors
Error::InvalidQuorumSystemif the limit matchingobjectiveis set.Error::InvalidDistributionfor a bad read/write fraction.Error::NoStrategyFoundif the limits cannot be met or there are nof-resilient quorums.Error::LpErrorif the solver fails for another reason.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for QuorumSystem<T>
impl<T> RefUnwindSafe for QuorumSystem<T>
impl<T> Send for QuorumSystem<T>
impl<T> Sync for QuorumSystem<T>
impl<T> Unpin for QuorumSystem<T>
impl<T> UnsafeUnpin for QuorumSystem<T>
impl<T> UnwindSafe for QuorumSystem<T>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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