From 07353f8724b8ad4df94137644c3297fe271ebca2 Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 20 Dec 2020 11:51:07 +0100 Subject: [PATCH] AccountS service skel --- accounts/accounts.go | 68 +++++++++++++++++++ .../tutaccounts/AccountProfiles.csv | 2 +- utils/consts.go | 1 + 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 accounts/accounts.go diff --git a/accounts/accounts.go b/accounts/accounts.go new file mode 100644 index 000000000..1426e5372 --- /dev/null +++ b/accounts/accounts.go @@ -0,0 +1,68 @@ +/* +Real-time Online/Offline Charging System (OerS) 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 +*/ + +package accounts + +import ( + "fmt" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +// NewAccountS instantiates the AccountS +func NewAccountS(cfg *config.CGRConfig, fltrS *engine.FilterS, dm *engine.DataManager) *AccountS { + return &AccountS{ + cfg: cfg, + fltrS: fltrS, + dm: dm, + } +} + +// AccountS operates Accounts +type AccountS struct { + cfg *config.CGRConfig + fltrS *engine.FilterS + dm *engine.DataManager +} + +// ListenAndServe keeps the service alive +func (aS *AccountS) ListenAndServe(stopChan, cfgRld chan struct{}) { + utils.Logger.Info(fmt.Sprintf("<%s> starting <%s>", + utils.CoreS, utils.AccountS)) + for { + select { + case <-stopChan: + return + case rld := <-cfgRld: // configuration was reloaded + cfgRld <- rld + } + } +} + +// Shutdown is called to shutdown the service +func (aS *AccountS) Shutdown() (err error) { + utils.Logger.Info(fmt.Sprintf("<%s> shutdown <%s>", utils.CoreS, utils.AccountS)) + return +} + +// Call implements rpcclient.ClientConnector interface for internal RPC +func (aS *AccountS) Call(serviceMethod string, args interface{}, reply interface{}) error { + return utils.RPCCall(aS, serviceMethod, args, reply) +} diff --git a/data/tariffplans/tutaccounts/AccountProfiles.csv b/data/tariffplans/tutaccounts/AccountProfiles.csv index c30f4ea8c..b00f75691 100644 --- a/data/tariffplans/tutaccounts/AccountProfiles.csv +++ b/data/tariffplans/tutaccounts/AccountProfiles.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,ActivationInterval,Weight,BalanceID,BalanceFilterIDs,BalanceType,BalanceOpts,BalanceWeight,BalanceValue +#Tenant,ID,FilterIDs,ActivationInterval,Weight,BalanceID,BalanceFilterIDs,BalanceWeight,BalanceBlocker,BalanceType,BalanceOpts,BalanceValue diff --git a/utils/consts.go b/utils/consts.go index ccb04dda3..5adebba9f 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -530,6 +530,7 @@ const ( MetaFile = "*file" Accounts = "Accounts" AccountService = "AccountS" + AccountS = "AccountS" Actions = "Actions" ActionPlans = "ActionPlans" ActionTriggers = "ActionTriggers"