Skip to main content

QuorumSet

Trait QuorumSet 

Source
pub trait QuorumSet {
    type Id: 'static;
    type Iter: Iterator<Item = Self::Id>;

    // Required methods
    fn is_quorum<'a, I: Iterator<Item = &'a Self::Id> + Clone>(
        &self,
        ids: I,
    ) -> bool;
    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

Implementations must be upward-closed: adding IDs to an accepted quorum must keep it accepted. The crate provides implementations for flat majority sets, joint quorum sets, and hierarchical QuorumTree rules.

Required Associated Types§

Source

type Id: 'static

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: Iterator<Item = &'a Self::Id> + Clone>( &self, ids: I, ) -> bool

Return true if the candidate IDs satisfy this quorum rule.

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: PartialOrd + Ord + Clone + 'static,

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.

Source§

type Id = ID

Source§

type Iter = IntoIter<ID>

Source§

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

Source§

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

Source§

impl<NID> QuorumSet for Vec<BTreeSet<NID>>
where NID: PartialOrd + Ord + Clone + 'static,

Joint quorum implementation for multiple flat voter sets.

A candidate set is accepted only when it is a majority quorum in every member config. ids() returns the deduplicated union of all config IDs.

Source§

type Id = NID

Source§

type Iter = IntoIter<NID>

Source§

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

Source§

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

Source§

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

Source§

type Id = <T as QuorumSet>::Id

Source§

type Iter = <T as QuorumSet>::Iter

Source§

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

Source§

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

Implementors§

Source§

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

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>