forked from TrueCloudLab/frostfs-node
[#428] client: Hide client cache behind interface in dependent packages
Replace usage of `cache.ClientCache` type with interface with similar signature. This will further allow overloading clients without affecting the logic of dependent packages. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f25253738a
commit
106884fc40
13 changed files with 65 additions and 49 deletions
|
@ -7,17 +7,20 @@ 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"
|
||||
)
|
||||
|
||||
type ClientConstructor interface {
|
||||
Get(string) (client.Client, error)
|
||||
}
|
||||
|
||||
// RemoteHeader represents utility for getting
|
||||
// the object header from a remote host.
|
||||
type RemoteHeader struct {
|
||||
keyStorage *util.KeyStorage
|
||||
|
||||
clientCache *cache.ClientCache
|
||||
clientCache ClientConstructor
|
||||
}
|
||||
|
||||
// RemoteHeadPrm groups remote header operation parameters.
|
||||
|
@ -30,7 +33,7 @@ type RemoteHeadPrm struct {
|
|||
var ErrNotFound = errors.New("object header not found")
|
||||
|
||||
// NewRemoteHeader creates, initializes and returns new RemoteHeader instance.
|
||||
func NewRemoteHeader(keyStorage *util.KeyStorage, cache *cache.ClientCache) *RemoteHeader {
|
||||
func NewRemoteHeader(keyStorage *util.KeyStorage, cache ClientConstructor) *RemoteHeader {
|
||||
return &RemoteHeader{
|
||||
keyStorage: keyStorage,
|
||||
clientCache: cache,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue