[#607] network: Return group-address client from ClientCache

Add group-address `Client` implementation. Return instances of this
implementation from `ClientCache.Get` method.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-21 17:56:19 +03:00 committed by Leonard Lyubich
parent 3805b0f638
commit c82615667d
3 changed files with 338 additions and 27 deletions

View file

@ -1,7 +1,6 @@
package cache
import (
"crypto/tls"
"sync"
"github.com/nspcc-dev/neofs-api-go/pkg/client"
@ -54,16 +53,7 @@ func (c *ClientCache) Get(netAddr network.Address) (client.Client, error) {
return cli, nil
}
opts := append(c.opts, client.WithAddress(netAddr.HostAddr()))
if netAddr.TLSEnabled() {
opts = append(opts, client.WithTLSConfig(&tls.Config{}))
}
cli, err := client.New(opts...)
if err != nil {
return nil, err
}
cli := newMultiClient(network.GroupFromAddress(netAddr), c.opts)
c.clients[mAddr] = cli