pub struct Raft<LogEntry: AbstractLogEntry + 'static, FSM: AbstractStateMachine + Clone + 'static> {
pub raft_node: RaftNode<LogEntry, FSM>,
pub raft_server: RaftServer<LogEntry, FSM>,
pub tx_server: Sender<ServerRequestMsg<LogEntry, FSM>>,
pub logger: Arc<dyn Logger>,
}
Expand description
This structure contains functions required for Raft bootstrap along with RaftNode and RaftServer instances. The bootstrap function returns an instance of the Raft type that deref to RaftNode type, allowing the use of functions necessary for interaction with the cluster.
Fields§
§raft_node: RaftNode<LogEntry, FSM>
§raft_server: RaftServer<LogEntry, FSM>
§tx_server: Sender<ServerRequestMsg<LogEntry, FSM>>
§logger: Arc<dyn Logger>
Implementations§
source§impl<LogEntry: AbstractLogEntry, FSM: AbstractStateMachine + Clone + Send + Sync + 'static> Raft<LogEntry, FSM>
impl<LogEntry: AbstractLogEntry, FSM: AbstractStateMachine + Clone + Send + Sync + 'static> Raft<LogEntry, FSM>
sourcepub fn bootstrap<A: ToSocketAddrs>(
node_id: u64,
raft_addr: A,
fsm: FSM,
config: Config,
logger: Arc<dyn Logger>
) -> Result<Self>
pub fn bootstrap<A: ToSocketAddrs>( node_id: u64, raft_addr: A, fsm: FSM, config: Config, logger: Arc<dyn Logger> ) -> Result<Self>
Creates a new Raft instance. Cloning a Raft instance does not bootstrap a new Raft instance. To bootstrap a new Raft instance, call this associated function.
sourcepub async fn request_id<A: ToSocketAddrs>(
raft_addr: A,
peer_addr: String
) -> Result<ClusterJoinTicket>
pub async fn request_id<A: ToSocketAddrs>( raft_addr: A, peer_addr: String ) -> Result<ClusterJoinTicket>
Requests a cluster join ticket from the peer. You can use this to dynamically add members in addition to initial_peers.
Methods from Deref<Target = RaftNode<LogEntry, FSM>>§
pub async fn is_leader(&self) -> bool
pub async fn get_id(&self) -> u64
pub async fn get_leader_id(&self) -> u64
pub async fn get_peers(&self) -> Peers
pub async fn add_peer<A: ToSocketAddrs>( &self, id: u64, addr: A, role: Option<InitialRole> )
pub async fn add_peers(&self, peers: HashMap<u64, SocketAddr>)
pub async fn inspect(&self) -> Result<String>
pub async fn state_machine(&self) -> FSM
pub async fn storage(&self) -> HeedStorage
pub async fn propose(&self, proposal: Vec<u8>) -> Result<()>
pub async fn change_config( &self, conf_change: ConfChangeV2 ) -> ConfChangeResponseResult
pub async fn get_cluster_size(&self) -> usize
pub async fn quit(&self)
pub async fn transfer_leader(&self, node_id: u64)
pub async fn campaign(&self)
pub async fn demote(&self, term: u64, leader_id: u64)
pub async fn leave(&self)
pub async fn leave_joint(&self)
pub async fn send_message(&self, message: RaftMessage)
pub async fn make_snapshot(&self, index: u64, term: u64)
pub async fn join_cluster(&self, tickets: Vec<ClusterJoinTicket>)
Trait Implementations§
source§impl<LogEntry: Clone + AbstractLogEntry + 'static, FSM: Clone + AbstractStateMachine + Clone + 'static> Clone for Raft<LogEntry, FSM>
impl<LogEntry: Clone + AbstractLogEntry + 'static, FSM: Clone + AbstractStateMachine + Clone + 'static> Clone for Raft<LogEntry, FSM>
Auto Trait Implementations§
impl<LogEntry, FSM> Freeze for Raft<LogEntry, FSM>
impl<LogEntry, FSM> !RefUnwindSafe for Raft<LogEntry, FSM>
impl<LogEntry, FSM> Send for Raft<LogEntry, FSM>
impl<LogEntry, FSM> Sync for Raft<LogEntry, FSM>
impl<LogEntry, FSM> Unpin for Raft<LogEntry, FSM>
impl<LogEntry, FSM> !UnwindSafe for Raft<LogEntry, FSM>
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request