mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added connection reload for Resource service
This commit is contained in:
committed by
Dan Christian Bogos
parent
22212e1125
commit
42f2403693
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user