forked from TrueCloudLab/frostfs-node
[#184] Use SDK client cache in object.Search
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7ba95dd5fc
commit
d485a5967d
4 changed files with 18 additions and 6 deletions
|
@ -265,6 +265,7 @@ func initObjectService(c *cfg) {
|
|||
|
||||
sSearch := searchsvc.NewService(
|
||||
searchsvc.WithKeyStorage(keyStorage),
|
||||
searchsvc.WithClientCache(clientCache),
|
||||
searchsvc.WithLocalStorage(ls),
|
||||
searchsvc.WithContainerSource(c.cfgObject.cnrStorage),
|
||||
searchsvc.WithNetworkMapSource(c.cfgObject.netMapStorage),
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -16,6 +17,8 @@ type remoteStream struct {
|
|||
keyStorage *util.KeyStorage
|
||||
|
||||
addr *network.Address
|
||||
|
||||
clientCache *cache.ClientCache
|
||||
}
|
||||
|
||||
func (s *remoteStream) stream(ctx context.Context, ch chan<- []*object.ID) error {
|
||||
|
@ -29,9 +32,7 @@ func (s *remoteStream) stream(ctx context.Context, ch chan<- []*object.ID) error
|
|||
return err
|
||||
}
|
||||
|
||||
c, err := client.New(key,
|
||||
client.WithAddress(addr),
|
||||
)
|
||||
c, err := s.clientCache.Get(key, addr)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not create SDK client %s", s, addr)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
|
||||
objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util"
|
||||
)
|
||||
|
@ -31,6 +32,8 @@ type cfg struct {
|
|||
workerPool util.WorkerPool
|
||||
|
||||
localAddrSrc network.LocalAddressSource
|
||||
|
||||
clientCache *cache.ClientCache
|
||||
}
|
||||
|
||||
func defaultCfg() *cfg {
|
||||
|
@ -96,3 +99,9 @@ func WithLocalAddressSource(v network.LocalAddressSource) Option {
|
|||
c.localAddrSrc = v
|
||||
}
|
||||
}
|
||||
|
||||
func WithClientCache(v *cache.ClientCache) Option {
|
||||
return func(c *cfg) {
|
||||
c.clientCache = v
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,9 +161,10 @@ loop:
|
|||
}
|
||||
} else {
|
||||
streamer = &remoteStream{
|
||||
prm: prm,
|
||||
keyStorage: p.keyStorage,
|
||||
addr: addr,
|
||||
prm: prm,
|
||||
keyStorage: p.keyStorage,
|
||||
addr: addr,
|
||||
clientCache: p.clientCache,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue