diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 7ad6172dd..b0d003adf 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -789,7 +789,7 @@ func startSupplierService(internalSupplierSChan chan rpcclient.RpcClientConnecti filterSChan <- filterS var attrSConn, resourceSConn, statSConn *rpcclient.RpcClientPool if len(cfg.SupplierSCfg().AttributeSConns) != 0 { - resourceSConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.TLSClientKey, cfg.TLSClientCerificate, + attrSConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.TLSClientKey, cfg.TLSClientCerificate, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout, cfg.SupplierSCfg().AttributeSConns, internalAttrSChan, cfg.InternalTtl) if err != nil { diff --git a/data/conf/samples/cluelrn/cgrates.json b/data/conf/samples/cluelrn/cgrates.json index e4501c5a8..317767370 100644 --- a/data/conf/samples/cluelrn/cgrates.json +++ b/data/conf/samples/cluelrn/cgrates.json @@ -45,13 +45,14 @@ "attributes": { "enabled": true, + "process_runs": 5, // number of run loops when processing event }, "suppliers": { "enabled": true, "attributes_conns": [ - {"address": "*internal"} + {"address": "127.0.0.1:2012", "transport":"*json"} ], }, diff --git a/data/tariffplans/cluelrn/Attributes.csv b/data/tariffplans/cluelrn/Attributes.csv index 9d7d1c0ca..121638ce6 100644 --- a/data/tariffplans/cluelrn/Attributes.csv +++ b/data/tariffplans/cluelrn/Attributes.csv @@ -5,4 +5,4 @@ cgrates.org,LRN_LATA_Dst13128543000,lrn,*string:Destination:13128543000;*rsr::Or cgrates.org,LRN_LATA_Cli9174269000,lrn,*string:Account:9174269000;*rsr::DestinationLATA(!^$),,CallerLATA,*any,132,true,false,30 cgrates.org,LRN_JURISDICTION_NY,lrn,FLTR_INTRALATA_NEWYORK,,LRNJurisdiction,*any,INTRA,true,false,50 cgrates.org,LRN_JURISDICTION_IL,lrn,FLTR_INTRALATA_ILLINOIS,,LRNJurisdiction,*any,INTRA,true,false,50 -cgrates.org,LRN_JURISDICTION_INTER,lrn,*string:Destination:9174269000;*rsr::CallerLATA(!^$),,LRNJurisdiction,*any,INTER,true,false,40 +cgrates.org,LRN_JURISDICTION_INTER,lrn,*string:Destination:13128543000;*rsr::CallerLATA(!^$),,LRNJurisdiction,*any,INTER,true,false,40 diff --git a/data/tariffplans/cluelrn/Suppliers.csv b/data/tariffplans/cluelrn/Suppliers.csv index 40e4bfdf0..441300ebf 100644 --- a/data/tariffplans/cluelrn/Suppliers.csv +++ b/data/tariffplans/cluelrn/Suppliers.csv @@ -1,4 +1,4 @@ #Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParamameters,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SupplierParameters,Weight -cgrates.org,SPL_CLUELRN_INTER,*string:Account:9174269000;*string:LRNJuristiction:INTER,2017-11-27T00:00:00Z,*least_cost,,LEVEL3,,,RP_LEVEL3_INTER,,,,false,,10 +cgrates.org,SPL_CLUELRN_INTER,*string:Account:9174269000;*string:LRNJurisdiction:INTER,2017-11-27T00:00:00Z,*least_cost,,LEVEL3,,,RP_LEVEL3_INTER,,,,false,,10 cgrates.org,SPL_CLUELRN_INTER,,,,,TMOBILE,,,RP_TMOBILE_INTER,,,,false,, cgrates.org,SPL_CLUELRN_INTER,,,,,COMCAST,,,RP_COMCAST_INTER,,,,false,, diff --git a/engine/suppliers.go b/engine/suppliers.go index da51bad6d..3d4a2c153 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -359,6 +359,21 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted } else if args.CGREvent.Event == nil { return utils.NewErrMandatoryIeMissing("Event") } + if spS.attributeS != nil { + if args.CGREvent.Context == nil { // populate if not already in + args.CGREvent.Context = utils.StringPointer(utils.MetaSuppliers) + } + attrArgs := &AttrArgsProcessEvent{ + CGREvent: args.CGREvent, + } + var rplyEv AttrSProcessEventReply + if err := spS.attributeS.Call(utils.AttributeSv1ProcessEvent, + attrArgs, &rplyEv); err == nil && len(rplyEv.AlteredFields) != 0 { + args.CGREvent = *rplyEv.CGREvent + } else if err.Error() != utils.ErrNotFound.Error() { + return utils.NewErrAttributeS(err) + } + } sSps, err := spS.sortedSuppliersForEvent(args) if err != nil { if err != utils.ErrNotFound {