mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added dummy service for CDRServer
This commit is contained in:
committed by
Dan Christian Bogos
parent
d18f9da6d6
commit
d93a0917a8
@@ -1345,7 +1345,7 @@ func main() {
|
||||
reS := services.NewResourceService()
|
||||
supS := services.NewSupplierService()
|
||||
schS := services.NewSchedulerService()
|
||||
srvManager.AddService(attrS, chrS, tS, stS, reS, supS, schS)
|
||||
srvManager.AddService(attrS, chrS, tS, stS, reS, supS, schS, services.NewCDRServer(internalCdrSChan))
|
||||
internalAttributeSChan = attrS.GetIntenternalChan()
|
||||
internalChargerSChan = chrS.GetIntenternalChan()
|
||||
internalThresholdSChan = tS.GetIntenternalChan()
|
||||
|
||||
86
services/cdrs.go
Normal file
86
services/cdrs.go
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
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/servmanager"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
// NewCDRServer returns the CDR Service
|
||||
func NewCDRServer(connChan chan rpcclient.RpcClientConnection) servmanager.Service {
|
||||
return &CDRServer{
|
||||
connChan: connChan,
|
||||
}
|
||||
}
|
||||
|
||||
// CDRServer implements Service interface
|
||||
// ToDo: Add the rest of functionality
|
||||
// only the chanel without reload functionality
|
||||
type CDRServer struct {
|
||||
// cdrS *engine.CDRServer
|
||||
// rpc *v1.CDRsV1
|
||||
connChan chan rpcclient.RpcClientConnection
|
||||
}
|
||||
|
||||
// Start should handle the sercive start
|
||||
func (cdrS *CDRServer) Start(sp servmanager.ServiceProvider, waitCache bool) (err error) {
|
||||
// if cdrS.IsRunning() {
|
||||
// return fmt.Errorf("service aleady running")
|
||||
// }
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetIntenternalChan returns the internal connection chanel
|
||||
func (cdrS *CDRServer) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) {
|
||||
return cdrS.connChan
|
||||
}
|
||||
|
||||
// Reload handles the change of config
|
||||
func (cdrS *CDRServer) Reload(sp servmanager.ServiceProvider) (err error) {
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Shutdown stops the service
|
||||
func (cdrS *CDRServer) Shutdown() (err error) {
|
||||
return utils.ErrNotImplemented
|
||||
// if err = cdrS.cdrS.Shutdown(); err != nil {
|
||||
// return
|
||||
// }
|
||||
// cdrS.cdrS = nil
|
||||
// cdrS.rpc = nil
|
||||
// <-cdrS.connChan
|
||||
// return
|
||||
}
|
||||
|
||||
// GetRPCInterface returns the interface to register for server
|
||||
func (cdrS *CDRServer) GetRPCInterface() interface{} {
|
||||
return nil //cdrS.rpc
|
||||
}
|
||||
|
||||
// IsRunning returns if the service is running
|
||||
func (cdrS *CDRServer) IsRunning() bool {
|
||||
return cdrS != nil // && cdrS.cdrS != nil
|
||||
}
|
||||
|
||||
// ServiceName returns the service name
|
||||
func (cdrS *CDRServer) ServiceName() string {
|
||||
return utils.CDRServer
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (schS *SchedulerService) Start(sp servmanager.ServiceProvider, waitCache bo
|
||||
schS.connChan <- schS.rpc
|
||||
|
||||
// Create connection to CDR Server and share it in engine(used for *cdrlog action)
|
||||
cdrsConn, err := sp.GetConnection(utils.CDRs, sp.GetConfig().SchedulerCfg().CDRsConns)
|
||||
cdrsConn, err := sp.GetConnection(utils.CDRServer, sp.GetConfig().SchedulerCfg().CDRsConns)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to CDRServer: %s", utils.SchedulerS, err.Error()))
|
||||
return
|
||||
|
||||
@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package services
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -78,14 +77,10 @@ func TestSchedulerSReload(t *testing.T) {
|
||||
t.Errorf("Expected service to be running")
|
||||
}
|
||||
cfg.SchedulerCfg().Enabled = false
|
||||
fmt.Println("1")
|
||||
cfg.GetReloadChan(config.SCHEDULER_JSN) <- struct{}{}
|
||||
fmt.Println("2")
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
if schS.IsRunning() {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
fmt.Println("3")
|
||||
engineShutdown <- true
|
||||
fmt.Println("4")
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ func (srvMngr *ServiceManager) GetConnection(subsystem string, conns []*config.R
|
||||
// srvMngr.RLock()
|
||||
// defer srvMngr.RUnlock()
|
||||
service, has := srvMngr.subsystems[subsystem]
|
||||
if !has { // used to bypass the not implemented services
|
||||
return nil, nil
|
||||
if !has { // used to not cause panics because of services that are not already migrated
|
||||
return nil, errors.New(utils.UnsupportedServiceIDCaps)
|
||||
}
|
||||
internalChan := service.GetIntenternalChan()
|
||||
if srvMngr.GetConfig().DispatcherSCfg().Enabled {
|
||||
|
||||
@@ -600,6 +600,7 @@ const (
|
||||
ChargerS = "ChargerS"
|
||||
CacheS = "CacheS"
|
||||
AnalyzerS = "AnalyzerS"
|
||||
CDRServer = "CDRServer"
|
||||
)
|
||||
|
||||
// Lower service names
|
||||
|
||||
Reference in New Issue
Block a user