[][src]Struct browseraft::NodeBuilder

pub struct NodeBuilder<T> { /* fields omitted */ }

Implementations

impl<T> NodeBuilder<T> where
    T: Serialize + DeserializeOwned + 'static, 
[src]

pub fn election_timeout(mut self: Self, ms: u32) -> Self[src]

Set the election timeout in milliseconds. This is discouraged, as the timeout should be randomized (so that nodes are less likely to simultaneously initiate elections). See eleciton_timeout_range

NB: If election_timeout_range is also set, this will overwrite it.

Defaults to a random value in the range (150, 300)

pub fn election_timeout_range(mut self: Self, low_ms: u32, high_ms: u32) -> Self[src]

Set the range for the randomized value of the election timeout.

Defaults to (150, 300).

pub fn heartbeat_timeout(mut self: Self, ms: u32) -> Self[src]

Set the leader heartbeat interval in milliseconds

Defaults to 50

pub fn id(mut self: Self, id: u32) -> Self[src]

Set the node's id.

Defaults to a random number

pub fn channel(mut self: Self, name: &str) -> Self[src]

Set the name of the BroadcastChannel the node should connect to

Defaults to "raft-nodes"

pub fn on_received<F>(mut self: Self, callback: F) -> Self where
    F: Fn(T) + 'static, 
[src]

Attach a closure to the node that will be called when the node receives a [Message::Payload] message

pub fn on_role_change<F>(mut self: Self, callback: F) -> Self where
    F: Fn(Role) + 'static, 
[src]

Attach a closure to the node that will be called when the node's role is changed.

pub fn build(self) -> Arc<Node<T>>[src]

Finalize the builder and construct a Node

Trait Implementations

impl<T> Default for NodeBuilder<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for NodeBuilder<T>[src]

impl<T> !Send for NodeBuilder<T>[src]

impl<T> !Sync for NodeBuilder<T>[src]

impl<T> Unpin for NodeBuilder<T>[src]

impl<T> !UnwindSafe for NodeBuilder<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.