pub struct Raft<LogEntry: AbstractLogEntry + 'static, LogStorage: StableStorage + Send + Clone + 'static, FSM: AbstractStateMachine + Clone + 'static> {
pub raft_node: RaftNode<LogEntry, LogStorage, FSM>,
pub raft_server: RaftServer<LogEntry, LogStorage, FSM>,
pub tx_server: Sender<ServerRequestMsg<LogEntry, LogStorage, 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, LogStorage, FSM>
§raft_server: RaftServer<LogEntry, LogStorage, FSM>
§tx_server: Sender<ServerRequestMsg<LogEntry, LogStorage, FSM>>
§logger: Arc<dyn Logger>
Implementations§
Source§impl<LogEntry: AbstractLogEntry, LogStorage: StableStorage + Send + Sync + Clone + 'static, FSM: AbstractStateMachine + Send + Sync + Clone + 'static> Raft<LogEntry, LogStorage, FSM>
impl<LogEntry: AbstractLogEntry, LogStorage: StableStorage + Send + Sync + Clone + 'static, FSM: AbstractStateMachine + Send + Sync + Clone + 'static> Raft<LogEntry, LogStorage, FSM>
Sourcepub fn bootstrap<A: ToSocketAddrs>(
node_id: u64,
raft_addr: A,
log_storage: LogStorage,
fsm: FSM,
config: Config,
logger: Arc<dyn Logger>,
) -> Result<Self>
pub fn bootstrap<A: ToSocketAddrs>( node_id: u64, raft_addr: A, log_storage: LogStorage, 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,
tls_config: Option<TlsConfig>,
) -> Result<ClusterJoinTicket>
pub async fn request_id<A: ToSocketAddrs>( raft_addr: A, peer_addr: String, tls_config: Option<TlsConfig>, ) -> 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, LogStorage, FSM>>§
pub async fn is_leader(&self) -> Result<bool>
pub async fn get_id(&self) -> Result<u64>
pub async fn get_leader_id(&self) -> Result<u64>
pub async fn get_peers(&self) -> Result<Peers>
pub async fn add_peer<A: ToSocketAddrs>( &self, id: u64, addr: A, role: Option<InitialRole>, ) -> Result<()>
pub async fn add_peers(&self, peers: HashMap<u64, SocketAddr>) -> Result<()>
pub async fn inspect(&self) -> Result<String>
pub async fn state_machine(&self) -> Result<FSM>
pub async fn storage(&self) -> Result<LogStorage>
pub async fn propose(&self, proposal: Vec<u8>) -> Result<()>
pub async fn change_config( &self, conf_change: ConfChangeV2, ) -> Result<ConfChangeResponseResult>
pub async fn get_cluster_size(&self) -> Result<usize>
pub async fn quit(&self) -> Result<()>
pub async fn transfer_leader(&self, node_id: u64) -> Result<()>
pub async fn campaign(&self) -> Result<()>
pub async fn demote(&self, term: u64, leader_id: u64) -> Result<()>
pub async fn leave(&self) -> Result<()>
pub async fn leave_joint(&self)
pub async fn send_message(&self, message: RaftMessage) -> Result<()>
pub async fn make_snapshot(&self, index: u64, term: u64) -> Result<()>
pub async fn join_cluster(&self, tickets: Vec<ClusterJoinTicket>) -> Result<()>
Trait Implementations§
Source§impl<LogEntry: Clone + AbstractLogEntry + 'static, LogStorage: Clone + StableStorage + Send + Clone + 'static, FSM: Clone + AbstractStateMachine + Clone + 'static> Clone for Raft<LogEntry, LogStorage, FSM>
impl<LogEntry: Clone + AbstractLogEntry + 'static, LogStorage: Clone + StableStorage + Send + Clone + 'static, FSM: Clone + AbstractStateMachine + Clone + 'static> Clone for Raft<LogEntry, LogStorage, FSM>
Source§impl<LogEntry: AbstractLogEntry + 'static, LogStorage: StableStorage + Send + Clone + 'static, FSM: AbstractStateMachine + Clone + 'static> Deref for Raft<LogEntry, LogStorage, FSM>
impl<LogEntry: AbstractLogEntry + 'static, LogStorage: StableStorage + Send + Clone + 'static, FSM: AbstractStateMachine + Clone + 'static> Deref for Raft<LogEntry, LogStorage, FSM>
Auto Trait Implementations§
impl<LogEntry, LogStorage, FSM> Freeze for Raft<LogEntry, LogStorage, FSM>
impl<LogEntry, LogStorage, FSM> !RefUnwindSafe for Raft<LogEntry, LogStorage, FSM>
impl<LogEntry, LogStorage, FSM> Send for Raft<LogEntry, LogStorage, FSM>where
LogStorage: Sync,
impl<LogEntry, LogStorage, FSM> Sync for Raft<LogEntry, LogStorage, FSM>where
LogStorage: Sync,
impl<LogEntry, LogStorage, FSM> Unpin for Raft<LogEntry, LogStorage, FSM>
impl<LogEntry, LogStorage, FSM> !UnwindSafe for Raft<LogEntry, LogStorage, 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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