func (d dialer) dial(_ <-chan struct{}) (io.Closer, error) {
	a := retry.StartWithCancel(d.openAttempt, d.opts.Clock, d.ctx.Done())
	var lastErr error = nil
	for a.Next() {
		conn, tlsConfig, err := d.dial1()
		if err == nil {
			return &dialResult{
				conn:      conn,
				addr:      d.addr,
				ipAddr:    d.ipAddr,
				urlStr:    d.urlStr,
				tlsConfig: tlsConfig,
			}, nil
		}
		if isX509Error(err) || !a.More() {
			// certificate errors don't improve with retries.
			return nil, errors.Annotatef(err, "unable to connect to API")
		}
		lastErr = err
	}
	if lastErr == nil {
		logger.Debugf("no error, but not connected, probably cancelled before we started")
		return nil, parallel.ErrStopped
	}
	return nil, errors.Trace(lastErr)
}
// dial implements the function value expected by Try.Start
// by dialing the websocket as specified in d and retrying
// when appropriate.
dial implements the function value expected by Try.Start
by dialing the websocket as specified in d and retrying
when appropriate.
// dial implements the function value expected by Try . Start // by dialing the websocket as specified in d and retrying // when appropriate .
func (d dialer) dial(_ <-chan struct{}) (io.Closer, error) {
	a := retry.StartWithCancel(d.openAttempt, d.opts.Clock, d.ctx.Done())
	var lastErr error = nil
	for a.Next() {
		conn, tlsConfig, err := d.dial1()
		if err == nil {
			return &dialResult{
				conn:      conn,
				addr:      d.addr,
				ipAddr:    d.ipAddr,
				urlStr:    d.urlStr,
				tlsConfig: tlsConfig,
			}, nil
		}
		if isX509Error(err) || !a.More() {
			return nil, errors.Annotatef(err, "unable to connect to API")
		}
		lastErr = err
	}
	if lastErr == nil {
		logger.Debugf("no error, but not connected, probably cancelled before we started")
		return nil, parallel.ErrStopped
	}
	return nil, errors.Trace(lastErr)
}
func ( d dialer ) dial ( _ <- chan struct { } ) ( io . Closer , error ) { a := retry . StartWithCancel ( d . openAttempt , d . opts . Clock , d . ctx . Done ( ) ) var lastErr error = nil for a . Next ( ) { conn , tlsConfig , err := d . dial1 ( ) if err == nil { return & dialResult { conn : conn , addr : d . addr , ipAddr : d . ipAddr , urlStr : d . urlStr , tlsConfig : tlsConfig , } , nil } if isX509Error ( err ) || ! a . More ( ) { return nil , errors . Annotatef ( err , " " ) } lastErr = err } if lastErr == nil { logger . Debugf ( " " ) return nil , parallel . ErrStopped } return nil , errors . Trace ( lastErr ) }
dial implements the function value expected by Try.Start
by dialing the websocket as specified in d and retrying
when appropriate.
dial implements the function value expected by Try . Start by dialing the websocket as specified in d and retrying when appropriate .
// certificate errors don't improve with retries.