Struct raft::Changer

source ·
pub struct Changer<'a> { /* private fields */ }
Expand description

Changer facilitates configuration changes. It exposes methods to handle simple and joint consensus while performing the proper validation that allows refusing invalid configuration changes before they affect the active configuration.

Implementations§

source§

impl Changer<'_>

source

pub fn new(tracker: &ProgressTracker) -> Changer<'_>

Creates a changer.

source

pub fn enter_joint( &self, auto_leave: bool, ccs: &[ConfChangeSingle] ) -> Result<(Configuration, MapChange)>

Verifies that the outgoing (=right) majority config of the joint config is empty and initializes it with a copy of the incoming (=left) majority config. That is, it transitions from

    (1 2 3)&&()

to

    (1 2 3)&&(1 2 3)
```.

The supplied changes are then applied to the incoming majority config,
resulting in a joint configuration that in terms of the Raft thesis[1]
(Section 4.3) corresponds to `C_{new,old}`.

[1]: https://github.com/ongardie/dissertation/blob/master/online-trim.pdf
source

pub fn leave_joint(&self) -> Result<(Configuration, MapChange)>

Transitions out of a joint configuration. It is an error to call this method if the configuration is not joint, i.e. if the outgoing majority config is empty.

The outgoing majority config of the joint configuration will be removed, that is, the incoming config is promoted as the sole decision maker. In the notation of the Raft thesis1 (Section 4.3), this method transitions from C_{new,old} into C_new.

At the same time, any staged learners (LearnersNext) the addition of which was held back by an overlapping voter in the former outgoing config will be inserted into Learners.

source

pub fn simple( &mut self, ccs: &[ConfChangeSingle] ) -> Result<(Configuration, MapChange)>

Carries out a series of configuration changes that (in aggregate) mutates the incoming majority config Voters[0] by at most one. This method will return an error if that is not the case, if the resulting quorum is zero, or if the configuration is in a joint state (i.e. if there is an outgoing configuration).

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Changer<'a>

§

impl<'a> Send for Changer<'a>

§

impl<'a> Sync for Changer<'a>

§

impl<'a> Unpin for Changer<'a>

§

impl<'a> UnwindSafe for Changer<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,