mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
63 lines
1.8 KiB
Go
Executable File
63 lines
1.8 KiB
Go
Executable File
/*
|
|
Real-time Online/Offline Charging System (OCS) 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 <http://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
package config
|
|
|
|
import "github.com/cgrates/cgrates/utils"
|
|
|
|
type SchedulerCfg struct {
|
|
Enabled bool
|
|
CDRsConns []string
|
|
Filters []string
|
|
}
|
|
|
|
func (schdcfg *SchedulerCfg) loadFromJsonCfg(jsnCfg *SchedulerJsonCfg) error {
|
|
if jsnCfg == nil {
|
|
return nil
|
|
}
|
|
if jsnCfg.Enabled != nil {
|
|
schdcfg.Enabled = *jsnCfg.Enabled
|
|
}
|
|
if jsnCfg.Cdrs_conns != nil {
|
|
schdcfg.CDRsConns = make([]string, len(*jsnCfg.Cdrs_conns))
|
|
for idx, conn := range *jsnCfg.Cdrs_conns {
|
|
// if we have the connection internal we change the name so we can have internal rpc for each subsystem
|
|
if conn == utils.MetaInternal {
|
|
schdcfg.CDRsConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCDRs)
|
|
} else {
|
|
schdcfg.CDRsConns[idx] = conn
|
|
}
|
|
}
|
|
}
|
|
if jsnCfg.Filters != nil {
|
|
schdcfg.Filters = make([]string, len(*jsnCfg.Filters))
|
|
for i, fltr := range *jsnCfg.Filters {
|
|
schdcfg.Filters[i] = fltr
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (schdcfg *SchedulerCfg) AsMapInterface() map[string]interface{} {
|
|
return map[string]interface{}{
|
|
utils.EnabledCfg: schdcfg.Enabled,
|
|
utils.CDRsConnsCfg: schdcfg.CDRsConns,
|
|
utils.FiltersCfg: schdcfg.Filters,
|
|
}
|
|
}
|