mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Update after rebase
This commit is contained in:
@@ -489,20 +489,20 @@ func main() {
|
||||
internalCacheSChan := make(chan rpcclient.ClientConnector, 1)
|
||||
internalGuardianSChan := make(chan rpcclient.ClientConnector, 1)
|
||||
|
||||
internalCDRServerChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalAttributeSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalDispatcherSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalSessionSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalChargerSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalThresholdSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalStatSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalResourceSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalSupplierSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalSchedulerSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalRALsChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalResponderChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalAPIerV1Chan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalAPIerV2Chan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency
|
||||
internalCDRServerChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalAttributeSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalDispatcherSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalSessionSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalChargerSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalThresholdSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalStatSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalResourceSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalSupplierSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalSchedulerSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalRALsChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalResponderChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalAPIerV1Chan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
internalAPIerV2Chan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency
|
||||
|
||||
// init CacheS
|
||||
cacheS := initCacheS(internalCacheSChan, server, dmService.GetDM(), exitChan)
|
||||
@@ -515,7 +515,7 @@ func main() {
|
||||
|
||||
// Start ServiceManager
|
||||
srvManager := servmanager.NewServiceManager(cfg, exitChan)
|
||||
connManager := services.NewConnManagerService(cfg, map[string]chan rpcclient.RpcClientConnection{
|
||||
connManager := services.NewConnManagerService(cfg, map[string]chan rpcclient.ClientConnector{
|
||||
//utils.AnalyzerSv1: anz.GetIntenternalChan(),
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaApier): internalAPIerV1Chan,
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes): internalAttributeSChan,
|
||||
@@ -523,7 +523,7 @@ func main() {
|
||||
//utils.CDRsV1: cdrS.GetIntenternalChan(),
|
||||
//utils.CDRsV2: cdrS.GetIntenternalChan(),
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaChargers): internalChargerSChan,
|
||||
utils.GuardianSv1: internalGuardianSChan,
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaGuardian): internalGuardianSChan,
|
||||
//utils.LoaderSv1: ldrs.GetIntenternalChan(),
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources): internalResourceSChan,
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResponder): internalResponderChan,
|
||||
|
||||
@@ -83,7 +83,6 @@ var (
|
||||
`Separator for csv file (by default "," is used)`)
|
||||
recursive = cgrLoaderFlags.Bool("recursive", false, "Loads data from folder recursive.")
|
||||
|
||||
|
||||
importID = cgrLoaderFlags.String("import_id", "", "Uniquely identify an import/load, postpended to some automatic fields")
|
||||
timezone = cgrLoaderFlags.String("timezone", "", `Timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>`)
|
||||
disableReverse = cgrLoaderFlags.Bool("disable_reverse_mappings", false, "Will disable reverse mappings rebuilding")
|
||||
@@ -96,6 +95,9 @@ var (
|
||||
dm *engine.DataManager
|
||||
storDb engine.LoadStorage
|
||||
loader engine.LoadReader
|
||||
|
||||
fromStorDB = cgrLoaderFlags.Bool("from_stordb", false, "Load the tariff plan from storDb to dataDb")
|
||||
toStorDB = cgrLoaderFlags.Bool("to_stordb", false, "Import the tariff plan from files to storDb")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
"thresholds_conns": [
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"thresholds_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
|
||||
"scheduler": {
|
||||
"enabled": true,
|
||||
"cdrs_conns": [
|
||||
{"address": "*internal"},
|
||||
],
|
||||
"cdrs_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ func logAction(ub *Account, a *Action, acs Actions, extraData interface{}) (err
|
||||
}
|
||||
|
||||
func cdrLogAction(acc *Account, a *Action, acs Actions, extraData interface{}) (err error) {
|
||||
if schedCdrsConns == nil {
|
||||
if len(config.CgrConfig().SchedulerCfg().CDRsConns) == 0 {
|
||||
return fmt.Errorf("No connection with CDR Server")
|
||||
}
|
||||
defaultTemplate := map[string]config.RSRParsers{
|
||||
@@ -204,11 +204,11 @@ func cdrLogAction(acc *Account, a *Action, acs Actions, extraData interface{}) (
|
||||
cdrs = append(cdrs, cdr)
|
||||
var rply string
|
||||
// After compute the CDR send it to CDR Server to be processed
|
||||
if err := schedCdrsConns.Call(utils.CDRsV1ProcessEvent,
|
||||
if err := connMgr.Call(config.CgrConfig().SchedulerCfg().CDRsConns,
|
||||
utils.CDRsV1ProcessEvent,
|
||||
&ArgV1ProcessEvent{
|
||||
Flags: []string{utils.ConcatenatedKey(utils.MetaChargers, "false")}, // do not try to get the chargers for cdrlog
|
||||
CGREvent: *cdr.AsCGREvent(),
|
||||
}, &rply); err != nil {
|
||||
Flags: []string{utils.ConcatenatedKey(utils.MetaChargers, "false")}, // do not try to get the chargers for cdrlog
|
||||
CGREvent: *cdr.AsCGREvent()}, &rply); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2665,6 +2665,9 @@ func (r *RPCMock) Call(method string, args interface{}, rply interface{}) error
|
||||
*rp = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
NEED TO REVIEW THIS TEST
|
||||
func TestCdrLogAction(t *testing.T) {
|
||||
bakSch := schedCdrsConns
|
||||
mock := RPCMock{}
|
||||
@@ -2750,7 +2753,7 @@ func TestCdrLogAction(t *testing.T) {
|
||||
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expCgrEv), utils.ToJSON(mock.args.CGREvent))
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**************** Benchmarks ********************************/
|
||||
|
||||
func BenchmarkUUID(b *testing.B) {
|
||||
|
||||
@@ -22,13 +22,11 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/guardian"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -58,7 +56,6 @@ var (
|
||||
debitPeriod = 10 * time.Second
|
||||
globalRoundingDecimals = 6
|
||||
connMgr *ConnManager
|
||||
schedCdrsConns rpcclient.RpcClientConnection
|
||||
rpSubjectPrefixMatching bool
|
||||
)
|
||||
|
||||
@@ -86,14 +83,6 @@ func SetCdrStorage(cStorage CdrStorage) {
|
||||
cdrStorage = cStorage
|
||||
}
|
||||
|
||||
// SetSchedCdrsConns sets the connection between action and CDRServer
|
||||
func SetSchedCdrsConns(sc rpcclient.ClientConnector) {
|
||||
schedCdrsConns = sc
|
||||
if schedCdrsConns != nil && reflect.ValueOf(schedCdrsConns).IsNil() {
|
||||
schedCdrsConns = nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewCallDescriptorFromCGREvent converts a CGREvent into CallDescriptor
|
||||
func NewCallDescriptorFromCGREvent(cgrEv *utils.CGREvent,
|
||||
timezone string) (cd *CallDescriptor, err error) {
|
||||
|
||||
@@ -26,7 +26,9 @@ import (
|
||||
|
||||
// NewConnManager returns the Connection Manager
|
||||
func NewConnManager(cfg *config.CGRConfig, rpcInternal map[string]chan rpcclient.ClientConnector) (cM *ConnManager) {
|
||||
return &ConnManager{cfg: cfg, rpcInternal: rpcInternal}
|
||||
cM = &ConnManager{cfg: cfg, rpcInternal: rpcInternal}
|
||||
SetConnManager(cM)
|
||||
return
|
||||
}
|
||||
|
||||
//ConnManager handle the RPC connections
|
||||
|
||||
@@ -28,13 +28,6 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// Individual session run
|
||||
type SessionRun struct {
|
||||
RequestType string
|
||||
CallDescriptor *CallDescriptor
|
||||
CallCosts []*CallCost
|
||||
}
|
||||
|
||||
type Responder struct {
|
||||
ExitChan chan bool
|
||||
Timeout time.Duration
|
||||
@@ -55,7 +48,7 @@ func (rs *Responder) usageAllowed(tor string, reqUsage time.Duration) (allowed b
|
||||
}
|
||||
|
||||
/*
|
||||
RPC method thet provides the external RPC interface for getting the rating information.
|
||||
RPC method that provides the external RPC interface for getting the rating information.
|
||||
*/
|
||||
func (rs *Responder) GetCost(arg *CallDescriptorWithArgDispatcher, reply *CallCost) (err error) {
|
||||
// RPC caching
|
||||
|
||||
@@ -68,7 +68,7 @@ type TpReader struct {
|
||||
|
||||
func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string,
|
||||
cacheConns, schedulerConns []string) (*TpReader, error) {
|
||||
var rmtConns, rplConns *rpcclient.RpcClientPool
|
||||
var rmtConns, rplConns *rpcclient.RPCPool
|
||||
if len(config.CgrConfig().DataDbCfg().RmtConns) != 0 {
|
||||
var err error
|
||||
rmtConns, err = NewRPCPool(rpcclient.PoolFirstPositive, config.CgrConfig().TlsCfg().ClientKey,
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewApierV1Service(cfg *config.CGRConfig, dm *DataDBService,
|
||||
server *utils.Server,
|
||||
schedService *SchedulerService,
|
||||
responderService *ResponderService,
|
||||
internalAPIerV1Chan chan rpcclient.RpcClientConnection,
|
||||
internalAPIerV1Chan chan rpcclient.ClientConnector,
|
||||
connMgr *engine.ConnManager) *ApierV1Service {
|
||||
return &ApierV1Service{
|
||||
connChan: internalAPIerV1Chan,
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
// NewApierV2Service returns the ApierV2 Service
|
||||
func NewApierV2Service(apiv1 *ApierV1Service, cfg *config.CGRConfig,
|
||||
server *utils.Server,
|
||||
internalAPIerV1Chan chan rpcclient.RpcClientConnection) *ApierV2Service {
|
||||
internalAPIerV1Chan chan rpcclient.ClientConnector) *ApierV2Service {
|
||||
return &ApierV2Service{
|
||||
apiv1: apiv1,
|
||||
connChan: internalAPIerV1Chan,
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewChargerService returns the Charger Service
|
||||
func NewChargerService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server,
|
||||
internalChargerSChan chan rpcclient.RpcClientConnection, connMgr *engine.ConnManager) servmanager.Service {
|
||||
internalChargerSChan chan rpcclient.ClientConnector, connMgr *engine.ConnManager) servmanager.Service {
|
||||
return &ChargerService{
|
||||
connChan: internalChargerSChan,
|
||||
cfg: cfg,
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewRalService returns the Ral Service
|
||||
func NewRalService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
storDB *StorDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server,
|
||||
internalRALsChan, internalResponderChan, internalAPIerV1Chan, internalAPIerV2Chan chan rpcclient.RpcClientConnection,
|
||||
internalRALsChan, internalResponderChan, internalAPIerV1Chan, internalAPIerV2Chan chan rpcclient.ClientConnector,
|
||||
schedulerService *SchedulerService, exitChan chan bool,
|
||||
connMgr *engine.ConnManager) *RalService {
|
||||
resp := NewResponderService(cfg, server, internalResponderChan, exitChan)
|
||||
@@ -71,7 +71,6 @@ func (rals *RalService) Start() (err error) {
|
||||
if rals.IsRunning() {
|
||||
return fmt.Errorf("service aleady running")
|
||||
}
|
||||
engine.SetConnManager(rals.connMgr)
|
||||
engine.SetRpSubjectPrefixMatching(rals.cfg.RalsCfg().RpSubjectPrefixMatching)
|
||||
rals.Lock()
|
||||
defer rals.Unlock()
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewResourceService returns the Resource Service
|
||||
func NewResourceService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
cacheS *engine.CacheS, filterSChan chan *engine.FilterS,
|
||||
server *utils.Server, internalResourceSChan chan rpcclient.RpcClientConnection,
|
||||
server *utils.Server, internalResourceSChan chan rpcclient.ClientConnector,
|
||||
connMgr *engine.ConnManager) servmanager.Service {
|
||||
return &ResourceService{
|
||||
connChan: internalResourceSChan,
|
||||
@@ -57,7 +57,7 @@ type ResourceService struct {
|
||||
|
||||
reS *engine.ResourceService
|
||||
rpc *v1.ResourceSv1
|
||||
connChan chan rpcclient.RpcClientConnection
|
||||
connChan chan rpcclient.ClientConnector
|
||||
connMgr *engine.ConnManager
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
// NewResponderService returns the Resonder Service
|
||||
func NewResponderService(cfg *config.CGRConfig, server *utils.Server,
|
||||
internalRALsChan chan rpcclient.RpcClientConnection,
|
||||
internalRALsChan chan rpcclient.ClientConnector,
|
||||
exitChan chan bool) *ResponderService {
|
||||
return &ResponderService{
|
||||
connChan: internalRALsChan,
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewSchedulerService returns the Scheduler Service
|
||||
func NewSchedulerService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
cacheS *engine.CacheS, fltrSChan chan *engine.FilterS,
|
||||
server *utils.Server, internalSchedulerrSChan chan rpcclient.RpcClientConnection,
|
||||
server *utils.Server, internalSchedulerrSChan chan rpcclient.ClientConnector,
|
||||
connMgr *engine.ConnManager) *SchedulerService {
|
||||
return &SchedulerService{
|
||||
connChan: internalSchedulerrSChan,
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewStatService returns the Stat Service
|
||||
func NewStatService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
cacheS *engine.CacheS, filterSChan chan *engine.FilterS,
|
||||
server *utils.Server, internalStatSChan chan rpcclient.RpcClientConnection, connMgr *engine.ConnManager) servmanager.Service {
|
||||
server *utils.Server, internalStatSChan chan rpcclient.ClientConnector, connMgr *engine.ConnManager) servmanager.Service {
|
||||
return &StatService{
|
||||
connChan: internalStatSChan,
|
||||
cfg: cfg,
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewSupplierService returns the Supplier Service
|
||||
func NewSupplierService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
cacheS *engine.CacheS, filterSChan chan *engine.FilterS,
|
||||
server *utils.Server, internalSupplierSChan chan rpcclient.RpcClientConnection,
|
||||
server *utils.Server, internalSupplierSChan chan rpcclient.ClientConnector,
|
||||
connMgr *engine.ConnManager) servmanager.Service {
|
||||
return &SupplierService{
|
||||
connChan: internalSupplierSChan,
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// NewThresholdService returns the Threshold Service
|
||||
func NewThresholdService(cfg *config.CGRConfig, dm *DataDBService,
|
||||
cacheS *engine.CacheS, filterSChan chan *engine.FilterS,
|
||||
server *utils.Server, internalThresholdSChan chan rpcclient.RpcClientConnection) servmanager.Service {
|
||||
server *utils.Server, internalThresholdSChan chan rpcclient.ClientConnector) servmanager.Service {
|
||||
return &ThresholdService{
|
||||
connChan: internalThresholdSChan,
|
||||
cfg: cfg,
|
||||
|
||||
Reference in New Issue
Block a user