mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Configuration option filters within scheduler section
This commit is contained in:
@@ -118,6 +118,7 @@ const CGRATES_CFG_JSON = `
|
||||
"scheduler": {
|
||||
"enabled": false, // start Scheduler service: <true|false>
|
||||
"cdrs_conns": [], // connections to CDRs for *cdrlog actions <*internal|x.y.z.y:1234>
|
||||
"filters": [], // only execute actions matching these filters
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -263,6 +263,7 @@ func TestDfSchedulerJsonCfg(t *testing.T) {
|
||||
eCfg := &SchedulerJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Cdrs_conns: &[]*RemoteHostJson{},
|
||||
Filters: &[]string{},
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.SchedulerJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -502,8 +502,8 @@ func TestCgrCfgJSONDefaultsScheduler(t *testing.T) {
|
||||
eSchedulerCfg := &SchedulerCfg{
|
||||
Enabled: false,
|
||||
CDRsConns: []*RemoteHost{},
|
||||
Filters: []string{},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cgrCfg.schedulerCfg, eSchedulerCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.schedulerCfg, eSchedulerCfg)
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ type RalsJsonCfg struct {
|
||||
type SchedulerJsonCfg struct {
|
||||
Enabled *bool
|
||||
Cdrs_conns *[]*RemoteHostJson
|
||||
Filters *[]string
|
||||
}
|
||||
|
||||
// Cdrs config section
|
||||
|
||||
@@ -21,6 +21,7 @@ package config
|
||||
type SchedulerCfg struct {
|
||||
Enabled bool
|
||||
CDRsConns []*RemoteHost
|
||||
Filters []string
|
||||
}
|
||||
|
||||
func (schdcfg *SchedulerCfg) loadFromJsonCfg(jsnCfg *SchedulerJsonCfg) error {
|
||||
@@ -30,7 +31,6 @@ func (schdcfg *SchedulerCfg) loadFromJsonCfg(jsnCfg *SchedulerJsonCfg) error {
|
||||
if jsnCfg.Enabled != nil {
|
||||
schdcfg.Enabled = *jsnCfg.Enabled
|
||||
}
|
||||
|
||||
if jsnCfg.Cdrs_conns != nil {
|
||||
schdcfg.CDRsConns = make([]*RemoteHost, len(*jsnCfg.Cdrs_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Cdrs_conns {
|
||||
@@ -38,5 +38,11 @@ func (schdcfg *SchedulerCfg) loadFromJsonCfg(jsnCfg *SchedulerJsonCfg) error {
|
||||
schdcfg.CDRsConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Filters != nil {
|
||||
schdcfg.Filters = make([]string, len(*jsnCfg.Filters))
|
||||
for i, fltr := range *jsnCfg.Filters {
|
||||
schdcfg.Filters[i] = fltr
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user