hyperbahn/advertise.go
func (c *Client) advertiseLoop() {
	sleepFor := c.fuzzedAdvertiseInterval()
	consecutiveFailures := uint(0)

	for {
		c.sleep(sleepFor)
		if c.IsClosed() {
			c.tchan.Logger().Infof("Hyperbahn client closed")
			return
		}

		if err := c.sendAdvertise(); err != nil {
			consecutiveFailures++
			errLogger := c.tchan.Logger().WithFields(tchannel.ErrField(err))
			if consecutiveFailures >= maxAdvertiseFailures && c.opts.FailStrategy == FailStrategyFatal {
				c.opts.Handler.OnError(ErrAdvertiseFailed{Cause: err, WillRetry: false})
				errLogger.Fatal("Hyperbahn client registration failed.")
			}

			c.logFailedRegistrationRetry(errLogger, consecutiveFailures)
			c.opts.Handler.OnError(ErrAdvertiseFailed{Cause: err, WillRetry: true})

			// Even after many failures, cap backoff.
			if consecutiveFailures < maxAdvertiseFailures {
				sleepFor = fuzzInterval(advertiseRetryInterval * time.Duration(1<<consecutiveFailures))
			}
		} else {
			c.opts.Handler.On(Readvertised)
			sleepFor = c.fuzzedAdvertiseInterval()
			consecutiveFailures = 0
		}
	}
}
func (c *Client) advertiseLoop() {
	sleepFor := c.fuzzedAdvertiseInterval()
	consecutiveFailures := uint(0)

	for {
		c.sleep(sleepFor)
		if c.IsClosed() {
			c.tchan.Logger().Infof("Hyperbahn client closed")
			return
		}

		if err := c.sendAdvertise(); err != nil {
			consecutiveFailures++
			errLogger := c.tchan.Logger().WithFields(tchannel.ErrField(err))
			if consecutiveFailures >= maxAdvertiseFailures && c.opts.FailStrategy == FailStrategyFatal {
				c.opts.Handler.OnError(ErrAdvertiseFailed{Cause: err, WillRetry: false})
				errLogger.Fatal("Hyperbahn client registration failed.")
			}

			c.logFailedRegistrationRetry(errLogger, consecutiveFailures)
			c.opts.Handler.OnError(ErrAdvertiseFailed{Cause: err, WillRetry: true})

			// Even after many failures, cap backoff.
			if consecutiveFailures < maxAdvertiseFailures {
				sleepFor = fuzzInterval(advertiseRetryInterval * time.Duration(1<<consecutiveFailures))
			}
		} else {
			c.opts.Handler.On(Readvertised)
			sleepFor = c.fuzzedAdvertiseInterval()
			consecutiveFailures = 0
		}
	}
}
// advertiseLoop readvertises the service approximately every minute (with some fuzzing).