mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: export method EtcdServer.leaderChangedNotify (#12378)
This commit is contained in:
@@ -185,6 +185,15 @@ type Server interface {
|
||||
ClusterVersion() *semver.Version
|
||||
Cluster() api.Cluster
|
||||
Alarms() []*pb.AlarmMember
|
||||
|
||||
// LeaderChangedNotify returns a channel for application level code to be notified
|
||||
// when etcd leader changes, this function is intend to be used only in application
|
||||
// which embed etcd.
|
||||
// Caution:
|
||||
// 1. the returned channel is being closed when the leadership changes.
|
||||
// 2. so the new channel needs to be obtained for each raft term.
|
||||
// 3. user can loose some consecutive channel changes using this API.
|
||||
LeaderChangedNotify() <-chan struct{}
|
||||
}
|
||||
|
||||
// EtcdServer is the production implementation of the Server interface
|
||||
@@ -1743,7 +1752,7 @@ func (s *EtcdServer) getLead() uint64 {
|
||||
return atomic.LoadUint64(&s.lead)
|
||||
}
|
||||
|
||||
func (s *EtcdServer) leaderChangedNotify() <-chan struct{} {
|
||||
func (s *EtcdServer) LeaderChangedNotify() <-chan struct{} {
|
||||
s.leaderChangedMu.RLock()
|
||||
defer s.leaderChangedMu.RUnlock()
|
||||
return s.leaderChanged
|
||||
|
||||
Reference in New Issue
Block a user