code: func (s *Store) WaitForLeader(timeout time.Duration) (string, error) {
  	tck := time.NewTicker(leaderWaitDelay)
  	defer tck.Stop()
  	tmr := time.NewTimer(timeout)
  	defer tmr.Stop()
  
  	for {
  		select {
  		case <-tck.C:
  			l := s.LeaderAddr()
  			if l != "" {
  				return l, nil
  			}
  		case <-tmr.C:
  			return "", fmt.Errorf("timeout expired")
  		}
  	}
  }
docs: // WaitForLeader blocks until a leader is detected, or the timeout expires.