use crate::error::Result;
use crate::{ElectionType, State};
#[derive(Clone, Debug)]
pub enum Event<T: ElectionType> {
Startup,
TransitToLeader {
term: u64,
caused_by_step_up: bool,
},
TransitToFollower {
term: u64,
prev_state: State,
caused_by_step_down: bool,
},
TransitToObserver {
term: u64,
prev_state: State,
},
TransitToPreCandidate,
TransitToCandidate,
ChangeLeader(T::NodeId),
Shutdown,
}
pub trait EventHandler<T: ElectionType>: Send + Sync {
fn handle_event(&self, event: Event<T>) -> Result<()>;
}