mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 22:29:55 +05:00
CdrStatsConfig with defaults
This commit is contained in:
@@ -28,8 +28,7 @@ import (
|
||||
// Parse the configuration file for CDRStatConfigs
|
||||
func ParseCfgDefaultCDRStatsConfig(c *conf.ConfigFile) (*CdrStatsConfig, error) {
|
||||
var err error
|
||||
csCfg := new(CdrStatsConfig)
|
||||
csCfg.Id = utils.DEFAULT_RUNID
|
||||
csCfg := NewCdrStatsConfigWithDefaults()
|
||||
if hasOpt := c.HasOption("cdrstats", "queue_length"); hasOpt {
|
||||
csCfg.QueueLength, _ = c.GetInt("cdrstats", "queue_length")
|
||||
}
|
||||
@@ -171,6 +170,12 @@ func ParseCfgDefaultCDRStatsConfig(c *conf.ConfigFile) (*CdrStatsConfig, error)
|
||||
return csCfg, nil
|
||||
}
|
||||
|
||||
func NewCdrStatsConfigWithDefaults() *CdrStatsConfig {
|
||||
csCfg := new(CdrStatsConfig)
|
||||
csCfg.setDefaults()
|
||||
return csCfg
|
||||
}
|
||||
|
||||
type CdrStatsConfig struct {
|
||||
Id string // Config id, unique per config instance
|
||||
QueueLength int // Number of items in the stats buffer
|
||||
@@ -193,3 +198,10 @@ type CdrStatsConfig struct {
|
||||
RatedSubjects []string
|
||||
CostInterval []float64 // 2 or less items, (>=Cost, <Cost)
|
||||
}
|
||||
|
||||
func (csCfg *CdrStatsConfig) setDefaults() {
|
||||
csCfg.Id = utils.META_DEFAULT
|
||||
csCfg.QueueLength = 50
|
||||
csCfg.TimeWindow = time.Duration(1) * time.Hour
|
||||
csCfg.Metrics = []string{"ASR", "ACD", "ACC"}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ func (self *CGRConfig) setDefaults() error {
|
||||
self.CDRSMediator = ""
|
||||
self.CDRSStats = ""
|
||||
self.CDRStatsEnabled = false
|
||||
self.CDRStatConfig = &CdrStatsConfig{Id: utils.DEFAULT_RUNID, QueueLength: 50, TimeWindow: time.Duration(1) * time.Hour, Metrics: []string{"ASR", "ACD", "ACC"}}
|
||||
self.CDRStatConfig = NewCdrStatsConfigWithDefaults()
|
||||
self.CdreDefaultInstance, _ = NewDefaultCdreConfig()
|
||||
self.CdrcEnabled = false
|
||||
self.CdrcCdrs = utils.INTERNAL
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestDefaults(t *testing.T) {
|
||||
eCfg.CDRSExtraFields = []*utils.RSRField{}
|
||||
eCfg.CDRSMediator = ""
|
||||
eCfg.CDRStatsEnabled = false
|
||||
eCfg.CDRStatConfig = &CdrStatsConfig{Id: utils.DEFAULT_RUNID, QueueLength: 50, TimeWindow: time.Duration(1) * time.Hour, Metrics: []string{"ASR", "ACD", "ACC"}}
|
||||
eCfg.CDRStatConfig = &CdrStatsConfig{Id: utils.META_DEFAULT, QueueLength: 50, TimeWindow: time.Duration(1) * time.Hour, Metrics: []string{"ASR", "ACD", "ACC"}}
|
||||
eCfg.CdrcEnabled = false
|
||||
eCfg.CdrcCdrs = utils.INTERNAL
|
||||
eCfg.CdrcRunDelay = time.Duration(0)
|
||||
@@ -219,7 +219,7 @@ func TestConfigFromFile(t *testing.T) {
|
||||
eCfg.CDRSExtraFields = []*utils.RSRField{&utils.RSRField{Id: "test"}}
|
||||
eCfg.CDRSMediator = "test"
|
||||
eCfg.CDRStatsEnabled = true
|
||||
eCfg.CDRStatConfig = &CdrStatsConfig{Id: utils.DEFAULT_RUNID, QueueLength: 99, TimeWindow: time.Duration(99) * time.Second,
|
||||
eCfg.CDRStatConfig = &CdrStatsConfig{Id: utils.META_DEFAULT, QueueLength: 99, TimeWindow: time.Duration(99) * time.Second,
|
||||
Metrics: []string{"test"}, TORs: []string{"test"}, CdrHosts: []string{"test"}, CdrSources: []string{"test"}, ReqTypes: []string{"test"}, Directions: []string{"test"},
|
||||
Tenants: []string{"test"}, Categories: []string{"test"}, Accounts: []string{"test"}, Subjects: []string{"test"}, DestinationPrefixes: []string{"test"},
|
||||
UsageInterval: []time.Duration{time.Duration(99) * time.Second},
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
# This file contains the default configuration hardcoded into CGRateS.
|
||||
# This is what you get when you load CGRateS with an empty configuration file.
|
||||
|
||||
[global]
|
||||
rpc_json_listen = :2012 # RPC JSON listening address
|
||||
|
||||
[rater]
|
||||
# enabled = false # Enable RaterCDRSExportPath service: <true|false>.
|
||||
enabled = true # Enable RaterCDRSExportPath service: <true|false>.
|
||||
|
||||
[scheduler]
|
||||
# enabled = false # Starts Scheduler service: <true|false>.
|
||||
@@ -47,7 +50,7 @@ enabled = true # Starts SessionManager service: <true|false>
|
||||
switch_type = opensips # Defines the type of switch behind: <freeswitch>
|
||||
|
||||
[opensips]
|
||||
listen_udp = 172.16.254.66:2020 # Address where to listen for datagram events coming from OpenSIPS
|
||||
listen_udp = :2020 # Address where to listen for datagram events coming from OpenSIPS
|
||||
mi_addr = 172.16.254.77:8020 # Adress where to reach OpenSIPS mi_datagram module
|
||||
|
||||
[mailer]
|
||||
|
||||
@@ -99,6 +99,7 @@ const (
|
||||
RATED_SUBJECT = "rated_subject"
|
||||
COST = "cost"
|
||||
DEFAULT_RUNID = "default"
|
||||
META_DEFAULT = "*default"
|
||||
STATIC_VALUE_PREFIX = "^"
|
||||
CSV = "csv"
|
||||
CDRE_DRYRUN = "dry_run"
|
||||
@@ -111,7 +112,6 @@ const (
|
||||
CDRC = "cdrc"
|
||||
MASK_CHAR = "*"
|
||||
CONCATENATED_KEY_SEP = ":"
|
||||
META_DEFAULT = "*default"
|
||||
FORKED_CDR = "forked_cdr"
|
||||
UNIT_TEST = "UNIT_TEST"
|
||||
HDR_VAL_SEP = "/"
|
||||
|
||||
Reference in New Issue
Block a user