pub struct NodeBuilder<T> { /* private fields */ }
Implementations§
Source§impl<T> NodeBuilder<T>where
T: Serialize + DeserializeOwned + 'static,
impl<T> NodeBuilder<T>where
T: Serialize + DeserializeOwned + 'static,
Sourcepub fn election_timeout(self, ms: u32) -> Self
pub fn election_timeout(self, ms: u32) -> Self
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)
Sourcepub fn election_timeout_range(self, low_ms: u32, high_ms: u32) -> Self
pub fn election_timeout_range(self, low_ms: u32, high_ms: u32) -> Self
Set the range for the randomized value of the election timeout.
Defaults to (150, 300).
Sourcepub fn heartbeat_timeout(self, ms: u32) -> Self
pub fn heartbeat_timeout(self, ms: u32) -> Self
Set the leader heartbeat interval in milliseconds
Defaults to 50
Sourcepub fn channel(self, name: &str) -> Self
pub fn channel(self, name: &str) -> Self
Set the name of the BroadcastChannel
the node should connect to
Defaults to "raft-nodes"
Sourcepub fn on_received<F>(self, callback: F) -> Selfwhere
F: Fn(T) + 'static,
pub fn on_received<F>(self, callback: F) -> Selfwhere
F: Fn(T) + 'static,
Attach a closure to the node that will be called when the node receives a [Message::Payload] message
Sourcepub fn on_role_change<F>(self, callback: F) -> Self
pub fn on_role_change<F>(self, callback: F) -> Self
Attach a closure to the node that will be called when the node’s role is changed.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for NodeBuilder<T>
impl<T> !RefUnwindSafe for NodeBuilder<T>
impl<T> !Send for NodeBuilder<T>
impl<T> !Sync for NodeBuilder<T>
impl<T> Unpin for NodeBuilder<T>
impl<T> !UnwindSafe for NodeBuilder<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more