Skip to main content

QuorumSet

Trait QuorumSet 

Source
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 four rules:

  • Upward-closed: adding IDs to an accepted quorum keeps it accepted. VecProgress and verify_intersection rely on this rule.
  • Closed over ids(): an ID that ids() does not yield never changes the result of is_quorum(). verify_intersection enumerates only the IDs that ids() 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.
  • No empty quorum: an input that holds no ID from ids(), such as an empty input, is never a quorum. An upward-closed rule that accepted the empty input would accept every input, so a read or write operation would succeed without contacting any node.

The crate provides implementations for flat majority sets, joint quorum sets, ThresholdQuorumSet rules, Joint rules over any rule type, 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§

Source

type Id

Node ID type in this quorum set.

Source

type Iter: Iterator<Item = Self::Id>

Iterator over every voter ID tracked by this quorum set.

Implementations that combine multiple sub-rules return each ID once.

Required Methods§

Source

fn is_quorum<'a, I>(&self, ids: I) -> bool
where Self::Id: 'a, I: Iterator<Item = &'a Self::Id> + Clone,

Return true if the candidate IDs satisfy this quorum rule.

Repeated IDs count once, and IDs that ids() does not yield are ignored. An empty input is never a quorum.

Source

fn ids(&self) -> Self::Iter

Return all voter IDs in this quorum set.

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>
where ID: Ord + Clone,

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.

Source§

type Id = ID

Source§

type Iter = IntoIter<ID>

Source§

fn is_quorum<'a, I>(&self, ids: I) -> bool
where ID: 'a, I: Iterator<Item = &'a ID> + Clone,

Source§

fn ids(&self) -> Self::Iter

Source§

impl<ID> QuorumSet for Vec<BTreeSet<ID>>
where ID: Ord + Clone,

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 has no voter and accepts no candidate set, like an empty BTreeSet.

Source§

type Id = ID

Source§

type Iter = IntoIter<ID>

Source§

fn is_quorum<'a, I>(&self, ids: I) -> bool
where ID: 'a, I: Iterator<Item = &'a ID> + Clone,

Source§

fn ids(&self) -> Self::Iter

Source§

impl<T> QuorumSet for Arc<T>
where T: QuorumSet,

Source§

type Id = <T as QuorumSet>::Id

Source§

type Iter = <T as QuorumSet>::Iter

Source§

fn is_quorum<'a, I>(&self, ids: I) -> bool
where Self::Id: 'a, I: Iterator<Item = &'a Self::Id> + Clone,

Source§

fn ids(&self) -> Self::Iter

Implementors§

Source§

impl<ID> QuorumSet for QuorumTree<ID>
where ID: Ord + Clone,

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.

Source§

type Id = ID

Source§

type Iter = IntoIter<ID>

Source§

impl<ID> QuorumSet for ThresholdQuorumSet<ID>
where ID: Ord + Clone,

Source§

type Id = ID

Source§

type Iter = IntoIter<ID>

Source§

impl<Q> QuorumSet for Joint<Q>
where Q: QuorumSet, Q::Id: Ord,

Source§

type Id = <Q as QuorumSet>::Id

Source§

type Iter = IntoIter<<Q as QuorumSet>::Id>

Source§

impl<R, W> QuorumSet for BothQuorums<R, W>
where R: QuorumSet, W: QuorumSet<Id = R::Id>, R::Id: Ord,

Source§

type Id = <R as QuorumSet>::Id

Source§

type Iter = IntoIter<<R as QuorumSet>::Id>

Source§

impl<R, W> QuorumSet for ReadOrBoth<R, W>
where R: QuorumSet, W: QuorumSet<Id = R::Id>, R::Id: Ord,

Source§

type Id = <R as QuorumSet>::Id

Source§

type Iter = IntoIter<<R as QuorumSet>::Id>