Ejemplo n.º 1
0
// capabilityLoop checks the cluster version every 500ms and updates
// the enabledCapability when the cluster version increased.
// capabilityLoop MUST be ran in a goroutine before checking capability
// or using capabilityHandler.
func capabilityLoop(s *etcdserver.EtcdServer) {
	stopped := s.StopNotify()

	var pv *semver.Version
	for {
		if v := s.ClusterVersion(); v != pv {
			if pv == nil {
				pv = v
			} else if v != nil && pv.LessThan(*v) {
				pv = v
			}
			enableMapMu.Lock()
			enabledMap = capabilityMaps[pv.String()]
			enableMapMu.Unlock()
		}

		select {
		case <-stopped:
			return
		case <-time.After(500 * time.Millisecond):
		}
	}
}