Replace strings with contants

This commit is contained in:
TeoV
2020-10-08 09:30:51 +03:00
committed by Dan Christian Bogos
parent 5d684063a6
commit 9d25b27a4a
3 changed files with 33 additions and 20 deletions

View File

@@ -344,6 +344,19 @@
"tenant": "cgrates.org",
"attempts": 1,
"filters": ["*string:~*req.ExporterUsed:ElasticExporter"],
"opts": {
"index": "cdrs",
//"if_primary_term": 0,
//"if_seq_no": 0,
"op_type": "",
"pipeline": "",
"require_alias": "",
"routing": "",
"timeout": 0,
//"version": 0,
"version_type": "",
"wait_for_active_shards": "",
},
"fields":[
{"tag": "CGRID", "path": "*exp.CGRID", "type": "*variable", "value": "~*req.CGRID"},
{"tag": "RunID", "path": "*exp.RunID", "type": "*variable", "value": "~*req.RunID"},

View File

@@ -63,35 +63,35 @@ func (eEe *ElasticEe) init() (err error) {
return
}
//parse opts
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.Index]; !has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsIndex]; !has {
eEe.opts.Index = utils.CDRsTBL
} else {
eEe.opts.Index = utils.IfaceAsString(val)
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.IfPrimaryTerm]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsIfPrimaryTerm]; has {
var intVal int64
if intVal, err = utils.IfaceAsTInt64(val); err != nil {
return
}
eEe.opts.IfPrimaryTerm = utils.IntPointer(int(intVal))
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.IfSeqNo]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsIfSeqNo]; has {
var intVal int64
if intVal, err = utils.IfaceAsTInt64(val); err != nil {
return
}
eEe.opts.IfSeqNo = utils.IntPointer(int(intVal))
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OpType]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsOpType]; has {
eEe.opts.OpType = utils.IfaceAsString(val)
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.Pipeline]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsPipeline]; has {
eEe.opts.Pipeline = utils.IfaceAsString(val)
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.Routing]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsRouting]; has {
eEe.opts.Routing = utils.IfaceAsString(val)
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.Timeout]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsTimeout]; has {
if eEe.opts.Timeout, err = utils.IfaceAsDuration(val); err != nil {
return
}
@@ -103,10 +103,10 @@ func (eEe *ElasticEe) init() (err error) {
}
eEe.opts.Version = utils.IntPointer(int(intVal))
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.VersionType]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsVersionType]; has {
eEe.opts.VersionType = utils.IfaceAsString(val)
}
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.WaitForActiveShards]; has {
if val, has := eEe.cgrCfg.EEsCfg().Exporters[eEe.cfgIdx].Opts[utils.OptsWaitForActiveShards]; has {
eEe.opts.WaitForActiveShards = utils.IfaceAsString(val)
}
return

View File

@@ -2384,17 +2384,17 @@ const (
// EEs
OptsEEsVerbose = "*eesVerbose"
// EEs Elasticsearch options
Index = "index"
IfPrimaryTerm = "if_primary_term"
IfSeqNo = "if_seq_no"
OpType = "op_type"
Pipeline = "pipeline"
RequireAlias = "require_alias"
Routing = "routing"
Timeout = "timeout"
VersionLow = "version"
VersionType = "version_type"
WaitForActiveShards = "wait_for_active_shards"
OptsIndex = "index"
OptsIfPrimaryTerm = "if_primary_term"
OptsIfSeqNo = "if_seq_no"
OptsOpType = "op_type"
OptsPipeline = "pipeline"
OptsRequireAlias = "require_alias"
OptsRouting = "routing"
OptsTimeout = "timeout"
VersionLow = "version"
OptsVersionType = "version_type"
OptsWaitForActiveShards = "wait_for_active_shards"
// Others
OptsContext = "*context"
Subsys = "*subsys"