pub struct Trigger<'r, C>where
C: RaftTypeConfig,{ /* private fields */ }
Expand description
Trigger is an interface to trigger an action to RaftCore by external caller.
Implementations§
source§impl<'r, C> Trigger<'r, C>where
C: RaftTypeConfig,
impl<'r, C> Trigger<'r, C>where
C: RaftTypeConfig,
sourcepub async fn elect(&self) -> Result<(), Fatal<C::NodeId>>
pub async fn elect(&self) -> Result<(), Fatal<C::NodeId>>
Trigger election at once and return at once.
Returns error when RaftCore has Fatal
error, e.g. shut down or having storage error.
It is not affected by Raft::enable_elect(false)
.
sourcepub async fn heartbeat(&self) -> Result<(), Fatal<C::NodeId>>
pub async fn heartbeat(&self) -> Result<(), Fatal<C::NodeId>>
Trigger a heartbeat at once and return at once.
Returns error when RaftCore has Fatal
error, e.g. shut down or having storage error.
It is not affected by Raft::enable_heartbeat(false)
.
sourcepub async fn snapshot(&self) -> Result<(), Fatal<C::NodeId>>
pub async fn snapshot(&self) -> Result<(), Fatal<C::NodeId>>
Trigger to build a snapshot at once and return at once.
Returns error when RaftCore has Fatal
error, e.g. shut down or having storage error.
sourcepub async fn purge_log(&self, upto: u64) -> Result<(), Fatal<C::NodeId>>
pub async fn purge_log(&self, upto: u64) -> Result<(), Fatal<C::NodeId>>
Initiate the log purge up to and including the given upto
log index.
Logs that are not included in a snapshot will NOT be purged.
In such scenario it will delete as many log as possible.
The max_in_snapshot_log_to_keep
config is not taken into account
when purging logs.
It returns error only when RaftCore has Fatal
error, e.g. shut down or having storage
error.
Openraft won’t purge logs at once, e.g. it may be delayed by several seconds, because if it is a leader and a replication task has been replicating the logs to a follower, the logs can’t be purged until the replication task is finished.