[#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:
Leonard Lyubich 2021-03-23 21:40:36 +03:00 committed by Leonard Lyubich
parent f25253738a
commit 106884fc40
13 changed files with 65 additions and 49 deletions

View file

@ -3,12 +3,12 @@ package putsvc
import (
"context"
"github.com/nspcc-dev/neofs-api-go/pkg/client"
"github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"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/nspcc-dev/neofs-node/pkg/util/logger"
@ -29,6 +29,10 @@ type Service struct {
type Option func(*cfg)
type ClientConstructor interface {
Get(string) (client.Client, error)
}
type cfg struct {
keyStorage *objutil.KeyStorage
@ -50,7 +54,7 @@ type cfg struct {
networkState netmap.State
clientCache *cache.ClientCache
clientConstructor ClientConstructor
log *logger.Logger
}
@ -138,9 +142,9 @@ func WithNetworkState(v netmap.State) Option {
}
}
func WithClientCache(v *cache.ClientCache) Option {
func WithClientConstructor(v ClientConstructor) Option {
return func(c *cfg) {
c.clientCache = v
c.clientConstructor = v
}
}