mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Simplify indexer.AddService implementation
This commit is contained in:
committed by
Dan Christian Bogos
parent
82c985cdbe
commit
fbc9afc784
@@ -41,10 +41,10 @@ func (sI *ServiceIndexer) GetService(srvID string) Service {
|
||||
return sI.srvS[srvID]
|
||||
}
|
||||
|
||||
// AddService adds a service based on it's id to the index
|
||||
func (sI *ServiceIndexer) AddService(srvID string, srv Service) {
|
||||
// AddService registers a service in the indexer using its name as key
|
||||
func (sI *ServiceIndexer) AddService(s Service) {
|
||||
sI.mux.Lock()
|
||||
sI.srvS[srvID] = srv
|
||||
sI.srvS[s.ServiceName()] = s
|
||||
sI.mux.Unlock()
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ func (srvMngr *ServiceManager) StartServices(ctx *context.Context, shtDwn contex
|
||||
func (srvMngr *ServiceManager) AddServices(services ...Service) {
|
||||
srvMngr.Lock()
|
||||
for _, srv := range services {
|
||||
srvMngr.serviceIndexer.AddService(srv.ServiceName(), srv)
|
||||
srvMngr.serviceIndexer.AddService(srv)
|
||||
if sAPIData, hasAPIData := serviceAPIData[srv.ServiceName()]; hasAPIData { // Add the internal connections
|
||||
rpcIntChan := make(chan birpc.ClientConnector, 1)
|
||||
srvMngr.connMgr.AddInternalConn(sAPIData[1], sAPIData[0], rpcIntChan)
|
||||
|
||||
Reference in New Issue
Block a user