forked from TrueCloudLab/frostfs-node
[#193] network/cache: Support client options in ClientCache.Get
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
a1b3da88c6
commit
27fc4d6e01
1 changed files with 3 additions and 5 deletions
8
pkg/network/cache/client.go
vendored
8
pkg/network/cache/client.go
vendored
|
@ -27,10 +27,8 @@ func NewSDKClientCache() *ClientCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get function returns existing client or creates a new one. Consider passing
|
// Get function returns existing client or creates a new one.
|
||||||
// connection options to specify details for client, but don't forget that two
|
func (c *ClientCache) Get(key *ecdsa.PrivateKey, address string, opts ...client.Option) (*client.Client, error) {
|
||||||
// different set of options should provide two different clients.
|
|
||||||
func (c *ClientCache) Get(key *ecdsa.PrivateKey, address string) (*client.Client, error) {
|
|
||||||
id := uniqueID(key, address)
|
id := uniqueID(key, address)
|
||||||
|
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
|
@ -52,7 +50,7 @@ func (c *ClientCache) Get(key *ecdsa.PrivateKey, address string) (*client.Client
|
||||||
return cli, nil
|
return cli, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cli, err := client.New(key, client.WithAddress(address))
|
cli, err := client.New(key, append(opts, client.WithAddress(address))...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue