mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added connection reload for Charger service
This commit is contained in:
committed by
Dan Christian Bogos
parent
2c7247586b
commit
af924267e0
@@ -179,3 +179,9 @@ func (cS *ChargerService) V1GetChargersForEvent(args *utils.CGREventWithArgDispa
|
||||
*rply = cPs
|
||||
return
|
||||
}
|
||||
|
||||
// SetAttributeConnection sets the new conection to the attribute service
|
||||
// only used on reload
|
||||
func (cS *ChargerService) SetAttributeConnection(attrS rpcclient.RpcClientConnection) {
|
||||
cS.attrS = attrS
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func (attrS *AttributeService) GetIntenternalChan() (conn chan rpcclient.RpcClie
|
||||
|
||||
// Reload handles the change of config
|
||||
func (attrS *AttributeService) Reload(sp servmanager.ServiceProvider) (err error) {
|
||||
return
|
||||
return // for the momment nothing to reload
|
||||
}
|
||||
|
||||
// Shutdown stops the service
|
||||
|
||||
@@ -53,15 +53,15 @@ func (chrS *ChargerService) Start(sp servmanager.ServiceProvider, waitCache bool
|
||||
<-sp.GetCacheS().GetPrecacheChannel(utils.CacheChargerProfiles)
|
||||
<-sp.GetCacheS().GetPrecacheChannel(utils.CacheChargerFilterIndexes)
|
||||
}
|
||||
var chrSConn rpcclient.RpcClientConnection
|
||||
if chrSConn, err = sp.GetConnection(utils.AttributeS, sp.GetConfig().ChargerSCfg().AttributeSConns); err != nil {
|
||||
var attrSConn rpcclient.RpcClientConnection
|
||||
if attrSConn, err = sp.GetConnection(utils.AttributeS, sp.GetConfig().ChargerSCfg().AttributeSConns); err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s",
|
||||
utils.ChargerS, utils.AttributeS, err.Error()))
|
||||
return
|
||||
}
|
||||
chrS.Lock()
|
||||
defer chrS.Unlock()
|
||||
if chrS.chrS, err = engine.NewChargerService(sp.GetDM(), sp.GetFilterS(), chrSConn, sp.GetConfig()); err != nil {
|
||||
if chrS.chrS, err = engine.NewChargerService(sp.GetDM(), sp.GetFilterS(), attrSConn, sp.GetConfig()); err != nil {
|
||||
utils.Logger.Crit(
|
||||
fmt.Sprintf("<%s> Could not init, error: %s",
|
||||
utils.ChargerS, err.Error()))
|
||||
@@ -83,7 +83,15 @@ func (chrS *ChargerService) GetIntenternalChan() (conn chan rpcclient.RpcClientC
|
||||
|
||||
// Reload handles the change of config
|
||||
func (chrS *ChargerService) Reload(sp servmanager.ServiceProvider) (err error) {
|
||||
// need to reload the connection to the attributeS
|
||||
var attrSConn rpcclient.RpcClientConnection
|
||||
if attrSConn, err = sp.GetConnection(utils.AttributeS, sp.GetConfig().ChargerSCfg().AttributeSConns); err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s",
|
||||
utils.ChargerS, utils.AttributeS, err.Error()))
|
||||
return
|
||||
}
|
||||
chrS.Lock()
|
||||
chrS.chrS.SetAttributeConnection(attrSConn)
|
||||
chrS.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user