// httpDo decorates the inherited behavior w/ support for HTTP redirection to follow Mesos leadership changes.
// NOTE: this implementation will change the state of the client upon Mesos leadership changes.
httpDo decorates the inherited behavior w/ support for HTTP redirection to follow Mesos leadership changes.
NOTE: this implementation will change the state of the client upon Mesos leadership changes.
// httpDo decorates the inherited behavior w / support for HTTP redirection to follow Mesos leadership changes . // NOTE : this implementation will change the state of the client upon Mesos leadership changes .
func (cli *client) httpDo(m encoding.Marshaler, opt ...httpcli.RequestOpt) (resp mesos.Response, err error) {
	var (
		done            chan struct{} 
		redirectBackoff <-chan struct{}
		getBackoff      = func() <-chan struct{} {
			if redirectBackoff == nil {
				done = make(chan struct{})
				redirectBackoff = backoff.Notifier(cli.redirect.MinBackoffPeriod, cli.redirect.MaxBackoffPeriod, done)
			}
			return redirectBackoff
		}
	)
	defer func() {
		if done != nil {
			close(done)
		}
	}()
	for attempt := 0; ; attempt++ {
		resp, err = cli.Client.Do(m, opt...)
		redirectErr, ok := err.(*mesosRedirectionError)
		if !ok {
			return resp, err
		}
		if attempt < cli.redirect.MaxAttempts {
			log.Println("redirecting to " + redirectErr.newURL)
			cli.With(httpcli.Endpoint(redirectErr.newURL))
			<-getBackoff()
			continue
		}
		return
	}
}
func ( cli * client ) httpDo ( m encoding . Marshaler , opt ... httpcli . RequestOpt ) ( resp mesos . Response , err error ) { var ( done chan struct { } redirectBackoff <- chan struct { } getBackoff = func ( ) <- chan struct { } { if redirectBackoff == nil { done = make ( chan struct { } ) redirectBackoff = backoff . Notifier ( cli . redirect . MinBackoffPeriod , cli . redirect . MaxBackoffPeriod , done ) } return redirectBackoff } ) defer func ( ) { if done != nil { close ( done ) } } ( ) for attempt := 0 ; ; attempt ++ { resp , err = cli . Client . Do ( m , opt ... ) redirectErr , ok := err . ( * mesosRedirectionError ) if ! ok { return resp , err } if attempt < cli . redirect . MaxAttempts { log . Println ( " " + redirectErr . newURL ) cli . With ( httpcli . Endpoint ( redirectErr . newURL ) ) <- getBackoff ( ) continue } return } }
httpDo decorates the inherited behavior w/ support for HTTP redirection to follow Mesos leadership changes.
httpDo decorates the inherited behavior w / support for HTTP redirection to follow Mesos leadership changes .
// avoid allocating these chans unless we actually need to redirect