Added connection reload for CDR server

This commit is contained in:
Trial97
2019-09-25 11:11:50 +03:00
committed by Dan Christian Bogos
parent 9cedb53fbe
commit d79b26419c
4 changed files with 73 additions and 2 deletions

View File

@@ -829,3 +829,35 @@ func (cdrS *CDRServer) V1CountCDRs(args *utils.RPCCDRsFilterWithArgDispatcher, c
}
return nil
}
// var ralConn, rpcclient.RpcClientConnection
// SetAttributeSConnection sets the new conection to the attribute service
// only used on reload
func (cdrS *CDRServer) SetAttributeSConnection(attrS rpcclient.RpcClientConnection) {
cdrS.attrS = attrS
}
// SetThresholSConnection sets the new conection to the threshold service
// only used on reload
func (cdrS *CDRServer) SetThresholSConnection(thdS rpcclient.RpcClientConnection) {
cdrS.thdS = thdS
}
// SetStatSConnection sets the new conection to the stat service
// only used on reload
func (cdrS *CDRServer) SetStatSConnection(stS rpcclient.RpcClientConnection) {
cdrS.statS = stS
}
// SetChargerSConnection sets the new conection to the charger service
// only used on reload
func (cdrS *CDRServer) SetChargerSConnection(chS rpcclient.RpcClientConnection) {
cdrS.chargerS = chS
}
// SetRALsConnection sets the new conection to the RAL service
// only used on reload
func (cdrS *CDRServer) SetRALsConnection(rls rpcclient.RpcClientConnection) {
cdrS.rals = rls
}

View File

@@ -616,7 +616,7 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted
return
}
// V1GetSupplierProfiles returns the list of valid supplier profiles
// V1GetSupplierProfilesForEvent returns the list of valid supplier profiles
func (spS *SupplierService) V1GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher, reply *[]*SupplierProfile) (err error) {
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.Tenant, utils.ID}); len(missing) != 0 {
return utils.NewErrMandatoryIeMissing(missing...)

View File

@@ -111,6 +111,45 @@ func (cdrS *CDRServer) GetIntenternalChan() (conn chan rpcclient.RpcClientConnec
// Reload handles the change of config
func (cdrS *CDRServer) Reload(sp servmanager.ServiceProvider) (err error) {
var ralConn, attrSConn, thresholdSConn, statsConn, chargerSConn rpcclient.RpcClientConnection
chargerSConn, err = sp.GetConnection(utils.ChargerS, sp.GetConfig().CdrsCfg().ChargerSConns)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("<CDRS> Could not connect to %s: %s",
utils.ChargerS, err.Error()))
return
}
ralConn, err = sp.GetConnection(utils.ResponderS, sp.GetConfig().CdrsCfg().RaterConns)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("<CDRS> Could not connect to %s: %s",
utils.RALService, err.Error()))
return
}
attrSConn, err = sp.GetConnection(utils.AttributeS, sp.GetConfig().CdrsCfg().AttributeSConns)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("<CDRS> Could not connect to %s: %s",
utils.AttributeS, err.Error()))
return
}
thresholdSConn, err = sp.GetConnection(utils.ThresholdS, sp.GetConfig().CdrsCfg().ThresholdSConns)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("<CDRS> Could not connect to %s: %s",
utils.ThresholdS, err.Error()))
return
}
statsConn, err = sp.GetConnection(utils.StatS, sp.GetConfig().CdrsCfg().StatSConns)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("<CDRS> Could not connect to %s: %s",
utils.StatS, err.Error()))
return
}
cdrS.Lock()
cdrS.cdrS.SetRALsConnection(ralConn)
cdrS.cdrS.SetAttributeSConnection(attrSConn)
cdrS.cdrS.SetThresholSConnection(thresholdSConn)
cdrS.cdrS.SetStatSConnection(statsConn)
cdrS.cdrS.SetChargerSConnection(chargerSConn)
cdrS.Unlock()
return
}

View File

@@ -90,7 +90,7 @@ func (schS *SchedulerService) GetIntenternalChan() (conn chan rpcclient.RpcClien
func (schS *SchedulerService) Reload(sp servmanager.ServiceProvider) (err error) {
schS.Lock()
schS.schS.Reload()
defer schS.Unlock()
schS.Unlock()
return
}