diff --git a/fsm/fsm.go b/fsm/fsm.go index 801505db..1c55139e 100644 --- a/fsm/fsm.go +++ b/fsm/fsm.go @@ -229,6 +229,11 @@ func (f *fsm) UniqueID() uint64 { return f.raft.UniqueID() } +// LeaderCh returns a channel with LeaderUpdates +// LeaderCh does not block. Note: this means if the user is not monitoring +// LeaderCh then the LeaderUpdate will be lost it is the user's +// responsibility to ensure the channel is consumed as aggressively as is needed +// based on expected update to the leader func (f *fsm) LeaderObserver() (LeaderObserver, error) { f.observationLock.Lock() defer f.observationLock.Unlock() @@ -257,6 +262,10 @@ type leaderUpdateObserver struct { id uint64 } +func (l *leaderUpdateObserver) LeaderCh() <-chan LeaderUpdate { + return l.updateCh +} + func (l *leaderUpdateObserver) Destroy() error { return l.fsm.unregisterLeaderObserver(l) } @@ -327,6 +336,10 @@ type memberUpdateObserver struct { id uint64 } +func (m *memberUpdateObserver) MemberCh() <-chan MemberUpdate { + return m.updateCh +} + func (m *memberUpdateObserver) Destroy() error { return m.fsm.unregisterMemberObserver(m) }