Add EEs APIs to dispatchers + tests

This commit is contained in:
ionutboangiu
2022-10-14 13:14:46 +03:00
committed by Dan Christian Bogos
parent c8b7833fc0
commit c2e847018a
14 changed files with 898 additions and 577 deletions

View File

@@ -953,6 +953,23 @@ func (dS *DispatcherCoreSv1) Panic(args *utils.PanicMessageArgs, reply *string)
return dS.dS.CoreSv1Panic(args, reply)
}
// DispatcherCoreSv1 exports RPC from CoreSv1
type DispatcherEeSv1 struct {
dS *dispatchers.DispatcherService
}
func NewDispatcherEeSv1(dps *dispatchers.DispatcherService) *DispatcherEeSv1 {
return &DispatcherEeSv1{dS: dps}
}
func (dS *DispatcherEeSv1) Ping(args *utils.CGREvent, reply *string) error {
return dS.dS.EeSv1Ping(args, reply)
}
func (dS *DispatcherEeSv1) ProcessEvent(args *engine.CGREventWithEeIDs, reply *map[string]map[string]interface{}) error {
return dS.dS.EeSv1ProcessEvent(args, reply)
}
type DispatcherReplicatorSv1 struct {
dS *dispatchers.DispatcherService
}

View File

@@ -1,98 +1,93 @@
{
// CGRateS Configuration file
//
"general": {
"node_id": "ALL",
"log_level": 7
},
"listen": {
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "redis", // data_db type: <redis|mongo>
"db_port": 6379, // data_db port to reach the database
"db_name": "11", // data_db database name to connect to
},
"stor_db": {
"db_password": "CGRateS.org",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}],
"general": {
"node_id": "ALL",
"log_level": 7
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
"listen": {
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080"
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "11"
},
"stor_db": {
"db_password": "CGRateS.org"
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}]
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true
},
"schedulers": {
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"]
},
"thresholds": {
"enabled": true
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true
},
"resources": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"]
},
"sessions": {
"enabled": true,
"listen_bijson": ":6014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"chargers_conns": ["*internal"],
"cdrs_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true,
},
"resources": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"listen_bijson": ":6014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"chargers_conns": ["*internal"],
"cdrs_conns": ["*internal"],
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"],
},
}

View File

@@ -1,93 +1,88 @@
{
// CGRateS Configuration file
//
"general": {
"node_id": "ALL2",
"log_level": 7
},
"listen": {
"rpc_json": ":7012",
"rpc_gob": ":7013",
"http": ":7080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "redis", // data_db type: <redis|mongo>
"db_port": 6379, // data_db port to reach the database
"db_name": "12", // data_db database name to connect to
},
"stor_db": {
"db_type":"*internal",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
"general": {
"node_id": "ALL2",
"log_level": 7
},
},
"attributes": {
"enabled": true
},
"listen": {
"rpc_json": ":7012",
"rpc_gob": ":7013",
"http": ":7080"
},
"rals": {
"enabled": true,
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "12"
},
"schedulers": {
"enabled": true,
},
"stor_db": {
"db_type":"*internal"
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
}
},
"thresholds": {
"enabled": true,
},
"attributes": {
"enabled": true
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"],
},
"rals": {
"enabled": true
},
"stats": {
"enabled": true,
},
"schedulers": {
"enabled": true
},
"resources": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"]
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"],
},
"thresholds": {
"enabled": true
},
"sessions": {
"enabled": true,
"listen_bijson": ":7014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"],
},
"stats": {
"enabled": true
},
"resources": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"]
},
"sessions": {
"enabled": true,
"listen_bijson": ":7014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"]
}
}

View File

@@ -1,97 +1,95 @@
{
// CGRateS Configuration file
//
"general": {
"node_id": "ALL2",
"log_level": 7
},
"listen": {
"rpc_json": ":7012",
"rpc_gob": ":7013",
"http": ":7080",
},
"data_db": {
"db_type": "mongo",
"db_name": "12",
"db_port": 27017,
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
"general": {
"node_id": "ALL2",
"log_level": 7
},
},
"attributes": {
"enabled": true
},
"listen": {
"rpc_json": ":7012",
"rpc_gob": ":7013",
"http": ":7080"
},
"rals": {
"enabled": true,
},
"data_db": {
"db_type": "mongo",
"db_name": "12",
"db_port": 27017
},
"schedulers": {
"enabled": true,
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
}
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"],
},
"attributes": {
"enabled": true
},
"stats": {
"enabled": true,
},
"rals": {
"enabled": true
},
"resources": {
"enabled": true,
},
"schedulers": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"],
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"]
},
"sessions": {
"enabled": true,
"listen_bijson": ":7014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
},
"thresholds": {
"enabled": true
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"],
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true
},
"resources": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"]
},
"ees": {
"enabled": true
},
"sessions": {
"enabled": true,
"listen_bijson": ":7014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"]
}
}

View File

@@ -1,95 +1,94 @@
{
// CGRateS Configuration file
//
"general": {
"node_id": "ALL2",
"log_level": 7
},
"listen": {
"rpc_json": ":7012",
"rpc_gob": ":7013",
"http": ":7080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "redis", // data_db type: <redis|mongo>
"db_port": 6379, // data_db port to reach the database
"db_name": "12", // data_db database name to connect to
},
"stor_db": {
"db_type":"*internal",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
"general": {
"node_id": "ALL2",
"log_level": 7
},
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"],
},
"stats": {
"enabled": true,
},
"resources": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"],
},
"listen": {
"rpc_json": ":7012",
"rpc_gob": ":7013",
"http": ":7080"
},
"sessions": {
"enabled": true,
"listen_bijson": ":7014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "12"
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"],
},
"stor_db": {
"db_type":"*internal"
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true
},
"schedulers": {
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"]
},
"thresholds": {
"enabled": true
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true
},
"resources": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"]
},
"ees": {
"enabled": true
},
"sessions": {
"enabled": true,
"listen_bijson": ":7014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"]
}
}

View File

@@ -1,100 +1,115 @@
{
// CGRateS Configuration file
//
"general": {
"node_id": "ALL",
"log_level": 7
},
"listen": {
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080",
},
"data_db": {
"db_type": "mongo",
"db_name": "11",
"db_port": 27017,
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}],
"general": {
"node_id": "ALL",
"log_level": 7
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
"listen": {
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080"
},
"data_db": {
"db_type": "mongo",
"db_name": "11",
"db_port": 27017
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}]
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true
},
"schedulers": {
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"]
},
"thresholds": {
"enabled": true
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true
},
"resources": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"]
},
"ees": {
"enabled": true,
"exporters": [
{
"id": "*default",
"type": "*rpc",
"opts": {
"rpcCodec": "*json",
"connIDs": ["rplConn"],
"serviceMethod": "CoreSv1.Status",
"keyPath": "" ,
"certPath": "",
"caPath": "",
"tls": false,
"rpcConnTimeout" : "1s",
"rpcReplyTimeout":"5s"
}
}
]
},
"sessions": {
"enabled": true,
"listen_bijson": ":6014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"chargers_conns": ["*internal"],
"cdrs_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true,
},
"resources": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"listen_bijson": ":6014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"chargers_conns": ["*internal"],
"cdrs_conns": ["*internal"],
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"],
},
}

View File

@@ -1,98 +1,116 @@
{
// CGRateS Configuration file
//
"general": {
"node_id": "ALL",
"log_level": 7
},
"listen": {
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "redis", // data_db type: <redis|mongo>
"db_port": 6379, // data_db port to reach the database
"db_name": "11", // data_db database name to connect to
},
"stor_db": {
"db_password": "CGRateS.org",
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}],
"general": {
"node_id": "ALL",
"log_level": 7
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}],
"listen": {
"rpc_json": ":6012",
"rpc_gob": ":6013",
"http": ":6080"
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "11"
},
"stor_db": {
"db_password": "CGRateS.org"
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:6012", "transport":"*json"}]
},
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true
},
"schedulers": {
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"]
},
"thresholds": {
"enabled": true
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"]
},
"stats": {
"enabled": true
},
"resources": {
"enabled": true
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"]
},
"ees": {
"enabled": true,
"exporters": [
{
"id": "*default",
"type": "*rpc",
"opts": {
"rpcCodec": "*json",
"connIDs": ["rplConn"],
"serviceMethod": "CoreSv1.Status",
"keyPath": "" ,
"certPath": "",
"caPath": "",
"tls": false,
"rpcConnTimeout" : "1s",
"rpcReplyTimeout":"5s"
}
}
]
},
"sessions": {
"enabled": true,
"listen_bijson": ":6014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"chargers_conns": ["*internal"],
"cdrs_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"]
}
},
"attributes": {
"enabled": true
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"thresholds": {
"enabled": true,
},
"routes": {
"enabled": true,
"rals_conns": ["*internal"],
},
"stats": {
"enabled": true,
},
"resources": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"listen_bijson": ":6014",
"routes_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
"rals_conns": ["*internal"],
"chargers_conns": ["*internal"],
"cdrs_conns": ["*internal"],
},
"apiers": {
"enabled": true,
"caches_conns":["conn1"],
"scheduler_conns": ["*internal"],
},
}

View File

@@ -1,67 +1,60 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
//
// This file contains the default configuration hardcoded into CGRateS.
// This is what you get when you load CGRateS with an empty configuration file.
"general": {
"node_id": "DispatcherS1",
"log_level": 7,
"reconnects": 1,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"stor_db": {
"db_type":"*internal",
},
"caches":{
"partitions": {
"*dispatcher_routes": {"limit": -1, "ttl": "2s"}
"general": {
"node_id": "DispatcherS1",
"log_level": 7,
"reconnects": 1
},
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080"
},
"attributes": {
"enabled": true
},
"stor_db": {
"db_type":"*internal"
},
"schedulers": {
"enabled": true,
},
"caches":{
"partitions": {
"*dispatcher_routes": {"limit": -1, "ttl": "2s"}
}
},
"rals": {
"enabled": true,
},
"attributes": {
"enabled": true
},
"chargers": {
"enabled": true,
},
"schedulers": {
"enabled": true
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"chargers_conns": ["*localhost"],
"listen_bijson": ":3014",
},
"rals": {
"enabled": true
},
"dispatchers":{
"enabled": true,
"attributes_conns": ["*internal"],
},
"chargers": {
"enabled": true
},
"sessions": {
"enabled": true,
"attributes_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"chargers_conns": ["*localhost"],
"listen_bijson": ":3014"
},
"dispatchers":{
"enabled": true,
"attributes_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"scheduler_conns": ["*internal"]
}
"apiers": {
"enabled": true,
"scheduler_conns": ["*internal"],
},
}

View File

@@ -25,4 +25,5 @@ cgrates.org,ATTR_API_CDRSV2,*auth,*string:~*req.ApiKey:cdrsv212345,,,*req.APIMet
cgrates.org,ATTR_API_RATES_AUTH,*auth,*string:~*req.ApiKey:rPrf12345,,,*req.APIMethods,*constant,RateSv1.Ping&RateSv1.CostForEvent,false,20
cgrates.org,ATTR_API_CORE_AUTH,*auth,*string:~*req.ApiKey:core12345,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep&CoreSv1.StartCPUProfiling&CoreSv1.StopCPUProfiling&CoreSv1.StartMemoryProfiling&CoreSv1.StopMemoryProfiling,false,20
cgrates.org,ATTR_API_ACTIONS_AUTH,*auth,*string:~*req.ApiKey:actPrf12345,,,*req.APIMethods,*constant,ActionSv1.Ping,false,20
cgrates.org,ATTR_API_ACCOUNTS_AUTH,*auth,*string:~*req.ApiKey:accPrf12345,,,*req.APIMethods,*constant,AccountSv1.Ping,false,20
cgrates.org,ATTR_API_ACCOUNTS_AUTH,*auth,*string:~*req.ApiKey:accPrf12345,,,*req.APIMethods,*constant,AccountSv1.Ping,false,20
cgrates.org,ATTR_API_EES_AUTH,*auth,*string:~*req.ApiKey:ees12345,,,*req.APIMethods,*constant,EeSv1.Ping&EeSv1.ProcessEvent,false,20
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs Path Type Value Blocker Weight
25 cgrates.org ATTR_API_RATES_AUTH *auth *string:~*req.ApiKey:rPrf12345 *req.APIMethods *constant RateSv1.Ping&RateSv1.CostForEvent false 20
26 cgrates.org ATTR_API_CORE_AUTH *auth *string:~*req.ApiKey:core12345 *req.APIMethods *constant CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep&CoreSv1.StartCPUProfiling&CoreSv1.StopCPUProfiling&CoreSv1.StartMemoryProfiling&CoreSv1.StopMemoryProfiling false 20
27 cgrates.org ATTR_API_ACTIONS_AUTH *auth *string:~*req.ApiKey:actPrf12345 *req.APIMethods *constant ActionSv1.Ping false 20
28 cgrates.org ATTR_API_ACCOUNTS_AUTH *auth *string:~*req.ApiKey:accPrf12345 *req.APIMethods *constant AccountSv1.Ping false 20
29 cgrates.org ATTR_API_EES_AUTH *auth *string:~*req.ApiKey:ees12345 *req.APIMethods *constant EeSv1.Ping&EeSv1.ProcessEvent false 20

View File

@@ -26,3 +26,4 @@ cgrates.org,ATTR_API_RATES_AUTH,*auth,*string:~*req.ApiKey:rPrf12345,,,*req.APIM
cgrates.org,ATTR_API_CORE_AUTH,*auth,*string:~*req.ApiKey:core12345,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep,false,20
cgrates.org,ATTR_API_ACTIONS_AUTH,*auth,*string:~*req.ApiKey:actPrf12345,,,*req.APIMethods,*constant,ActionSv1.Ping,false,20
cgrates.org,ATTR_API_ACCOUNTS_AUTH,*auth,*string:~*req.ApiKey:accPrf12345,,,*req.APIMethods,*constant,AccountSv1.Ping,false,20
cgrates.org,ATTR_API_EES_AUTH,*auth,*string:~*req.ApiKey:ees12345,,,*req.APIMethods,*constant,EeSv1.Ping&EeSv1.ProcessEvent,false,20
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs Path Type Value Blocker Weight
26 cgrates.org ATTR_API_CORE_AUTH *auth *string:~*req.ApiKey:core12345 *req.APIMethods *constant CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep false 20
27 cgrates.org ATTR_API_ACTIONS_AUTH *auth *string:~*req.ApiKey:actPrf12345 *req.APIMethods *constant ActionSv1.Ping false 20
28 cgrates.org ATTR_API_ACCOUNTS_AUTH *auth *string:~*req.ApiKey:accPrf12345 *req.APIMethods *constant AccountSv1.Ping false 20
29 cgrates.org ATTR_API_EES_AUTH *auth *string:~*req.ApiKey:ees12345 *req.APIMethods *constant EeSv1.Ping&EeSv1.ProcessEvent false 20

70
dispatchers/ees.go Normal file
View File

@@ -0,0 +1,70 @@
/*
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 dispatchers
import (
"time"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func (dS *DispatcherService) EeSv1Ping(args *utils.CGREvent, reply *string) (err error) {
tnt := dS.cfg.GeneralCfg().DefaultTenant
if args != nil && len(args.Tenant) != 0 {
tnt = args.Tenant
}
ev := make(map[string]interface{})
if args != nil {
ev = args.Event
}
opts := make(map[string]interface{})
if args != nil {
opts = args.APIOpts
}
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
if err = dS.authorize(utils.EeSv1Ping, tnt,
utils.IfaceAsString(opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
return
}
}
return dS.Dispatch(&utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.EeSv1Ping, args, reply)
}
func (dS *DispatcherService) EeSv1ProcessEvent(args *engine.CGREventWithEeIDs, reply *map[string]map[string]interface{}) (err error) {
tnt := dS.cfg.GeneralCfg().DefaultTenant
if args != nil && len(args.Tenant) != 0 {
tnt = args.Tenant
}
ev := make(map[string]interface{})
if args != nil {
ev = args.Event
}
opts := make(map[string]interface{})
if args != nil {
opts = args.APIOpts
}
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
if err = dS.authorize(utils.EeSv1ProcessEvent, tnt,
utils.IfaceAsString(opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
return
}
}
return dS.Dispatch(&utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.EeSv1ProcessEvent, args, reply)
}

216
dispatchers/ees_it_test.go Normal file
View File

@@ -0,0 +1,216 @@
//go:build integration
// +build integration
/*
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 dispatchers
import (
"testing"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
var sTestsDspEEs = []func(t *testing.T){
testDspEEsPingFailover,
testDspEEsProcessEventFailover,
testDspEEsProcessEventRoundRobin,
testDspEEsPing,
testDspEEsTestAuthKey,
testDspEEsTestAuthKey2,
}
func TestDspEEsIT(t *testing.T) {
var config1, config2, config3 string
switch *dbType {
case utils.MetaInternal:
t.SkipNow()
case utils.MetaMySQL:
config1 = "all_mysql"
config2 = "all2_mysql"
config3 = "dispatchers_mysql"
case utils.MetaMongo:
config1 = "all_mongo"
config2 = "all2_mongo"
config3 = "dispatchers_mongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
dispDIR := "dispatchers"
if *encoding == utils.MetaGOB {
dispDIR += "_gob"
}
testDsp(t, sTestsDspEEs, "TestDspEEs", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
}
func testDspEEsPingFailover(t *testing.T) {
var reply string
if err := allEngine.RPC.Call(utils.EeSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Unexpected reply: %s", reply)
}
ev := &utils.CGREvent{
Tenant: "cgrates.org",
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "ees12345",
},
}
if err := dispEngine.RPC.Call(utils.EeSv1Ping, ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Unexpected reply: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RPC.Call(utils.EeSv1Ping, ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Unexpected reply: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RPC.Call(utils.EeSv1Ping, ev, &reply); err == nil {
t.Errorf("Expected error but received %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
allEngine2.startEngine(t)
}
func testDspEEsProcessEventFailover(t *testing.T) {
args := &engine.CGREventWithEeIDs{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
ID: "event1",
Event: map[string]interface{}{
utils.EventName: "Event1",
utils.AccountField: "1001",
},
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "ees12345",
},
},
}
var reply map[string]map[string]interface{}
if err := dispEngine.RPC.Call(utils.EeSv1ProcessEvent, args, &reply); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
}
allEngine2.stopEngine(t)
if err := dispEngine.RPC.Call(utils.EeSv1ProcessEvent,
args, &reply); err != nil {
t.Fatal(err)
}
allEngine2.startEngine(t)
}
func testDspEEsPing(t *testing.T) {
var reply string
if err := allEngine.RPC.Call(utils.EeSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RPC.Call(utils.EeSv1Ping, &utils.CGREvent{
Tenant: "cgrates.org",
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "ees12345",
},
}, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
}
func testDspEEsTestAuthKey(t *testing.T) {
args := &engine.CGREventWithEeIDs{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
ID: "event1",
Event: map[string]interface{}{
utils.AccountField: "1001",
},
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "12345",
},
},
}
var reply map[string]map[string]interface{}
if err := dispEngine.RPC.Call(utils.EeSv1ProcessEvent,
args, &reply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Errorf("expected: <%+v>,\nreceived: <%+v>", utils.ErrUnauthorizedApi.Error(), err)
}
}
func testDspEEsTestAuthKey2(t *testing.T) {
args := &engine.CGREventWithEeIDs{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
ID: "event1",
Event: map[string]interface{}{
utils.AccountField: "1001",
},
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "ees12345",
},
},
}
var reply map[string]map[string]interface{}
if err := dispEngine.RPC.Call(utils.EeSv1ProcessEvent,
args, &reply); err != nil {
t.Error(err)
} else if _, ok := reply[utils.MetaDefault]; !ok {
t.Error("expected to match the *default exporter")
}
}
func testDspEEsProcessEventRoundRobin(t *testing.T) {
args := &engine.CGREventWithEeIDs{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
ID: "event1",
Event: map[string]interface{}{
utils.EventName: "RoundRobin",
utils.AccountField: "1001",
},
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "ees12345",
},
},
}
var reply map[string]map[string]interface{}
// To ALL2
if err := dispEngine.RPC.Call(utils.EeSv1ProcessEvent,
args, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
}
// To ALL
if err := dispEngine.RPC.Call(utils.EeSv1ProcessEvent,
args, &reply); err != nil {
t.Error(err)
} else if _, ok := reply[utils.MetaDefault]; !ok {
t.Error("expected to match the *default exporter")
}
}

View File

@@ -64,7 +64,7 @@ type testDispatcher struct {
cmd *exec.Cmd
}
func newTestEngine(t *testing.T, cfgPath string, initDataDB, intitStoreDB bool) (d *testDispatcher) {
func newTestEngine(t *testing.T, cfgPath string, initDataDB, initStoreDB bool) (d *testDispatcher) {
d = new(testDispatcher)
d.CfgPath = cfgPath
var err error
@@ -78,7 +78,7 @@ func newTestEngine(t *testing.T, cfgPath string, initDataDB, intitStoreDB bool)
d.initDataDb(t)
}
if intitStoreDB {
if initStoreDB {
d.resetStorDb(t)
}
d.startEngine(t)

View File

@@ -118,6 +118,9 @@ func (dspS *DispatcherService) Start() (err error) {
dspS.server.RpcRegisterName(utils.CoreSv1,
v1.NewDispatcherCoreSv1(dspS.dspS))
dspS.server.RpcRegisterName(utils.EeSv1,
v1.NewDispatcherEeSv1(dspS.dspS))
dspS.server.RpcRegisterName(utils.Responder,
v1.NewDispatcherResponder(dspS.dspS))