From 8a03ae73d6343f982c8d3b52b2fa1693e5d476a6 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Mon, 4 Jul 2022 16:13:47 +0300
Subject: [PATCH] refactor: rename postone_until -> broadcast_when

---
 src/traft/event.rs | 14 +++++++-------
 src/traft/node.rs  |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/traft/event.rs b/src/traft/event.rs
index daaf98eefa..fe9bc2b3f3 100644
--- a/src/traft/event.rs
+++ b/src/traft/event.rs
@@ -175,21 +175,21 @@ pub fn broadcast(event: impl Borrow<Event>) {
     }
 }
 
-/// Postpones the `postpone` event until the `until` event happens.
+/// Sets the `target` event to be broadcast when the `when` event happens.
 ///
 /// **NOTE**: the postponement is volatile, so if the instance restarts between
-/// the `postpone` and the `until` events happens, there will not be a
+/// the `target` and the `when` events happen, there will not be a
 /// notification.
 ///
-/// Adds an event handler which will broadcast the `postpone` event when the
-/// `until` happens.
+/// Adds an event handler which will broadcast the `target` event when the
+/// `when` event happens.
 ///
 /// Returns an error if `EVENTS` is uninitialized
-pub fn postpone_until(postpone: Event, until: Event) -> Result<(), Error> {
+pub fn broadcast_when(target: Event, when: Event) -> Result<(), Error> {
     let mut events = events()?;
-    let cond = events.regular_cond(postpone);
+    let cond = events.regular_cond(target);
     events.add_once_handler(
-        until,
+        when,
         handler(move || {
             cond.broadcast();
             Ok(())
diff --git a/src/traft/node.rs b/src/traft/node.rs
index 191e35caad..2dea124b58 100644
--- a/src/traft/node.rs
+++ b/src/traft/node.rs
@@ -489,7 +489,7 @@ fn handle_committed_conf_change(
     let raft_id = &raw_node.raft.id;
     let voters_old = Storage::voters().unwrap();
     if voters_old.contains(raft_id) && !conf_state.voters.contains(raft_id) {
-        event::postpone_until(Event::Demoted, Event::LeaveJointState).ok();
+        event::broadcast_when(Event::Demoted, Event::LeaveJointState).ok();
     }
 
     Storage::persist_conf_state(&conf_state).unwrap();
-- 
GitLab