rpc/client: add MaxConnsPerHost option, fix #2149

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-09-02 11:25:57 +03:00
parent 296734d367
commit 9d34547118

View file

@ -50,6 +50,8 @@ type Options struct {
CACert string CACert string
DialTimeout time.Duration DialTimeout time.Duration
RequestTimeout time.Duration RequestTimeout time.Duration
// Limit total number of connections per host. No limit by default.
MaxConnsPerHost int
} }
// cache stores cache values for the RPC client methods. // cache stores cache values for the RPC client methods.
@ -86,6 +88,7 @@ func New(ctx context.Context, endpoint string, opts Options) (*Client, error) {
DialContext: (&net.Dialer{ DialContext: (&net.Dialer{
Timeout: opts.DialTimeout, Timeout: opts.DialTimeout,
}).DialContext, }).DialContext,
MaxConnsPerHost: opts.MaxConnsPerHost,
}, },
Timeout: opts.RequestTimeout, Timeout: opts.RequestTimeout,
} }