code: func (s *Service) supervisor() error {
  	first := true
  
  	for {
  		if first {
  			// no delay on first attempt
  			first = false
  		} else {
  			// get backoff duration
  			d := s.backoff.Duration()
  			s.log(fmt.Sprintf("Delay Reconnect: %v", d))
  
  			// sleep but return on Stop
  			select {
  			case <-time.After(d):
  			case <-s.tomb.Dying():
  				return tomb.ErrDying
  			}
  		}
  
  		s.log("Next Reconnect")
  
  		// prepare the stop channel
  		fail := make(chan struct{})
  
  		// try once to get a client
  		client, resumed := s.connect(fail)
  		if client == nil {
  			continue
  		}
  
  		// resubscribe
  		if s.ResubscribeAllSubscriptions {
  			if !s.resubscribe(client) {
  				continue
  			}
  		}
  
  		// run callback
  		if s.OnlineCallback != nil {
  			s.OnlineCallback(resumed)
  		}
  
  		// run dispatcher on client
  		dying := s.dispatcher(client, fail)
  
  		// run callback
  		if s.OfflineCallback != nil {
  			s.OfflineCallback()
  		}
  
  		// return goroutine if dying
  		if dying {
  			return tomb.ErrDying
  		}
  	}
  }
docs: // the supervised reconnect loop