From 6b1104833885ce0c4fc523dd274b0fb696eef7f4 Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 10 Jul 2018 12:31:46 +0200 Subject: [PATCH] Initial ChargerService.V1ProcessEvent --- data/conf/samples/tutmysql/cgrates.json | 14 ++++----- engine/chargers.go | 40 ++++++++++++++++++++----- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json index 5b793f0c5..86c108843 100644 --- a/data/conf/samples/tutmysql/cgrates.json +++ b/data/conf/samples/tutmysql/cgrates.json @@ -224,13 +224,14 @@ ], -"attributes": { // Attribute service - "enabled": true, // starts Alias service: . + +"attributes": { + "enabled": true, }, -"chargers": { // Attribute service - "enabled": true, // starts Alias service: . +"chargers": { + "enabled": true, }, @@ -262,11 +263,6 @@ }, -"aliases": { - "enabled": true, -}, - - "sessions": { "enabled": true, "suppliers_conns": [ diff --git a/engine/chargers.go b/engine/chargers.go index 9b04f0243..084e430b0 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -25,6 +25,17 @@ import ( "github.com/cgrates/rpcclient" ) +// ChargerProfile is the config for one Charger +type ChargerProfile struct { + Tenant string + ID string + FilterIDs []string + ActivationInterval *utils.ActivationInterval // Activation interval + RunID string + AttributeIDs []string // perform data aliasing based on these Attributes + Weight float64 +} + func NewChargerService(dm *DataManager, filterS *FilterS, attrS rpcclient.RpcClientConnection, strgIdxFlds, prfxIdxFlds *[]string) (*ChargerService, error) { @@ -34,6 +45,7 @@ func NewChargerService(dm *DataManager, filterS *FilterS, prfxIdxFlds: prfxIdxFlds}, nil } +// ChargerService is performing charging type ChargerService struct { dm *DataManager filterS *FilterS @@ -57,12 +69,24 @@ func (cS *ChargerService) Shutdown() (err error) { return } -type ChargerProfile struct { - Tenant string - ID string - FilterIDs []string - ActivationInterval *utils.ActivationInterval // Activation interval - RunID string - AttributeIDs []string - Weight float64 +func (cS *ChargerService) processEvent(cgrEv *utils.CGREvent) (cgrEvs []*utils.CGREvent, err error) { + return +} + +// V1ProcessEvent will process the event received via API and return list of events forked +func (cS *ChargerService) V1ProcessEvent(args *utils.CGREvent, + reply *[]*utils.CGREvent) (err error) { + if args.Event == nil { + return utils.NewErrMandatoryIeMissing("Event") + } + rply, err := cS.processEvent(args) + if err != nil { + if err != utils.ErrNotFound { + err = utils.NewErrServerError(err) + } + return err + } + *reply = rply + return + }