From 70fa4f7a2bfb4ecf62d09866a8a25733ad73b32e Mon Sep 17 00:00:00 2001 From: adi Date: Thu, 22 Sep 2022 17:22:50 +0300 Subject: [PATCH] Bool opts and config modification --- .../conf/samples/dispatcher_opts/cgrates.json | 6 +++++- .../dispatcher_opts_admin/cgrates.json | 21 ++++++++++++------- engine/libdynopts.go | 12 +++++++++-- utils/mapstorage_test.go | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/data/conf/samples/dispatcher_opts/cgrates.json b/data/conf/samples/dispatcher_opts/cgrates.json index aab47d661..8676b6b65 100644 --- a/data/conf/samples/dispatcher_opts/cgrates.json +++ b/data/conf/samples/dispatcher_opts/cgrates.json @@ -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 }, diff --git a/data/conf/samples/dispatcher_opts_admin/cgrates.json b/data/conf/samples/dispatcher_opts_admin/cgrates.json index 71bfec856..87fcab797 100644 --- a/data/conf/samples/dispatcher_opts_admin/cgrates.json +++ b/data/conf/samples/dispatcher_opts_admin/cgrates.json @@ -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"}, ], - }, */ + }, }, } \ No newline at end of file diff --git a/engine/libdynopts.go b/engine/libdynopts.go index c71f3aa39..f510a2600 100644 --- a/engine/libdynopts.go +++ b/engine/libdynopts.go @@ -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) } } diff --git a/utils/mapstorage_test.go b/utils/mapstorage_test.go index 5a43eeae5..63fe49009 100644 --- a/utils/mapstorage_test.go +++ b/utils/mapstorage_test.go @@ -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 {