From 49cfc09d071306bb450666ee0d150970be5bc9d9 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Tue, 26 Dec 2023 18:43:56 -0500 Subject: [PATCH] Tighthen up code --- cluster/bootstrap.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cluster/bootstrap.go b/cluster/bootstrap.go index f652e8a8..4ca6f2d8 100644 --- a/cluster/bootstrap.go +++ b/cluster/bootstrap.go @@ -39,7 +39,8 @@ const ( type Suffrage int const ( - Voter Suffrage = iota + SuffrageUnknown Suffrage = iota + Voter NonVoter ) @@ -68,6 +69,11 @@ func (s Suffrage) IsVoter() bool { return s == Voter } +// IsNonVoter returns whether the Suffrage is a NonVoter. +func (s Suffrage) IsNonVoter() bool { + return s == NonVoter +} + const ( requestTimeout = 5 * time.Second numJoinAttempts = 1 @@ -178,7 +184,7 @@ func (b *Bootstrapper) Boot(id, raftAddr string, suf Suffrage, done func() bool, return nil } - if suf == Voter { + if suf.IsVoter() { // This is where we have to be careful. This node failed to join with any node // in the targets list. This could be because none of the nodes are contactable, // or none of the nodes are in a functioning cluster with a leader. That means that