Adding CdrStats config in rater

This commit is contained in:
DanB
2015-04-02 16:52:31 +02:00
parent c908aa95cf
commit 57827b3a3d
6 changed files with 14 additions and 2 deletions

View File

@@ -118,6 +118,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
return err
}
tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account)
engine.Logger.Debug("Add balance before getAccount")
if _, err := self.AccountDb.GetAccount(tag); err != nil {
// create user balance if not exists
account := &engine.Account{
@@ -128,6 +129,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
return err
}
}
engine.Logger.Debug("Add balance after getAccount")
at := &engine.ActionTiming{
AccountIds: []string{tag},
}
@@ -141,6 +143,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
if attr.Overwrite {
aType = engine.DEBIT_RESET
}
engine.Logger.Debug("Add balance before SetActions")
at.SetActions(engine.Actions{
&engine.Action{
ActionType: aType,
@@ -157,10 +160,12 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
},
},
})
engine.Logger.Debug("Add balance before at.Execute")
if err := at.Execute(); err != nil {
*reply = err.Error()
return err
}
engine.Logger.Debug("AddBalance done!")
*reply = OK
return nil
}

View File

@@ -191,6 +191,7 @@ type CGRConfig struct {
MaxCallDuration time.Duration // The maximum call duration (used by responder when querying DerivedCharging) // ToDo: export it in configuration file
RaterEnabled bool // start standalone server (no balancer)
RaterBalancer string // balancer address host:port
RaterCdrStats string // address where to reach the cdrstats service. Empty to disable stats gathering <""|internal|x.y.z.y:1234>
BalancerEnabled bool
SchedulerEnabled bool
CDRSEnabled bool // Enable CDR Server service
@@ -463,6 +464,9 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
if jsnRaterCfg.Balancer != nil {
self.RaterBalancer = *jsnRaterCfg.Balancer
}
if jsnRaterCfg.Cdrstats != nil {
self.RaterCdrStats = *jsnRaterCfg.Cdrstats
}
}
if jsnBalancerCfg != nil && jsnBalancerCfg.Enabled != nil {

View File

@@ -85,7 +85,8 @@ const CGRATES_CFG_JSON = `
"rater": {
"enabled": false, // enable Rater service: <true|false>
"balancer": "", // register to Balancer as worker: <""|internal|x.y.z.y:1234>
"balancer": "", // register to balancer as worker: <""|internal|x.y.z.y:1234>
"cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234>
},

View File

@@ -118,7 +118,7 @@ func TestDfBalancerJsonCfg(t *testing.T) {
}
func TestDfRaterJsonCfg(t *testing.T) {
eCfg := &RaterJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer("")}
eCfg := &RaterJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer(""), Cdrstats: utils.StringPointer("")}
if cfg, err := dfCgrJsonCfg.RaterJsonCfg(); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eCfg, cfg) {

View File

@@ -58,6 +58,7 @@ type BalancerJsonCfg struct {
type RaterJsonCfg struct {
Enabled *bool
Balancer *string
Cdrstats *string
}
// Scheduler config section

View File

@@ -65,6 +65,7 @@
//"rater": {
// "enabled": false, // enable Rater service: <true|false>
// "balancer": "", // register to Balancer as worker: <""|internal|x.y.z.y:1234>
// "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234>
//},