[][src]Struct raft4rs::raft::Raft

pub struct Raft {
    pub id: u64,
    pub applied: AtomicU64,
    pub store: RaftLog,
    pub replicas: RwLock<Vec<u64>>,
    pub resolver: RSL,
    // some fields omitted
}

Fields

id: u64applied: AtomicU64store: RaftLogreplicas: RwLock<Vec<u64>>resolver: RSL

Implementations

impl Raft[src]

pub async fn new(
    id: u64,
    start_index: u64,
    conf: Arc<Config>,
    replicas: Vec<u64>,
    resolver: RSL,
    sm: SM
) -> RaftResult<Arc<Self>>
[src]

id is raft id: it unique in diff raft group start_index: to add member when raft group exists . set it for playback log not remove self it first to load it by disk , if not exists use by your set, if you unknow how to set , set it 0 conf is raft config replicas all members in raft group . resolver to find addr by node_id callback for app

pub async fn notify<'_>(self: &'_ Raft)[src]

pub async fn execute<'_>(
    self: &'_ Arc<Raft>,
    cmd: Vec<u8>,
    forward_leader: bool
) -> RaftResult<Vec<u8>>
[src]

pub async fn submit<'_>(
    self: &'_ Arc<Raft>,
    cmd: Vec<u8>,
    forward_leader: bool
) -> RaftResult<()>
[src]

pub async fn add_member<'_>(self: &'_ Arc<Raft>, node_id: u64) -> RaftResult<()>[src]

pub async fn remove_member<'_>(
    self: &'_ Arc<Raft>,
    node_id: u64
) -> RaftResult<()>
[src]

pub async fn apply<'_, '_>(
    self: &'_ Arc<Raft>,
    entry: &'_ Entry
) -> RaftResult<()>
[src]

pub fn get_resolver(&self) -> &RSL[src]

pub async fn heartbeat<'_>(
    &'_ self,
    term: u64,
    leader: u64,
    committed: u64,
    applied: u64
) -> RaftResult<()>
[src]

pub async fn vote<'_>(
    &'_ self,
    leader: u64,
    term: u64,
    committed: u64
) -> RaftResult<()>
[src]

pub async fn leader_change<'_>(
    &'_ self,
    term: u64,
    index: u64,
    leader: u64
) -> RaftResult<()>
[src]

pub async fn is_follower<'_>(&'_ self) -> bool[src]

pub async fn is_leader<'_>(&'_ self) -> bool[src]

pub fn leader(&self) -> u64[src]

pub async fn is_candidate<'_>(&'_ self) -> bool[src]

pub async fn get_state<'_>(&'_ self) -> RaftState[src]

pub fn is_stoped(&self) -> bool[src]

pub async fn update_apply<'_>(&'_ self, term: u64, index: u64) -> RaftResult<()>[src]

pub async fn info<'_>(&'_ self) -> RaftInfo[src]

impl Raft[src]

pub async fn try_to_leader<'_>(self: &'_ Arc<Raft>) -> RaftResult<bool>[src]

pub async fn to_follower<'_>(&'_ self)[src]

impl Raft[src]

pub fn start(self: &Arc<Raft>)[src]

Auto Trait Implementations

impl !RefUnwindSafe for Raft

impl Send for Raft

impl Sync for Raft

impl Unpin for Raft

impl !UnwindSafe for Raft

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,