Added *ec field to ees as DataProvider

This commit is contained in:
porosnicuadrian
2022-02-22 16:51:10 +02:00
committed by Dan Christian Bogos
parent 46eccb6542
commit 8941b1ef0d
17 changed files with 247 additions and 52 deletions

View File

@@ -1899,7 +1899,7 @@ func (apierSv1 *APIerSv1) ExportCDRs(args *utils.ArgExportCDRs, reply *map[strin
withErros := false
var rplyCdr map[string]map[string]interface{}
for _, cdr := range cdrs {
argCdr := &utils.CGREventWithEeIDs{
argCdr := &engine.CGREventWithEeIDs{
EeIDs: args.ExporterIDs,
CGREvent: cdr.AsCGREvent(),
}

View File

@@ -20,6 +20,7 @@ package v1
import (
"github.com/cgrates/cgrates/ees"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -37,7 +38,7 @@ func (eeSv1 *EeSv1) Ping(ign *utils.CGREvent, reply *string) error {
}
// ProcessEvent triggers exports on EEs side
func (eeSv1 *EeSv1) ProcessEvent(args *utils.CGREventWithEeIDs,
func (eeSv1 *EeSv1) ProcessEvent(args *engine.CGREventWithEeIDs,
reply *map[string]map[string]interface{}) error {
return eeSv1.eeS.V1ProcessEvent(args, reply)
}

View File

@@ -80,7 +80,7 @@
"attempts": 1,
"field_separator": ",",
"fields":[
{"tag": "Number", "path": "*hdr.Number", "type": "*constant", "value": "NumberOfEvent"},
{"tag": "Number", "path": "*hdr.Number", "type": "*constant", "value": "NumberOfEvent"},
{"tag": "CGRID", "path": "*hdr.CGRID", "type": "*constant", "value": "CGRID"},
{"tag": "RunID", "path": "*hdr.RunID", "type": "*constant", "value": "RunID"},
{"tag": "ToR", "path": "*hdr.ToR", "type": "*constant", "value": "ToR"},
@@ -94,7 +94,9 @@
{"tag": "SetupTime", "path": "*hdr.SetupTime", "type": "*constant", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "AnswerTime", "path": "*hdr.AnswerTime", "type": "*constant", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "Usage", "path": "*hdr.Usage", "type": "*constant", "value": "Usage"},
{"tag": "Cost", "path": "*hdr.Cost", "type": "*constant", "value": "Cost"},
{"tag": "Cost", "path": "*hdr.Cost", "type": "*constant", "value": "Cost"},
{"tag": "RatingPlan", "path": "*hdr.RatingPlan", "type": "*constant", "value": "RatingPlan"},
{"tag": "RatingPlanSubject", "path": "*hdr.RatingPlanSubject", "type": "*constant", "value": "RatingPlanSubject"},
{"tag": "Number", "path": "*exp.Number", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "CGRID", "path": "*exp.CGRID", "type": "*variable", "value": "~*req.CGRID"},
@@ -112,6 +114,8 @@
{"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage"},
{"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:4}"},
{"tag": "RatingPlan", "path": "*exp.RatingPlan", "type": "*variable", "value": "~*ec.EventCost.Charges[0].Rating.RatingFilter.RatingPlanID"},
{"tag": "RatingPlanSubject", "path": "*exp.RatingPlanSubject", "type": "*variable", "value": "~*ec.EventCost.Charges[0].Rating.RatingFilter.Subject"},
{"tag": "NumberOfEvents", "path": "*trl.NumberOfEvents", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "TotalDuration", "path": "*trl.TotalDuration", "type": "*variable", "value": "~*dc.TotalDuration"},

View File

@@ -122,7 +122,7 @@ func (eeS *EventExporterS) attrSProcessEvent(cgrEv *utils.CGREvent, attrIDs []st
// V1ProcessEvent will be called each time a new event is received from readers
// rply -> map[string]map[string]interface{}
func (eeS *EventExporterS) V1ProcessEvent(cgrEv *utils.CGREventWithEeIDs, rply *map[string]map[string]interface{}) (err error) {
func (eeS *EventExporterS) V1ProcessEvent(cgrEv *engine.CGREventWithEeIDs, rply *map[string]map[string]interface{}) (err error) {
eeS.cfg.RLocks(config.EEsJson)
defer eeS.cfg.RUnlocks(config.EEsJson)
@@ -270,6 +270,7 @@ func exportEventWithExporter(exp EventExporter, ev *utils.CGREvent, oneTime bool
utils.MetaDC: exp.GetMetrics(),
utils.MetaOpts: utils.MapStorage(ev.APIOpts),
utils.MetaCfg: cfg.GetDataProvider(),
utils.MetaEC: utils.MapStorage{utils.EventCost: ev.Event[utils.EventCost]},
}, utils.FirstNonEmpty(ev.Tenant, cfg.GeneralCfg().DefaultTenant),
filterS,
map[string]*utils.OrderedNavigableMap{utils.MetaExp: expNM}).SetFields(exp.Cfg().ContentFields())

View File

@@ -173,7 +173,7 @@ func TestV1ProcessEvent(t *testing.T) {
newDM := engine.NewDataManager(newIDb, cfg.CacheCfg(), nil)
filterS := engine.NewFilterS(cfg, nil, newDM)
eeS := NewEventExporterS(cfg, filterS, nil)
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -223,7 +223,7 @@ func TestV1ProcessEvent2(t *testing.T) {
newDM := engine.NewDataManager(newIDb, cfg.CacheCfg(), nil)
filterS := engine.NewFilterS(cfg, nil, newDM)
eeS := NewEventExporterS(cfg, filterS, nil)
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -263,7 +263,7 @@ func TestV1ProcessEvent3(t *testing.T) {
newDM := engine.NewDataManager(newIDb, cfg.CacheCfg(), nil)
filterS := engine.NewFilterS(cfg, nil, newDM)
eeS := NewEventExporterS(cfg, filterS, nil)
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -297,7 +297,7 @@ func TestV1ProcessEvent4(t *testing.T) {
t.Error(err)
}
eeS.eesChs[utils.MetaHTTPPost].Set("SQLExporterFull", newEeS, []string{"grp1"})
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -359,7 +359,7 @@ func TestV1ProcessEventMockMetrics(t *testing.T) {
time.Second, false, onCacheEvicted),
}
eeS.eesChs[utils.MetaHTTPPost].Set("SQLExporterFull", mEe, []string{"grp1"})
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -388,7 +388,7 @@ func TestV1ProcessEvent5(t *testing.T) {
Type: "invalid_type",
},
}
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -419,7 +419,7 @@ func TestV1ProcessEvent6(t *testing.T) {
newDM := engine.NewDataManager(newIDb, cfg.CacheCfg(), nil)
filterS := engine.NewFilterS(cfg, nil, newDM)
eeS := NewEventExporterS(cfg, filterS, nil)
cgrEv := &utils.CGREventWithEeIDs{
cgrEv := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -119,7 +119,7 @@ func testElasticStartElasticsearch(t *testing.T) {
}
func testElasticExportEvents(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"ElasticsearchExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -147,7 +147,7 @@ func testElasticExportEvents(t *testing.T) {
},
}
eventData := &utils.CGREventWithEeIDs{
eventData := &engine.CGREventWithEeIDs{
EeIDs: []string{"ElasticsearchExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -175,7 +175,7 @@ func testElasticExportEvents(t *testing.T) {
},
}
eventSMS := &utils.CGREventWithEeIDs{
eventSMS := &engine.CGREventWithEeIDs{
EeIDs: []string{"ElasticsearchExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -203,7 +203,7 @@ func testElasticExportEvents(t *testing.T) {
},
}
eventSMSNoFields := &utils.CGREventWithEeIDs{
eventSMSNoFields := &engine.CGREventWithEeIDs{
EeIDs: []string{"ElasticExporterWithNoFields"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -106,7 +106,7 @@ func testCsvRPCConn(t *testing.T) {
}
func testCsvExportEvent(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -132,7 +132,7 @@ func testCsvExportEvent(t *testing.T) {
},
}
eventData := &utils.CGREventWithEeIDs{
eventData := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -158,7 +158,7 @@ func testCsvExportEvent(t *testing.T) {
},
}
eventSMS := &utils.CGREventWithEeIDs{
eventSMS := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -225,7 +225,133 @@ func testCsvVerifyExports(t *testing.T) {
}
func testCsvExportComposedEvent(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
cd := &engine.EventCost{
Cost: utils.Float64Pointer(0.264933),
CGRID: "d8534def2b7067f4f5ad4f7ec7bbcc94bb46111a",
Rates: engine.ChargedRates{
"3db483c": engine.RateGroups{
{
Value: 0.1574,
RateUnit: 60000000000,
RateIncrement: 30000000000,
GroupIntervalStart: 0,
},
{
Value: 0.1574,
RateUnit: 60000000000,
RateIncrement: 1000000000,
GroupIntervalStart: 30000000000,
},
},
},
RunID: "*default",
Usage: utils.DurationPointer(101 * time.Second),
Rating: engine.Rating{
"7f3d423": &engine.RatingUnit{
MaxCost: 40,
RatesID: "3db483c",
TimingID: "128e970",
ConnectFee: 0,
RoundingMethod: "*up",
MaxCostStrategy: "*disconnect",
RatingFiltersID: "f8e95f2",
RoundingDecimals: 4,
},
},
Charges: []*engine.ChargingInterval{
{
RatingID: "7f3d423",
Increments: []*engine.ChargingIncrement{
{
Cost: 0.0787,
Usage: 30000000000,
AccountingID: "fee8a3a",
CompressFactor: 1,
},
},
CompressFactor: 1,
},
{
RatingID: "7f3d423",
Increments: []*engine.ChargingIncrement{
{
Cost: 0.002623,
Usage: 1000000000,
AccountingID: "3463957",
CompressFactor: 71,
},
},
CompressFactor: 1,
},
},
Timings: engine.ChargedTimings{
"128e970": &engine.ChargedTiming{
StartTime: "00:00:00",
},
},
StartTime: time.Date(2019, 12, 06, 11, 57, 32, 0, time.UTC),
Accounting: engine.Accounting{
"3463957": &engine.BalanceCharge{
Units: 0.002623,
RatingID: "",
AccountID: "cgrates.org:1001",
BalanceUUID: "154419f2-45e0-4629-a203-06034ccb493f",
ExtraChargeID: "",
},
"fee8a3a": &engine.BalanceCharge{
Units: 0.0787,
RatingID: "",
AccountID: "cgrates.org:1001",
BalanceUUID: "154419f2-45e0-4629-a203-06034ccb493f",
ExtraChargeID: "",
},
},
RatingFilters: engine.RatingFilters{
"f8e95f2": engine.RatingMatchedFilters{
"Subject": "*out:cgrates.org:mo_call_UK_Mobile_O2_GBRCN:*any",
"RatingPlanID": "RP_MO_CALL_44800",
"DestinationID": "DST_44800",
"DestinationPrefix": "44800",
},
},
AccountSummary: &engine.AccountSummary{
ID: "234189200129930",
Tenant: "cgrates.org",
Disabled: false,
AllowNegative: false,
BalanceSummaries: engine.BalanceSummaries{
&engine.BalanceSummary{
ID: "MOBILE_DATA",
Type: "*data",
UUID: "08a05723-5849-41b9-b6a9-8ee362539280",
Value: 3221225472,
Disabled: false,
},
&engine.BalanceSummary{
ID: "MOBILE_SMS",
Type: "*sms",
UUID: "06a87f20-3774-4eeb-826e-a79c5f175fd3",
Value: 247,
Disabled: false,
},
&engine.BalanceSummary{
ID: "MOBILE_VOICE",
Type: "*voice",
UUID: "4ad16621-6e22-4e35-958e-5e1ff93ad7b7",
Value: 14270000000000,
Disabled: false,
},
&engine.BalanceSummary{
ID: "MONETARY_POSTPAID",
Type: "*monetary",
UUID: "154419f2-45e0-4629-a203-06034ccb493f",
Value: 50,
Disabled: false,
},
},
},
}
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporterComposed"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -250,11 +376,11 @@ func testCsvExportComposedEvent(t *testing.T) {
utils.Cost: 1.016374,
"ExtraFields": map[string]string{"extra1": "val_extra1",
"extra2": "val_extra2", "extra3": "val_extra3"},
"EventCost": cd,
},
},
}
eventSMS := &utils.CGREventWithEeIDs{
eventSMS := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporterComposed"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -279,6 +405,7 @@ func testCsvExportComposedEvent(t *testing.T) {
utils.Cost: 0.155462,
"ExtraFields": map[string]string{"extra1": "val_extra1",
"extra2": "val_extra2", "extra3": "val_extra3"},
"EventCost": cd,
},
},
}
@@ -306,9 +433,9 @@ func testCsvVerifyComposedExports(t *testing.T) {
if len(files) != 1 {
t.Errorf("Expected %+v, received: %+v", 1, len(files))
}
eCnt := "NumberOfEvent,CGRID,RunID,ToR,OriginID,RequestType,Tenant,Category,Account,Subject,Destination,SetupTime,AnswerTime,Usage,Cost" + "\n" +
"1,dbafe9c8614c785a65aabd116dd3959c3c56f7f6,*default,*voice,dsafdsaf,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,10000000000,1.0164" + "\n" +
"2,2478e9f18ebcd3c684f3c14596b8bfeab2b0d6d4,*default,*sms,sdfwer,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,1,0.1555" + "\n" +
eCnt := "NumberOfEvent,CGRID,RunID,ToR,OriginID,RequestType,Tenant,Category,Account,Subject,Destination,SetupTime,AnswerTime,Usage,Cost,RatingPlan,RatingPlanSubject" + "\n" +
"1,dbafe9c8614c785a65aabd116dd3959c3c56f7f6,*default,*voice,dsafdsaf,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,10000000000,1.0164,RP_MO_CALL_44800,*out:cgrates.org:mo_call_UK_Mobile_O2_GBRCN:*any" + "\n" +
"2,2478e9f18ebcd3c684f3c14596b8bfeab2b0d6d4,*default,*sms,sdfwer,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,1,0.1555,RP_MO_CALL_44800,*out:cgrates.org:mo_call_UK_Mobile_O2_GBRCN:*any" + "\n" +
"2,10s,1ns,1.1718" + "\n"
if outContent1, err := os.ReadFile(files[0]); err != nil {
t.Error(err)
@@ -327,7 +454,7 @@ func testCsvExportMaskedDestination(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVMaskedDestination"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -382,7 +509,7 @@ func testCsvVerifyMaskedDestination(t *testing.T) {
}
func testCsvExportEventWithInflateTemplate(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporterWIthTemplate"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -410,7 +537,7 @@ func testCsvExportEventWithInflateTemplate(t *testing.T) {
},
}
eventData := &utils.CGREventWithEeIDs{
eventData := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporterWIthTemplate"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -438,7 +565,7 @@ func testCsvExportEventWithInflateTemplate(t *testing.T) {
},
}
eventSMS := &utils.CGREventWithEeIDs{
eventSMS := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporterWIthTemplate"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -506,7 +633,7 @@ func testCsvVerifyExportsWithInflateTemplate(t *testing.T) {
}
func testCsvExportNotFoundExporter(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"ExporterNotFound"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -97,7 +97,7 @@ func testFwvRPCConn(t *testing.T) {
}
func testFwvExportEvent(t *testing.T) {
event := &utils.CGREventWithEeIDs{
event := &engine.CGREventWithEeIDs{
EeIDs: []string{"FwvExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -115,7 +115,7 @@ func testHTTPStartHTTPServer(t *testing.T) {
}
func testHTTPExportEvent(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPPostExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -143,7 +143,7 @@ func testHTTPExportEvent(t *testing.T) {
},
}
eventData := &utils.CGREventWithEeIDs{
eventData := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPPostExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -171,7 +171,7 @@ func testHTTPExportEvent(t *testing.T) {
},
}
eventSMS := &utils.CGREventWithEeIDs{
eventSMS := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPPostExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -199,7 +199,7 @@ func testHTTPExportEvent(t *testing.T) {
},
}
eventSMSNoFields := &utils.CGREventWithEeIDs{
eventSMSNoFields := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPPostExporterWithNoFields"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -112,7 +112,7 @@ func testHTTPJsonMapStartHTTPServer(t *testing.T) {
}
func testHTTPJsonMapExportEvent(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPJsonMapExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -143,7 +143,7 @@ func testHTTPJsonMapExportEvent(t *testing.T) {
},
}
eventData := &utils.CGREventWithEeIDs{
eventData := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPJsonMapExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -174,7 +174,7 @@ func testHTTPJsonMapExportEvent(t *testing.T) {
},
}
eventSMS := &utils.CGREventWithEeIDs{
eventSMS := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPJsonMapExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -206,7 +206,7 @@ func testHTTPJsonMapExportEvent(t *testing.T) {
},
}
eventSMSNoFields := &utils.CGREventWithEeIDs{
eventSMSNoFields := &engine.CGREventWithEeIDs{
EeIDs: []string{"HTTPJsonMapExporterWithNoFields"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -143,7 +143,7 @@ func testSqlEeRPCConn(t *testing.T) {
}
func testSqlEeExportEventFull(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterFull"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -179,7 +179,7 @@ func testSqlEeExportEventFull(t *testing.T) {
}
func testSqlEeExportEventPartial(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"SQLExporterPartial"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -99,7 +99,7 @@ func testVirtRPCConn(t *testing.T) {
}
func testVirtExportSupplierEvent(t *testing.T) {
supplierEvent := &utils.CGREventWithEeIDs{
supplierEvent := &engine.CGREventWithEeIDs{
EeIDs: []string{"RouteExporter"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
@@ -133,7 +133,7 @@ func testVirtExportSupplierEvent(t *testing.T) {
}
func testVirtExportEvents(t *testing.T) {
eventVoice := &utils.CGREventWithEeIDs{
eventVoice := &engine.CGREventWithEeIDs{
EeIDs: []string{"CSVExporterFromVirt"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -979,7 +979,7 @@ func export(ub *Account, a *Action, acs Actions, _ *FilterS, extraData interface
default:
return // nothing to post
}
args := &utils.CGREventWithEeIDs{
args := &CGREventWithEeIDs{
EeIDs: strings.Split(a.ExtraParameters, utils.InfieldSep),
CGREvent: cgrEv,
}

66
engine/argees.go Normal file
View File

@@ -0,0 +1,66 @@
/*
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 engine
import (
"encoding/json"
"github.com/cgrates/cgrates/utils"
)
// CGREventWithEeIDs struct is moved in engine due to importing ciclying packages in order to unmarshalling properly for our EventCost type. This is the API struct argument
// CGREventWithEeIDs is the CGREventWithOpts with EventExporterIDs
type CGREventWithEeIDs struct {
EeIDs []string
*utils.CGREvent
}
func (cgr *CGREventWithEeIDs) UnmarshalJSON(data []byte) error {
// firstly, we will unamrshall the entire data into raw bytes
ids := make(map[string]json.RawMessage)
if err := json.Unmarshal(data, &ids); err != nil {
return err
}
// populate eeids in case of it's existance
eeIDs := make([]string, len(ids[utils.EeIDs]))
if err := json.Unmarshal(ids[utils.EeIDs], &eeIDs); err != nil {
return err
}
cgr.EeIDs = eeIDs
// populate the entire CGRevent struct in case of it's existance
var cgrEv *utils.CGREvent
if err := json.Unmarshal(data, &cgrEv); err != nil {
return err
}
cgr.CGREvent = cgrEv
// check if we have EventCost and modify it's type (by default it was map[string]interface{} by unrmarshaling, now it will be EventCost)
if ecEv, has := cgrEv.Event[utils.EventCost]; has {
ec := new(EventCost)
bts, err := json.Marshal(ecEv)
if err != nil {
return err
}
if err := json.Unmarshal(bts, &ec); err != nil {
return err
}
cgr.Event[utils.EventCost] = ec
}
return nil
}

View File

@@ -424,7 +424,7 @@ func (cdrS *CDRServer) statSProcessEvent(cgrEv *utils.CGREvent) (err error) {
}
// eeSProcessEvent will process the event with the EEs component
func (cdrS *CDRServer) eeSProcessEvent(cgrEv *utils.CGREventWithEeIDs) (err error) {
func (cdrS *CDRServer) eeSProcessEvent(cgrEv *CGREventWithEeIDs) (err error) {
var reply map[string]map[string]interface{}
if err = cdrS.connMgr.Call(cdrS.cgrCfg.CdrsCfg().EEsConns, nil,
utils.EeSv1ProcessEvent,
@@ -574,7 +574,7 @@ func (cdrS *CDRServer) processEvents(evs []*utils.CGREvent,
if export {
if len(cdrS.cgrCfg.CdrsCfg().EEsConns) != 0 {
for _, cgrEv := range cgrEvs {
evWithOpts := &utils.CGREventWithEeIDs{
evWithOpts := &CGREventWithEeIDs{
CGREvent: cgrEv,
EeIDs: cdrS.cgrCfg.CdrsCfg().OnlineCDRExports,
}

View File

@@ -196,12 +196,6 @@ func GetRoutePaginatorFromOpts(ev map[string]interface{}) (args Paginator, err e
return
}
// CGREventWithEeIDs is the CGREventWithOpts with EventExporterIDs
type CGREventWithEeIDs struct {
EeIDs []string
*CGREvent
}
// NMAsCGREvent builds a CGREvent considering Time as time.Now()
// and Event as linear map[string]interface{} with joined paths
// treats particular case when the value of map is []*NMItem - used in agents/AgentRequest

View File

@@ -237,6 +237,8 @@ const (
MetaReqRunID = "*req.RunID"
Cost = "Cost"
CostDetails = "CostDetails"
EventCost = "EventCost"
EeIDs = "EeIDs"
Rated = "rated"
Partial = "Partial"
PreRated = "PreRated"