forked from TrueCloudLab/frostfs-node
[#184] Use SDK client cache in object.Head
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
fb90827532
commit
e9a6365333
3 changed files with 19 additions and 6 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
|
||||
objectTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc"
|
||||
objectService "github.com/nspcc-dev/neofs-node/pkg/services/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl"
|
||||
|
@ -180,6 +181,8 @@ func initObjectService(c *cfg) {
|
|||
|
||||
nodeOwner.SetNeo3Wallet(neo3Wallet)
|
||||
|
||||
clientCache := cache.NewSDKClientCache()
|
||||
|
||||
objGC := gc.New(
|
||||
gc.WithLogger(c.log),
|
||||
gc.WithRemover(ls),
|
||||
|
@ -220,7 +223,7 @@ func initObjectService(c *cfg) {
|
|||
),
|
||||
policer.WithTrigger(ch),
|
||||
policer.WithRemoteHeader(
|
||||
headsvc.NewRemoteHeader(keyStorage),
|
||||
headsvc.NewRemoteHeader(keyStorage, clientCache),
|
||||
),
|
||||
policer.WithLocalAddressSource(c),
|
||||
policer.WithHeadTimeout(
|
||||
|
@ -274,6 +277,7 @@ func initObjectService(c *cfg) {
|
|||
|
||||
sHead := headsvc.NewService(
|
||||
headsvc.WithKeyStorage(keyStorage),
|
||||
headsvc.WithClientCache(clientCache),
|
||||
headsvc.WithLocalStorage(ls),
|
||||
headsvc.WithContainerSource(c.cfgObject.cnrStorage),
|
||||
headsvc.WithNetworkMapSource(c.cfgObject.netMapStorage),
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/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"
|
||||
)
|
||||
|
@ -15,6 +16,8 @@ import (
|
|||
// the object header from a remote host.
|
||||
type RemoteHeader struct {
|
||||
keyStorage *util.KeyStorage
|
||||
|
||||
clientCache *cache.ClientCache
|
||||
}
|
||||
|
||||
// RemoteHeadPrm groups remote header operation parameters.
|
||||
|
@ -25,9 +28,10 @@ type RemoteHeadPrm struct {
|
|||
}
|
||||
|
||||
// NewRemoteHeader creates, initializes and returns new RemoteHeader instance.
|
||||
func NewRemoteHeader(keyStorage *util.KeyStorage) *RemoteHeader {
|
||||
func NewRemoteHeader(keyStorage *util.KeyStorage, cache *cache.ClientCache) *RemoteHeader {
|
||||
return &RemoteHeader{
|
||||
keyStorage: keyStorage,
|
||||
keyStorage: keyStorage,
|
||||
clientCache: cache,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,9 +65,7 @@ func (h *RemoteHeader) Head(ctx context.Context, prm *RemoteHeadPrm) (*object.Ob
|
|||
return nil, err
|
||||
}
|
||||
|
||||
c, err := client.New(key,
|
||||
client.WithAddress(addr),
|
||||
)
|
||||
c, err := h.clientCache.Get(key, addr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "(%T) could not create SDK client %s", h, addr)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,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"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -134,3 +135,9 @@ func WithRightChildSearcher(v RelationSearcher) Option {
|
|||
c.rightChildSearcher = v
|
||||
}
|
||||
}
|
||||
|
||||
func WithClientCache(v *cache.ClientCache) Option {
|
||||
return func(c *cfg) {
|
||||
c.remoteHeader.clientCache = v
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue