mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Removed unused connmanager service
This commit is contained in:
@@ -777,9 +777,9 @@ func testInternalAccountBalanceOperations(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
Account: "testAccount1",
|
||||
BalanceType: utils.MONETARY,
|
||||
Value: 17.4,
|
||||
Value: 17.4,
|
||||
Balance: map[string]interface{}{
|
||||
utils.ID: "testAccSetBalance",
|
||||
utils.ID: "testAccSetBalance",
|
||||
},
|
||||
}
|
||||
if err := internalRPC.Call(utils.ApierV1SetBalance, attrs, &reply); err != nil {
|
||||
|
||||
@@ -466,7 +466,7 @@ func main() {
|
||||
|
||||
// initialize the connManager before creating the DMService
|
||||
// because we need to pass the connection to it
|
||||
connManager := services.NewConnManagerService(cfg, map[string]chan rpcclient.ClientConnector{
|
||||
connManager := engine.NewConnManager(cfg, map[string]chan rpcclient.ClientConnector{
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAnalyzer): internalAnalyzerSChan,
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaApier): internalAPIerV1Chan,
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes): internalAttributeSChan,
|
||||
@@ -489,7 +489,7 @@ func main() {
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaDispatchers): internalDispatcherSChan,
|
||||
})
|
||||
|
||||
dmService := services.NewDataDBService(cfg, connManager.GetConnMgr())
|
||||
dmService := services.NewDataDBService(cfg, connManager)
|
||||
storDBService := services.NewStorDBService(cfg)
|
||||
if dmService.ShouldRun() { // Some services can run without db, ie: CDRC
|
||||
if err = dmService.Start(); err != nil {
|
||||
@@ -526,45 +526,44 @@ func main() {
|
||||
|
||||
// Start ServiceManager
|
||||
srvManager := servmanager.NewServiceManager(cfg, exitChan)
|
||||
|
||||
attrS := services.NewAttributeService(cfg, dmService, cacheS, filterSChan, server, internalAttributeSChan)
|
||||
dspS := services.NewDispatcherService(cfg, dmService, cacheS, filterSChan, server, internalDispatcherSChan, connManager.GetConnMgr())
|
||||
dspS := services.NewDispatcherService(cfg, dmService, cacheS, filterSChan, server, internalDispatcherSChan, connManager)
|
||||
chrS := services.NewChargerService(cfg, dmService, cacheS, filterSChan, server,
|
||||
internalChargerSChan, connManager.GetConnMgr())
|
||||
internalChargerSChan, connManager)
|
||||
tS := services.NewThresholdService(cfg, dmService, cacheS, filterSChan, server, internalThresholdSChan)
|
||||
stS := services.NewStatService(cfg, dmService, cacheS, filterSChan, server,
|
||||
internalStatSChan, connManager.GetConnMgr())
|
||||
internalStatSChan, connManager)
|
||||
reS := services.NewResourceService(cfg, dmService, cacheS, filterSChan, server,
|
||||
internalResourceSChan, connManager.GetConnMgr())
|
||||
internalResourceSChan, connManager)
|
||||
supS := services.NewSupplierService(cfg, dmService, cacheS, filterSChan, server,
|
||||
internalSupplierSChan, connManager.GetConnMgr())
|
||||
internalSupplierSChan, connManager)
|
||||
|
||||
schS := services.NewSchedulerService(cfg, dmService, cacheS, filterSChan,
|
||||
server, internalSchedulerSChan, connManager.GetConnMgr())
|
||||
server, internalSchedulerSChan, connManager)
|
||||
|
||||
rals := services.NewRalService(cfg, dmService, storDBService, cacheS, filterSChan, server,
|
||||
internalRALsChan, internalResponderChan, internalAPIerV1Chan, internalAPIerV2Chan,
|
||||
schS, exitChan, connManager.GetConnMgr())
|
||||
schS, exitChan, connManager)
|
||||
|
||||
cdrS := services.NewCDRServer(cfg, dmService, storDBService, filterSChan, server, internalCDRServerChan,
|
||||
connManager.GetConnMgr())
|
||||
connManager)
|
||||
|
||||
smg := services.NewSessionService(cfg, dmService, server, internalSessionSChan, exitChan, connManager.GetConnMgr())
|
||||
smg := services.NewSessionService(cfg, dmService, server, internalSessionSChan, exitChan, connManager)
|
||||
|
||||
ldrs := services.NewLoaderService(cfg, dmService, filterSChan, server, exitChan,
|
||||
internalLoaderSChan, connManager.GetConnMgr())
|
||||
internalLoaderSChan, connManager)
|
||||
anz := services.NewAnalyzerService(cfg, server, exitChan, internalAnalyzerSChan)
|
||||
|
||||
srvManager.AddServices(connManager, attrS, chrS, tS, stS, reS, supS, schS, rals,
|
||||
srvManager.AddServices(attrS, chrS, tS, stS, reS, supS, schS, rals,
|
||||
rals.GetResponder(), rals.GetAPIv1(), rals.GetAPIv2(), cdrS, smg,
|
||||
services.NewEventReaderService(cfg, filterSChan, exitChan, connManager.GetConnMgr()),
|
||||
services.NewDNSAgent(cfg, filterSChan, exitChan, connManager.GetConnMgr()),
|
||||
services.NewFreeswitchAgent(cfg, exitChan, connManager.GetConnMgr()),
|
||||
services.NewKamailioAgent(cfg, exitChan, connManager.GetConnMgr()),
|
||||
services.NewAsteriskAgent(cfg, exitChan, connManager.GetConnMgr()), // partial reload
|
||||
services.NewRadiusAgent(cfg, filterSChan, exitChan, connManager.GetConnMgr()), // partial reload
|
||||
services.NewDiameterAgent(cfg, filterSChan, exitChan, connManager.GetConnMgr()), // partial reload
|
||||
services.NewHTTPAgent(cfg, filterSChan, server, connManager.GetConnMgr()), // no reload
|
||||
services.NewEventReaderService(cfg, filterSChan, exitChan, connManager),
|
||||
services.NewDNSAgent(cfg, filterSChan, exitChan, connManager),
|
||||
services.NewFreeswitchAgent(cfg, exitChan, connManager),
|
||||
services.NewKamailioAgent(cfg, exitChan, connManager),
|
||||
services.NewAsteriskAgent(cfg, exitChan, connManager), // partial reload
|
||||
services.NewRadiusAgent(cfg, filterSChan, exitChan, connManager), // partial reload
|
||||
services.NewDiameterAgent(cfg, filterSChan, exitChan, connManager), // partial reload
|
||||
services.NewHTTPAgent(cfg, filterSChan, server, connManager), // no reload
|
||||
ldrs, anz, dspS, dmService, storDBService,
|
||||
)
|
||||
srvManager.StartServices()
|
||||
@@ -604,7 +603,7 @@ func main() {
|
||||
initConfigSv1(internalConfigChan, server)
|
||||
|
||||
// Start CDRC components if necessary
|
||||
go startCdrcs(filterSChan, exitChan, connManager.GetConnMgr())
|
||||
go startCdrcs(filterSChan, exitChan, connManager)
|
||||
|
||||
// Serve rpc connections
|
||||
go startRpc(server, rals.GetResponder().GetIntenternalChan(), cdrS.GetIntenternalChan(),
|
||||
|
||||
@@ -112,8 +112,6 @@ func loadConfig() (ldrCfg *config.CGRConfig) {
|
||||
}
|
||||
config.SetCgrConfig(ldrCfg)
|
||||
}
|
||||
// we initialize connManager here with nil for InternalChannels
|
||||
cM := engine.NewConnManager(ldrCfg, nil)
|
||||
// Data for DataDB
|
||||
if *dataDBType != dfltCfg.DataDbCfg().DataDbType {
|
||||
ldrCfg.DataDbCfg().DataDbType = strings.TrimPrefix(*dataDBType, "*")
|
||||
@@ -246,6 +244,8 @@ func main() {
|
||||
}
|
||||
|
||||
ldrCfg := loadConfig()
|
||||
// we initialize connManager here with nil for InternalChannels
|
||||
cM := engine.NewConnManager(ldrCfg, nil)
|
||||
|
||||
if !*toStorDB {
|
||||
d, err := engine.NewDataDBConn(ldrCfg.DataDbCfg().DataDbType,
|
||||
|
||||
@@ -1219,6 +1219,11 @@ func (cfg *CGRConfig) reloadSection(section string) (err error) {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case RPCConnsJsonName: // nothing to reload
|
||||
if !fall {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case DATADB_JSN:
|
||||
cfg.rldChans[DATADB_JSN] <- struct{}{}
|
||||
time.Sleep(1) // to force the context switch( to be sure we start the DB before a service that needs it)
|
||||
@@ -1436,15 +1441,6 @@ func (cfg *CGRConfig) reloadSection(section string) (err error) {
|
||||
time.Sleep(1) // to force the context switch( to be sure we start the DB before a service that needs it)
|
||||
}
|
||||
cfg.rldChans[Apier] <- struct{}{}
|
||||
if !fall {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case RPCConnsJsonName:
|
||||
cfg.rldChans[RPCConnsJsonName] <- struct{}{}
|
||||
if !fall {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1775,7 +1771,7 @@ func (*CGRConfig) loadConfigFromReader(rdr io.Reader, loadFuncs []func(jsnCfg *C
|
||||
// Reads all .json files out of a folder/subfolders and loads them up in lexical order
|
||||
func (cfg *CGRConfig) loadConfigFromPath(path string, loadFuncs []func(jsnCfg *CgrJsonCfg) error) (err error) {
|
||||
if isUrl(path) {
|
||||
return cfg.loadConfigFromHttp(path, loadFuncs) // prefix protocol
|
||||
return cfg.loadConfigFromHTTP(path, loadFuncs) // prefix protocol
|
||||
}
|
||||
var fi os.FileInfo
|
||||
if fi, err = os.Stat(path); err != nil {
|
||||
@@ -1831,7 +1827,7 @@ func (cfg *CGRConfig) loadConfigFromFolder(cfgDir string, loadFuncs []func(jsnCf
|
||||
return
|
||||
}
|
||||
|
||||
func (cfg *CGRConfig) loadConfigFromHttp(urlPaths string, loadFuncs []func(jsnCfg *CgrJsonCfg) error) (err error) {
|
||||
func (cfg *CGRConfig) loadConfigFromHTTP(urlPaths string, loadFuncs []func(jsnCfg *CgrJsonCfg) error) (err error) {
|
||||
for _, urlPath := range strings.Split(urlPaths, utils.INFIELD_SEP) {
|
||||
if _, err = url.ParseRequestURI(urlPath); err != nil {
|
||||
return
|
||||
|
||||
@@ -316,7 +316,7 @@ func (cdrS *CDRServer) chrgrSProcessEvent(cgrEv *utils.CGREventWithArgDispatcher
|
||||
func (cdrS *CDRServer) attrSProcessEvent(cgrEv *utils.CGREventWithArgDispatcher) (err error) {
|
||||
var rplyEv AttrSProcessEventReply
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.FirstNonEmpty(
|
||||
Context: utils.StringPointer(utils.FirstNonEmpty(
|
||||
utils.IfaceAsString(cgrEv.CGREvent.Event[utils.Context]),
|
||||
utils.MetaCDRs)),
|
||||
CGREvent: cgrEv.CGREvent}
|
||||
|
||||
@@ -52,7 +52,8 @@ func TestAttributeSReload(t *testing.T) {
|
||||
attrS := NewAttributeService(cfg, db,
|
||||
chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1),
|
||||
)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(attrS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -79,7 +79,8 @@ func TestCdrsReload(t *testing.T) {
|
||||
cdrS := NewCDRServer(cfg, db, stordb, filterSChan, server,
|
||||
make(chan rpcclient.ClientConnector, 1),
|
||||
nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), cdrS, ralS, schS, chrS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(cdrS, ralS, schS, chrS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown,
|
||||
make(chan rpcclient.ClientConnector, 1), nil), db, stordb)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
|
||||
@@ -53,7 +53,8 @@ func TestChargerSReload(t *testing.T) {
|
||||
db := NewDataDBService(cfg, nil)
|
||||
attrS := NewAttributeService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1))
|
||||
chrS := NewChargerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, chrS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(attrS, chrS,
|
||||
NewLoaderService(cfg, db, filterSChan, server,
|
||||
engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
func NewConnManagerService(cfg *config.CGRConfig, intConns map[string]chan rpcclient.ClientConnector) *ConnManagerService {
|
||||
return &ConnManagerService{
|
||||
cfg: cfg,
|
||||
connMgr: engine.NewConnManager(cfg, intConns),
|
||||
}
|
||||
}
|
||||
|
||||
type ConnManagerService struct {
|
||||
sync.RWMutex
|
||||
cfg *config.CGRConfig
|
||||
connMgr *engine.ConnManager
|
||||
}
|
||||
|
||||
// Start should handle the sercive start
|
||||
func (cM *ConnManagerService) Start() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetIntenternalChan returns the internal connection chanel
|
||||
func (cM *ConnManagerService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reload handles the change of config
|
||||
func (cM *ConnManagerService) Reload() (err error) {
|
||||
return // for the momment nothing to reload
|
||||
}
|
||||
|
||||
// Shutdown stops the service
|
||||
func (cM *ConnManagerService) Shutdown() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// IsRunning returns if the service is running
|
||||
func (cM *ConnManagerService) IsRunning() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ServiceName returns the service name
|
||||
func (cM *ConnManagerService) ServiceName() string {
|
||||
return utils.RPCConnS
|
||||
}
|
||||
|
||||
// ShouldRun returns if the service should be running
|
||||
func (cM *ConnManagerService) ShouldRun() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (cM *ConnManagerService) GetConnMgr() *engine.ConnManager {
|
||||
return cM.connMgr
|
||||
}
|
||||
@@ -49,8 +49,9 @@ func TestDataDBReload(t *testing.T) {
|
||||
close(chS.GetPrecacheChannel(utils.CacheAttributeFilterIndexes))
|
||||
server := utils.NewServer()
|
||||
srvMngr := servmanager.NewServiceManager(cfg, engineShutdown)
|
||||
db := NewDataDBService(cfg, nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), NewAttributeService(cfg, db,
|
||||
cM := engine.NewConnManager(cfg, nil)
|
||||
db := NewDataDBService(cfg, cM)
|
||||
srvMngr.AddServices(NewAttributeService(cfg, db,
|
||||
chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1)),
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
|
||||
@@ -55,7 +55,8 @@ func TestDispatcherSReload(t *testing.T) {
|
||||
attrS := NewAttributeService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1))
|
||||
srv := NewDispatcherService(cfg, db, chS, filterSChan, server,
|
||||
make(chan rpcclient.ClientConnector, 1), nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, srv,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(attrS, srv,
|
||||
NewLoaderService(cfg, db, filterSChan, server,
|
||||
engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
|
||||
@@ -53,7 +53,8 @@ func TestDNSAgentReload(t *testing.T) {
|
||||
sS := NewSessionService(cfg, db, server, make(chan rpcclient.ClientConnector, 1),
|
||||
engineShutdown, nil)
|
||||
srv := NewDNSAgent(cfg, filterSChan, engineShutdown, nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), srv, sS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(srv, sS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -57,7 +57,8 @@ func TestEventReaderSReload(t *testing.T) {
|
||||
db := NewDataDBService(cfg, nil)
|
||||
sS := NewSessionService(cfg, db, server, make(chan rpcclient.ClientConnector, 1), engineShutdown, nil)
|
||||
attrS := NewEventReaderService(cfg, filterSChan, engineShutdown, nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, sS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(attrS, sS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -75,7 +75,8 @@ func TestRalsReload(t *testing.T) {
|
||||
make(chan rpcclient.ClientConnector, 1),
|
||||
make(chan rpcclient.ClientConnector, 1),
|
||||
schS, engineShutdown, nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), ralS, schS, tS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(ralS, schS, tS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db, stordb)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -56,7 +56,8 @@ func TestResourceSReload(t *testing.T) {
|
||||
db := NewDataDBService(cfg, nil)
|
||||
tS := NewThresholdService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1))
|
||||
reS := NewResourceService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), tS, reS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(tS, reS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -47,7 +47,8 @@ func TestSchedulerSReload(t *testing.T) {
|
||||
srvMngr := servmanager.NewServiceManager(cfg, engineShutdown)
|
||||
db := NewDataDBService(cfg, nil)
|
||||
schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), schS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(schS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -129,7 +129,6 @@ func (smg *SessionService) GetIntenternalChan() (conn chan rpcclient.ClientConne
|
||||
|
||||
// Reload handles the change of config
|
||||
func (smg *SessionService) Reload() (err error) {
|
||||
|
||||
sReplConns, err := sessions.NewSReplConns(smg.cfg.SessionSCfg().ReplicationConns,
|
||||
smg.cfg.GeneralCfg().Reconnects, smg.cfg.GeneralCfg().ConnectTimeout,
|
||||
smg.cfg.GeneralCfg().ReplyTimeout)
|
||||
|
||||
@@ -80,7 +80,8 @@ func TestSessionSReload(t *testing.T) {
|
||||
make(chan rpcclient.ClientConnector, 1),
|
||||
nil)
|
||||
srv := NewSessionService(cfg, db, server, make(chan rpcclient.ClientConnector, 1), engineShutdown, nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), srv, chrS, schS, ralS, cdrS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(srv, chrS, schS, ralS, cdrS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db, stordb)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -56,7 +56,8 @@ func TestStatSReload(t *testing.T) {
|
||||
db := NewDataDBService(cfg, nil)
|
||||
tS := NewThresholdService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1))
|
||||
sS := NewStatService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), tS, sS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(tS, sS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -54,7 +54,8 @@ func TestSupplierSReload(t *testing.T) {
|
||||
db := NewDataDBService(cfg, nil)
|
||||
sts := NewStatService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil)
|
||||
supS := NewSupplierService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil)
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), supS, sts,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(supS, sts,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -50,7 +50,8 @@ func TestThresholdSReload(t *testing.T) {
|
||||
srvMngr := servmanager.NewServiceManager(cfg, engineShutdown)
|
||||
db := NewDataDBService(cfg, nil)
|
||||
tS := NewThresholdService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1))
|
||||
srvMngr.AddServices(NewConnManagerService(cfg, nil), tS,
|
||||
engine.NewConnManager(cfg, nil)
|
||||
srvMngr.AddServices(tS,
|
||||
NewLoaderService(cfg, db, filterSChan, server, engineShutdown, make(chan rpcclient.ClientConnector, 1), nil), db)
|
||||
if err = srvMngr.StartServices(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
// NewConnection returns a new connection
|
||||
func NewConnection(cfg *config.CGRConfig, serviceConnChan, dispatcherSChan chan rpcclient.ClientConnector,
|
||||
conns []*config.RemoteHost) (rpcclient.ClientConnector, error) {
|
||||
if len(conns) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
internalChan := serviceConnChan
|
||||
if cfg.DispatcherSCfg().Enabled {
|
||||
internalChan = dispatcherSChan
|
||||
}
|
||||
return engine.NewRPCPool(rpcclient.PoolFirst,
|
||||
cfg.TlsCfg().ClientKey,
|
||||
cfg.TlsCfg().ClientCerificate, cfg.TlsCfg().CaCertificate,
|
||||
cfg.GeneralCfg().ConnectAttempts, cfg.GeneralCfg().Reconnects,
|
||||
cfg.GeneralCfg().ConnectTimeout, cfg.GeneralCfg().ReplyTimeout,
|
||||
conns, internalChan, false)
|
||||
}
|
||||
@@ -147,7 +147,6 @@ func (srvMngr *ServiceManager) GetConfig() *config.CGRConfig {
|
||||
func (srvMngr *ServiceManager) StartServices() (err error) {
|
||||
go srvMngr.handleReload()
|
||||
for serviceName, shouldRun := range map[string]bool{
|
||||
utils.RPCConnS: true,
|
||||
utils.AttributeS: srvMngr.GetConfig().AttributeSCfg().Enabled,
|
||||
utils.ChargerS: srvMngr.GetConfig().ChargerSCfg().Enabled,
|
||||
utils.ThresholdS: srvMngr.GetConfig().ThresholdSCfg().Enabled,
|
||||
@@ -305,10 +304,6 @@ func (srvMngr *ServiceManager) handleReload() {
|
||||
if err = srvMngr.reloadService(utils.StorDB); err != nil {
|
||||
return
|
||||
}
|
||||
case <-srvMngr.GetConfig().GetReloadChan(config.RPCConnsJsonName):
|
||||
if err = srvMngr.reloadService(utils.RPCConnS); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
// handle RPC server
|
||||
}
|
||||
|
||||
@@ -709,7 +709,6 @@ const (
|
||||
CDRServer = "CDRServer"
|
||||
ResponderS = "ResponderS"
|
||||
GuardianS = "GuardianS"
|
||||
RPCConnS = "RPCConnS"
|
||||
)
|
||||
|
||||
// Lower service names
|
||||
|
||||
Reference in New Issue
Block a user