[#567] cmd/node: Close cached clients on shutdown

Call `CloseAll` on all `ClientCache` instances on application shutdown.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 09:44:38 +03:00 committed by Leonard Lyubich
parent bf92e895c0
commit 9b2939d538
3 changed files with 9 additions and 1 deletions

View file

@ -72,13 +72,15 @@ func initContainerService(c *cfg) {
PlacementBuilder: loadPlacementBuilder, PlacementBuilder: loadPlacementBuilder,
}) })
clientCache := cache.NewSDKClientCache() // FIXME: use shared cache
loadRouter := loadroute.New( loadRouter := loadroute.New(
loadroute.Prm{ loadroute.Prm{
LocalServerInfo: c, LocalServerInfo: c,
RemoteWriterProvider: &remoteLoadAnnounceProvider{ RemoteWriterProvider: &remoteLoadAnnounceProvider{
key: c.key, key: c.key,
loadAddrSrc: c, loadAddrSrc: c,
clientCache: cache.NewSDKClientCache(), // FIXME: use shared cache clientCache: clientCache,
deadEndProvider: loadcontroller.SimpleWriterProvider(loadAccumulator), deadEndProvider: loadcontroller.SimpleWriterProvider(loadAccumulator),
}, },
Builder: routeBuilder, Builder: routeBuilder,
@ -86,6 +88,8 @@ func initContainerService(c *cfg) {
loadroute.WithLogger(c.log), loadroute.WithLogger(c.log),
) )
c.onShutdown(clientCache.CloseAll)
ctrl := loadcontroller.New( ctrl := loadcontroller.New(
loadcontroller.Prm{ loadcontroller.Prm{
LocalMetrics: loadcontroller.SimpleIteratorProvider(localMetrics), LocalMetrics: loadcontroller.SimpleIteratorProvider(localMetrics),

View file

@ -155,6 +155,8 @@ func initObjectService(c *cfg) {
clientCache := cache.NewSDKClientCache( clientCache := cache.NewSDKClientCache(
client.WithDialTimeout(c.viper.GetDuration(cfgAPIClientDialTimeout))) client.WithDialTimeout(c.viper.GetDuration(cfgAPIClientDialTimeout)))
c.onShutdown(clientCache.CloseAll)
clientConstructor := &reputationClientConstructor{ clientConstructor := &reputationClientConstructor{
log: c.log, log: c.log,
nmSrc: c.cfgObject.netMapStorage, nmSrc: c.cfgObject.netMapStorage,

View file

@ -90,6 +90,8 @@ func initReputationService(c *cfg) {
apiClientCache := cache.NewSDKClientCache() apiClientCache := cache.NewSDKClientCache()
c.onShutdown(apiClientCache.CloseAll)
remoteLocalTrustProvider := common.NewRemoteTrustProvider( remoteLocalTrustProvider := common.NewRemoteTrustProvider(
common.RemoteProviderPrm{ common.RemoteProviderPrm{
LocalAddrSrc: c, LocalAddrSrc: c,