Merge pull request #2151 from nspcc-dev/rpc-client-conn

rpc/client: add `MaxConnsPerHost` option, fix #2149
This commit is contained in:
Roman Khimov 2021-09-02 13:11:17 +03:00 committed by GitHub
commit 64f9ed826f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,6 +50,8 @@ type Options struct {
CACert string
DialTimeout 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.
@ -86,6 +88,7 @@ func New(ctx context.Context, endpoint string, opts Options) (*Client, error) {
DialContext: (&net.Dialer{
Timeout: opts.DialTimeout,
}).DialContext,
MaxConnsPerHost: opts.MaxConnsPerHost,
},
Timeout: opts.RequestTimeout,
}