Select Git revision
dialer_legacy.go
-
ale authored
Add the 'connect_timeout' and 'request_max_timeout' configuration fields, to control respectively the initial connection timeout, and the maximum time for each individual request. This allows fine-tuning of the expected performance of specific backends, for example to let optional backends fail fast.
ale authoredAdd the 'connect_timeout' and 'request_max_timeout' configuration fields, to control respectively the initial connection timeout, and the maximum time for each individual request. This allows fine-tuning of the expected performance of specific backends, for example to let optional backends fail fast.
dialer_legacy.go 581 B
// +build !go1.9
package clientutil
import (
"context"
"net"
"time"
)
// Go < 1.9 does not have net.DialContext, reimplement it in terms of
// net.DialTimeout.
func netDialContext(addr string, connectTimeout time.Duration) func(context.Context, string, string) (net.Conn, error) {
return func(ctx context.Context, net string, _ string) (net.Conn, error) {
if deadline, ok := ctx.Deadline(); ok {
ctxTimeout := time.Until(deadline)
if ctxTimeout < connectTimeout {
connectTimeout = ctxTimeout
}
}
return net.DialTimeout(network, addr, connectTimeout)
}
}