diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index c3d72a38f..d17b2848e 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -11,9 +11,11 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-api-go/pkg" + apiclient "github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/netmap" netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + apiclientconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/apiclient" contractsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/contracts" engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine" shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard" @@ -36,6 +38,7 @@ import ( netmap2 "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/timer" "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/control" trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller" truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage" @@ -108,6 +111,8 @@ type cfg struct { cfgReputation cfgReputation mainChainClient *client.Client + + clientCache *cache.ClientCache } type cfgGRPC struct { @@ -271,12 +276,17 @@ func initCfg(path string) *cfg { scriptHash: contractsconfig.Reputation(appCfg), workerPool: reputationWorkerPool, }, + clientCache: cache.NewSDKClientCache( + apiclient.WithDialTimeout(apiclientconfig.DialTimeout(appCfg)), + ), } if metricsconfig.Address(c.appCfg) != "" { c.metricsCollector = metrics.NewStorageMetrics() } + c.onShutdown(c.clientCache.CloseAll) // clean up connections + initLocalStorage(c) return c diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 63f0cc140..0216cd12a 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -21,7 +21,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/morph/event" containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container" "github.com/nspcc-dev/neofs-node/pkg/network" - "github.com/nspcc-dev/neofs-node/pkg/network/cache" containerTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc" containerService "github.com/nspcc-dev/neofs-node/pkg/services/container" loadcontroller "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/controller" @@ -72,15 +71,13 @@ func initContainerService(c *cfg) { PlacementBuilder: loadPlacementBuilder, }) - clientCache := cache.NewSDKClientCache() // FIXME: use shared cache - loadRouter := loadroute.New( loadroute.Prm{ LocalServerInfo: c, RemoteWriterProvider: &remoteLoadAnnounceProvider{ key: &c.key.PrivateKey, loadAddrSrc: c, - clientCache: clientCache, + clientCache: c.clientCache, deadEndProvider: loadcontroller.SimpleWriterProvider(loadAccumulator), }, Builder: routeBuilder, @@ -88,8 +85,6 @@ func initContainerService(c *cfg) { loadroute.WithLogger(c.log), ) - c.onShutdown(clientCache.CloseAll) - ctrl := loadcontroller.New( loadcontroller.Prm{ LocalMetrics: loadcontroller.SimpleIteratorProvider(localMetrics), diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index c9c9a4429..5d13cef93 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -14,7 +14,6 @@ import ( "github.com/nspcc-dev/neofs-api-go/util/signature" "github.com/nspcc-dev/neofs-api-go/v2/object" objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc" - apiclientconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/apiclient" policerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/policer" replicatorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/replicator" coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client" @@ -25,7 +24,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/network" - "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" @@ -168,17 +166,12 @@ func initObjectService(c *cfg) { nodeOwner.SetNeo3Wallet(neo3Wallet) - clientCache := cache.NewSDKClientCache( - client.WithDialTimeout(apiclientconfig.DialTimeout(c.appCfg))) - - c.onShutdown(clientCache.CloseAll) - clientConstructor := &reputationClientConstructor{ log: c.log, nmSrc: c.cfgObject.netMapStorage, netState: c.cfgNetmap.state, trustStorage: c.cfgReputation.localTrustStorage, - basicConstructor: clientCache, + basicConstructor: c.clientCache, } coreConstructor := (*coreClientConstructor)(clientConstructor) diff --git a/cmd/neofs-node/reputation.go b/cmd/neofs-node/reputation.go index b6f3784f1..18f7d6072 100644 --- a/cmd/neofs-node/reputation.go +++ b/cmd/neofs-node/reputation.go @@ -14,7 +14,6 @@ import ( rtpwrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" - "github.com/nspcc-dev/neofs-node/pkg/network/cache" grpcreputation "github.com/nspcc-dev/neofs-node/pkg/network/transport/reputation/grpc" "github.com/nspcc-dev/neofs-node/pkg/services/reputation" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" @@ -87,15 +86,11 @@ func initReputationService(c *cfg) { }, ) - apiClientCache := cache.NewSDKClientCache() - - c.onShutdown(apiClientCache.CloseAll) - remoteLocalTrustProvider := common.NewRemoteTrustProvider( common.RemoteProviderPrm{ LocalAddrSrc: c, DeadEndProvider: daughterStorageWriterProvider, - ClientCache: apiClientCache, + ClientCache: c.clientCache, WriterProvider: localreputation.NewRemoteProvider( localreputation.RemoteProviderPrm{ Key: &c.key.PrivateKey, @@ -108,7 +103,7 @@ func initReputationService(c *cfg) { common.RemoteProviderPrm{ LocalAddrSrc: c, DeadEndProvider: consumerStorageWriterProvider, - ClientCache: apiClientCache, + ClientCache: c.clientCache, WriterProvider: intermediatereputation.NewRemoteProvider( intermediatereputation.RemoteProviderPrm{ Key: &c.key.PrivateKey,