pub trait QuorumSet {
type Id;
type Iter: Iterator<Item = Self::Id>;
// Required methods
fn is_quorum<'a, I>(&self, ids: I) -> bool
where Self::Id: 'a,
I: Iterator<Item = &'a Self::Id> + Clone;
fn ids(&self) -> Self::Iter;
}Expand description
Common interface for every quorum rule supported by this crate.
A quorum is a collection of nodes that a read or write operation in a distributed system has to contact. See: http://web.mit.edu/6.033/2005/wwwdocs/quorum_note.html
Every implementation must follow three rules:
- Upward-closed: adding IDs to an accepted quorum keeps it accepted.
VecProgressandverify_intersectionrely on this rule. - Closed over
ids(): an ID thatids()does not yield never changes the result ofis_quorum().verify_intersectionenumerates only the IDs thatids()yields, so it relies on this rule. - Duplicate-safe: an ID that appears more than once in the
is_quorum()input counts once, so callers may pass an iterator with repeats.
The crate provides implementations for flat majority sets, joint quorum sets, hierarchical
QuorumTree rules, and BothQuorums, which requires both a read and a write quorum.
ReadOrBoth holds either a read rule alone or a BothQuorums.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<ID> QuorumSet for BTreeSet<ID>
Majority quorum implementation for a flat voter set.
impl<ID> QuorumSet for BTreeSet<ID>
Majority quorum implementation for a flat voter set.
A candidate set is accepted when it contains more than half of the IDs in
this BTreeSet. An empty BTreeSet accepts no candidate set, unlike
an empty joint config (Vec<BTreeSet>), which accepts every candidate
set.
Source§impl<ID> QuorumSet for Vec<BTreeSet<ID>>
Joint quorum implementation for multiple flat voter sets.
impl<ID> QuorumSet for Vec<BTreeSet<ID>>
Joint quorum implementation for multiple flat voter sets.
A candidate set is accepted only when it is a majority quorum in every
member config. QuorumSet::ids returns the deduplicated union of all
config IDs. An empty Vec accepts every candidate set: with no member
config, the requirement is vacuously satisfied.
Implementors§
Source§impl<ID> QuorumSet for QuorumTree<ID>
Hierarchical quorum implementation for QuorumTree.
impl<ID> QuorumSet for QuorumTree<ID>
Hierarchical quorum implementation for QuorumTree.
Evaluation follows the tree structure. ids() returns all leaf IDs once,
even when the same node appears in more than one subtree.