Added connection reload for Resource service

This commit is contained in:
Trial97
2019-09-25 10:50:14 +03:00
committed by Dan Christian Bogos
parent 22212e1125
commit 42f2403693
2 changed files with 14 additions and 2 deletions

View File

@@ -765,3 +765,9 @@ func (rS *ResourceService) Reload() {
func (rS *ResourceService) StartLoop() {
go rS.runBackup()
}
// SetThresholdConnection sets the new conection to the threshold service
// only used on reload
func (rS *ResourceService) SetThresholdConnection(thdS rpcclient.RpcClientConnection) {
rS.thdS = thdS
}

View File

@@ -55,7 +55,7 @@ func (reS *ResourceService) Start(sp servmanager.ServiceProvider, waitCache bool
<-sp.GetCacheS().GetPrecacheChannel(utils.CacheResourceFilterIndexes)
}
var thdSConn rpcclient.RpcClientConnection
if thdSConn, err = sp.GetConnection(utils.ThresholdS, sp.GetConfig().StatSCfg().ThresholdSConns); err != nil {
if thdSConn, err = sp.GetConnection(utils.ThresholdS, sp.GetConfig().ResourceSCfg().ThresholdSConns); err != nil {
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to ThresholdS: %s", utils.ResourceS, err.Error()))
return
}
@@ -84,9 +84,15 @@ func (reS *ResourceService) GetIntenternalChan() (conn chan rpcclient.RpcClientC
// Reload handles the change of config
func (reS *ResourceService) Reload(sp servmanager.ServiceProvider) (err error) {
var thdSConn rpcclient.RpcClientConnection
if thdSConn, err = sp.GetConnection(utils.ThresholdS, sp.GetConfig().ResourceSCfg().ThresholdSConns); err != nil {
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to ThresholdS: %s", utils.ResourceS, err.Error()))
return
}
reS.Lock()
reS.reS.SetThresholdConnection(thdSConn)
reS.reS.Reload()
defer reS.Unlock()
reS.Unlock()
return
}