pub struct Cluster<N> { /* private fields */ }
Expand description

Utility to ease the implementation of changes in cluster membership, i.e. joining and parting of nodes, and concurrency.

This utility is most useful to implementors of the State trait. Whenever a log entry is applied it should also be applied to this Cluster. If done consistently, concurrency_at_offset_one and nodes_at can be used to trivially implement the methods concurrency and cluster_at.

Membership Changes

No limits are placed on membership changes. Practically speaking, however, it is wise not to make significant changes quickly. Nodes should not become voting members of a cluster until they can be certain they won’t break an earlier commitment.

Concurrency Increases

The implementation is “optimal” in that it takes advantage of concurrency increases the moment they become known.

Roundrr + 1r + 2
Log Entryc ≔ 5
Target Concurrency255
Effective Concurrency255

Concurrency Decreases

When concurrency is decreased, it cannot be assumed that everyone knows of this reduction until the the previous concurrency window is exhausted. Consider that the concurrency level is 5 in round r and is then reduced by a log entry in round r + 1. Any node that does not see that log entry in time may think the concurrency level is unchanged, at least until it exhausts the concurrency of 5 in round r + 5. Any further append to the log is only allowed while taking the reduction into account. That means that in effect the concurrency level slowly reduces from 5 to 2, as if the 5 throws a shadow along the axis of concurrency.

Roundrr + 1r + 2r + 3r + 4r + 5
Log Entryc ≔ 2
Target Concurrency522222
Effective Concurrency554322

Implementations

Returns a new cluster with the given initial state.

Applies the given log entry, making the appropiate updates.

Returns the concurrency at offset one.

Equivalent to c.nodes_at(NonZeroUsize::new(1).unwrap()).unwrap().

Returns effective set of nodes of the cluster for the given round number or None when the level of concurrency does not allow the node set to be determined yet.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Thaws this value.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more