Example #1
0
func getConfig(e *etcdm.EtcdManager) (*cluster.NilConfig, error) {
	cv, _, err := e.GetClusterView()
	if err != nil {
		return nil, fmt.Errorf("cannot get clusterview: %v", err)
	}
	if cv == nil {
		return nil, fmt.Errorf("no clusterview available")
	}
	cfg := cv.Config
	if cfg == nil {
		return nil, nil
	}
	return cfg, nil
}
Example #2
0
func WaitClusterViewMaster(master string, e *etcdm.EtcdManager, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cv, _, err := e.GetClusterView()
		if err != nil {
			goto end
		}
		if cv != nil {
			if cv.Master == master {
				return nil
			}
		}
	end:
		time.Sleep(2 * time.Second)
	}
	return fmt.Errorf("timeout")

}