utils.rs 434 B

1234567891011121314
  1. use std::time::Duration;
  2. pub fn sleep_millis(mills: u64) {
  3. std::thread::sleep(Duration::from_millis(mills))
  4. }
  5. pub const LONG_ELECTION_TIMEOUT_MILLIS: u64 = 1000;
  6. pub fn sleep_election_timeouts(count: u64) {
  7. sleep_millis(LONG_ELECTION_TIMEOUT_MILLIS * count)
  8. }
  9. /// Pass this function to [`Raft::new`] if the application will not accept
  10. /// any request for taking snapshots.
  11. pub const NO_SNAPSHOT: fn(ruaft::Index) = |_| {};