Bool opts and config modification

This commit is contained in:
adi
2022-09-22 17:22:50 +03:00
committed by Dan Christian Bogos
parent 6b7afc196d
commit 70fa4f7a2b
4 changed files with 29 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
{
"general": {
"node_id": "DispatcherOpts",
"node_id": "HOST1",
"log_level": 7,
},
@@ -36,6 +36,10 @@
},
"caches":{
"partitions": {
"*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false}, // control dispatcher routes caching
"*dispatchers": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false}, // control dispatcher interface
},
"remote_conns": ["gob_cache"], // the conns that are queried when the items are not found in cache
},

View File

@@ -1,7 +1,7 @@
{
"general": {
"node_id": "DispatcherOpts_Admin",
"node_id": "HOST2",
"log_level": 7,
},
@@ -30,12 +30,16 @@
},
],
},
},
"caches":{
//"remote_conns": ["gob_cache"], // the conns that are queried when the items are not found in cache
},
"caches":{
"partitions": {
"*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false}, // control dispatcher routes caching
"*dispatchers": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false}, // control dispatcher interface
},
"remote_conns": ["gob_cache"], // the conns that are queried when the items are not found in cache
},
"admins": {
"enabled": true,
@@ -50,11 +54,12 @@
{"address": "127.0.0.1:4012", "transport":"*json"},
],
},
/* "gob_cache": {
"gob_cache": {
"strategy": "*first",
"conns": [
{"address": "127.0.0.1:4012", "transport":"*gob"},
{"address": "127.0.0.1:4013", "transport":"*gob"},
],
}, */
},
},
}

View File

@@ -173,9 +173,17 @@ func GetIntOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filter
// returns the config option if at least one filter passes or the default value if none of them do
func GetBoolOpts(ctx *context.Context, tnt string, dP utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicBoolOpt,
dftOpt bool, optNames ...string) (cfgOpt bool, err error) {
optsDP := GetAPIOptsFromDataProvider(dP)
values, err := dP.FieldAsInterface([]string{utils.MetaOpts})
if err != nil {
return false, err
}
var opts map[string]interface{}
opts, canCast := values.(map[string]interface{})
if !canCast {
return false, utils.ErrCastFailed
}
for _, optName := range optNames {
if opt, has := optsDP[optName]; has {
if opt, has := opts[optName]; has {
return utils.IfaceAsBool(opt)
}
}

View File

@@ -209,6 +209,7 @@ func TestNavMapGetField(t *testing.T) {
},
"AnotherFirstLevel": "ValAnotherFirstLevel",
}
pth := []string{"FirstLevel", "SecondLevel", "ThirdLevel", "Fld1[0]"}
eFld := "Val1"
if fld, err := nM.FieldAsInterface(pth); err != nil {