From 21120eb9b6b549af73d0cb0758ea02f5c4f5e707 Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 14 Oct 2020 17:43:05 +0300 Subject: [PATCH] Add "redis_" prefix to "dataDB" option for redis --- cmd/cgr-loader/cgr-loader.go | 12 +++--- cmd/cgr-loader/cgr-loader_it_test.go | 10 ++--- cmd/cgr-migrator/cgr-migrator.go | 12 +++--- cmd/cgr-tester/cgr-tester.go | 12 +++--- config/config_defaults.go | 9 +++-- config/config_json_test.go | 19 ++++----- config/config_test.go | 8 ++-- config/migratorcfg_test.go | 40 +++++++++---------- data/conf/cgrates/cgrates.json | 35 +++++++++++++--- .../samples/tutredis_cluster/cgrates.json | 2 +- engine/storage_utils.go | 4 +- packages/debian/changelog | 1 + services/datadb.go | 4 +- services/datadb_it_test.go | 10 ++--- utils/consts.go | 25 ++++++------ 15 files changed, 115 insertions(+), 88 deletions(-) diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go index 959a262eb..2cfeae2f1 100755 --- a/cmd/cgr-loader/cgr-loader.go +++ b/cmd/cgr-loader/cgr-loader.go @@ -59,9 +59,9 @@ var ( "The name of redis sentinel") dbRedisCluster = cgrLoaderFlags.Bool("redis_cluster", false, "Is the redis datadb a cluster") - dbRedisClusterSync = cgrLoaderFlags.String("cluster_sync", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterSyncCfg]), + dbRedisClusterSync = cgrLoaderFlags.String("redis_cluster_sync", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg]), "The sync interval for the redis cluster") - dbRedisClusterDownDelay = cgrLoaderFlags.String("cluster_ondown_delay", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]), + dbRedisClusterDownDelay = cgrLoaderFlags.String("redis_cluster_ondown_delay", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]), "The delay before executing the commands if the redis cluster is in the CLUSTERDOWN state") dbQueryTimeout = cgrLoaderFlags.String("query_timeout", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg]), "The timeout for queries") @@ -152,11 +152,11 @@ func loadConfig() (ldrCfg *config.CGRConfig) { if *dbRedisCluster != rdsCls { ldrCfg.DataDbCfg().Opts[utils.RedisClusterCfg] = *dbRedisCluster } - if *dbRedisClusterSync != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterSyncCfg]) { - ldrCfg.DataDbCfg().Opts[utils.ClusterSyncCfg] = *dbRedisClusterSync + if *dbRedisClusterSync != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg]) { + ldrCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg] = *dbRedisClusterSync } - if *dbRedisClusterDownDelay != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]) { - ldrCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg] = *dbRedisClusterDownDelay + if *dbRedisClusterDownDelay != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]) { + ldrCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg] = *dbRedisClusterDownDelay } if *dbQueryTimeout != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg]) { ldrCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg] = *dbQueryTimeout diff --git a/cmd/cgr-loader/cgr-loader_it_test.go b/cmd/cgr-loader/cgr-loader_it_test.go index f4627e5f8..30f695d36 100644 --- a/cmd/cgr-loader/cgr-loader_it_test.go +++ b/cmd/cgr-loader/cgr-loader_it_test.go @@ -57,11 +57,11 @@ func TestLoadConfig(t *testing.T) { DataDbUser: "cgrates2", DataDbPass: "toor", Opts: map[string]interface{}{ - utils.RedisSentinelNameCfg: "sentinel1", - utils.QueryTimeoutCfg: "10s", - utils.ClusterSyncCfg: "5s", - utils.ClusterOnDownDelayCfg: "0", - utils.RedisClusterCfg: false, + utils.RedisSentinelNameCfg: "sentinel1", + utils.QueryTimeoutCfg: "10s", + utils.RedisClusterSyncCfg: "5s", + utils.RedisClusterOnDownDelayCfg: "0", + utils.RedisClusterCfg: false, }, RmtConns: []string{}, RplConns: []string{}, diff --git a/cmd/cgr-migrator/cgr-migrator.go b/cmd/cgr-migrator/cgr-migrator.go index ac77a5e9f..44dfb7187 100755 --- a/cmd/cgr-migrator/cgr-migrator.go +++ b/cmd/cgr-migrator/cgr-migrator.go @@ -67,9 +67,9 @@ var ( "the name of redis sentinel") dbRedisCluster = cgrMigratorFlags.Bool("redis_cluster", false, "Is the redis datadb a cluster") - dbRedisClusterSync = cgrMigratorFlags.String("cluster_sync", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterSyncCfg]), + dbRedisClusterSync = cgrMigratorFlags.String("redis_cluster_sync", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg]), "The sync interval for the redis cluster") - dbRedisClusterDownDelay = cgrMigratorFlags.String("cluster_ondown_delay", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]), + dbRedisClusterDownDelay = cgrMigratorFlags.String("redis_cluster_ondown_delay", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]), "The delay before executing the commands if the redis cluster is in the CLUSTERDOWN state") dbQueryTimeout = cgrMigratorFlags.String("query_timeout", utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg]), "The timeout for queries") @@ -172,11 +172,11 @@ func main() { if *dbRedisCluster != rdsCls { mgrCfg.DataDbCfg().Opts[utils.RedisClusterCfg] = *dbRedisCluster } - if *dbRedisClusterSync != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterSyncCfg]) { - mgrCfg.DataDbCfg().Opts[utils.ClusterSyncCfg] = *dbRedisClusterSync + if *dbRedisClusterSync != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg]) { + mgrCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg] = *dbRedisClusterSync } - if *dbRedisClusterDownDelay != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]) { - mgrCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg] = *dbRedisClusterDownDelay + if *dbRedisClusterDownDelay != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]) { + mgrCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg] = *dbRedisClusterDownDelay } if *dbQueryTimeout != utils.IfaceAsString(dfltCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg]) { mgrCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg] = *dbQueryTimeout diff --git a/cmd/cgr-tester/cgr-tester.go b/cmd/cgr-tester/cgr-tester.go index 6fb74ea61..a97c55101 100644 --- a/cmd/cgr-tester/cgr-tester.go +++ b/cmd/cgr-tester/cgr-tester.go @@ -57,9 +57,9 @@ var ( redisSentinel = cgrTesterFlags.String("redis_sentinel", utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.RedisSentinelNameCfg]), "The name of redis sentinel") dbRedisCluster = cgrTesterFlags.Bool("redis_cluster", false, "Is the redis datadb a cluster") - dbRedisClusterSync = cgrTesterFlags.String("cluster_sync", utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.ClusterSyncCfg]), + dbRedisClusterSync = cgrTesterFlags.String("redis_cluster_sync", utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.RedisClusterSyncCfg]), "The sync interval for the redis cluster") - dbRedisClusterDownDelay = cgrTesterFlags.String("cluster_ondown_delay", utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]), + dbRedisClusterDownDelay = cgrTesterFlags.String("redis_cluster_ondown_delay", utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]), "The delay before executing the commands if the redis cluster is in the CLUSTERDOWN state") dbQueryTimeout = cgrTesterFlags.String("query_timeout", utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.QueryTimeoutCfg]), "The timeout for queries") @@ -208,11 +208,11 @@ func main() { if *dbRedisCluster != rdsCls { tstCfg.DataDbCfg().Opts[utils.RedisClusterCfg] = *dbRedisCluster } - if *dbRedisClusterSync != utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.ClusterSyncCfg]) { - tstCfg.DataDbCfg().Opts[utils.ClusterSyncCfg] = *dbRedisClusterSync + if *dbRedisClusterSync != utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.RedisClusterSyncCfg]) { + tstCfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg] = *dbRedisClusterSync } - if *dbRedisClusterDownDelay != utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]) { - tstCfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg] = *dbRedisClusterDownDelay + if *dbRedisClusterDownDelay != utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]) { + tstCfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg] = *dbRedisClusterDownDelay } if *dbQueryTimeout != utils.IfaceAsString(cgrConfig.DataDbCfg().Opts[utils.QueryTimeoutCfg]) { tstCfg.DataDbCfg().Opts[utils.QueryTimeoutCfg] = *dbQueryTimeout diff --git a/config/config_defaults.go b/config/config_defaults.go index a5a248f1b..220a44651 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -104,9 +104,10 @@ const CGRATES_CFG_JSON = ` "opts":{ "redis_sentinel": "", // the name of sentinel when used "redis_cluster": false, // if enabled the datadb will try to connect to the redis cluster - "cluster_sync": "5s", // the sync interval for the redis cluster - "cluster_ondown_delay": "0", // the delay before executing the commands if the redis cluster is in the CLUSTERDOWN state + "redis_cluster_sync": "5s", // the sync interval for the redis cluster + "redis_cluster_ondown_delay": "0", // the delay before executing the commands if the redis cluster is in the CLUSTERDOWN state "query_timeout":"10s", + "redis_tls": false, // if true it will use a tls connection and use the client certificate, key and ca_certificate for tls connection } }, @@ -871,8 +872,8 @@ const CGRATES_CFG_JSON = ` "out_datadb_opts":{ "redis_sentinel": "", "redis_cluster": false, - "cluster_sync": "5s", - "cluster_ondown_delay": "0", + "redis_cluster_sync": "5s", + "redis_cluster_ondown_delay": "0", }, "out_stordb_opts":{}, }, diff --git a/config/config_json_test.go b/config/config_json_test.go index 35544f70e..b7d505ebc 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -331,11 +331,12 @@ func TestDfDataDbJsonCfg(t *testing.T) { Replication_conns: &[]string{}, Remote_conns: &[]string{}, Opts: map[string]interface{}{ - utils.RedisSentinelNameCfg: "", - utils.QueryTimeoutCfg: "10s", - utils.RedisClusterCfg: false, - utils.ClusterOnDownDelayCfg: "0", - utils.ClusterSyncCfg: "5s", + utils.RedisSentinelNameCfg: "", + utils.QueryTimeoutCfg: "10s", + utils.RedisClusterCfg: false, + utils.RedisClusterOnDownDelayCfg: "0", + utils.RedisClusterSyncCfg: "5s", + utils.RedisTLS: false, }, Items: &map[string]*ItemOptJson{ utils.MetaAccounts: { @@ -1628,10 +1629,10 @@ func TestDfMigratorCfg(t *testing.T) { Users_filters: &[]string{}, Out_storDB_opts: make(map[string]interface{}), Out_dataDB_opts: map[string]interface{}{ - utils.RedisSentinelNameCfg: "", - utils.RedisClusterCfg: false, - utils.ClusterSyncCfg: "5s", - utils.ClusterOnDownDelayCfg: "0", + utils.RedisSentinelNameCfg: "", + utils.RedisClusterCfg: false, + utils.RedisClusterSyncCfg: "5s", + utils.RedisClusterOnDownDelayCfg: "0", }, } if cfg, err := dfCgrJSONCfg.MigratorCfgJson(); err != nil { diff --git a/config/config_test.go b/config/config_test.go index 6ffd8b06e..82ce3c0b1 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -1732,10 +1732,10 @@ func TestCgrMigratorCfgDefault(t *testing.T) { OutStorDBUser: "cgrates", OutStorDBPassword: "", OutDataDBOpts: map[string]interface{}{ - utils.ClusterOnDownDelayCfg: "0", - utils.ClusterSyncCfg: "5s", - utils.RedisClusterCfg: false, - utils.RedisSentinelNameCfg: "", + utils.RedisClusterOnDownDelayCfg: "0", + utils.RedisClusterSyncCfg: "5s", + utils.RedisClusterCfg: false, + utils.RedisSentinelNameCfg: "", }, OutStorDBOpts: make(map[string]interface{}), } diff --git a/config/migratorcfg_test.go b/config/migratorcfg_test.go index f900ac468..23c33209d 100644 --- a/config/migratorcfg_test.go +++ b/config/migratorcfg_test.go @@ -40,8 +40,8 @@ func TestMigratorCgrCfgloadFromJsonCfg(t *testing.T) { Out_storDB_user: utils.StringPointer(utils.CGRATES), Out_storDB_password: utils.StringPointer(utils.EmptyString), Out_dataDB_opts: map[string]interface{}{ - utils.RedisClusterCfg: true, - utils.ClusterSyncCfg: "10s", + utils.RedisClusterCfg: true, + utils.RedisClusterSyncCfg: "10s", }, Out_storDB_opts: map[string]interface{}{ utils.RedisClusterCfg: true, @@ -62,10 +62,10 @@ func TestMigratorCgrCfgloadFromJsonCfg(t *testing.T) { OutStorDBUser: utils.CGRATES, OutStorDBPassword: utils.EmptyString, OutDataDBOpts: map[string]interface{}{ - utils.RedisSentinelNameCfg: utils.EmptyString, - utils.RedisClusterCfg: true, - utils.ClusterSyncCfg: "10s", - utils.ClusterOnDownDelayCfg: "0", + utils.RedisSentinelNameCfg: utils.EmptyString, + utils.RedisClusterCfg: true, + utils.RedisClusterSyncCfg: "10s", + utils.RedisClusterOnDownDelayCfg: "0", }, OutStorDBOpts: map[string]interface{}{ utils.RedisClusterCfg: true, @@ -91,8 +91,8 @@ func TestMigratorCgrCfgAsMapInterface(t *testing.T) { "users_filters":["users","filters","Account"], "out_datadb_opts":{ "redis_cluster": true, - "cluster_sync": "2s", - "cluster_ondown_delay": "1", + "redis_cluster_sync": "2s", + "redis_cluster_ondown_delay": "1", }, }, }` @@ -113,10 +113,10 @@ func TestMigratorCgrCfgAsMapInterface(t *testing.T) { utils.UsersFiltersCfg: []string{"users", "filters", "Account"}, utils.OutStorDBOptsCfg: map[string]interface{}{}, utils.OutDataDBOptsCfg: map[string]interface{}{ - utils.RedisSentinelNameCfg: "", - utils.RedisClusterCfg: true, - utils.ClusterSyncCfg: "2s", - utils.ClusterOnDownDelayCfg: "1", + utils.RedisSentinelNameCfg: "", + utils.RedisClusterCfg: true, + utils.RedisClusterSyncCfg: "2s", + utils.RedisClusterOnDownDelayCfg: "1", }, } if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil { @@ -152,10 +152,10 @@ func TestMigratorCgrCfgAsMapInterface1(t *testing.T) { utils.UsersFiltersCfg: []string{"users", "filters", "Account"}, utils.OutStorDBOptsCfg: map[string]interface{}{}, utils.OutDataDBOptsCfg: map[string]interface{}{ - utils.RedisSentinelNameCfg: "out_datadb_redis_sentinel", - utils.RedisClusterCfg: false, - utils.ClusterSyncCfg: "5s", - utils.ClusterOnDownDelayCfg: "0", + utils.RedisSentinelNameCfg: "out_datadb_redis_sentinel", + utils.RedisClusterCfg: false, + utils.RedisClusterSyncCfg: "5s", + utils.RedisClusterOnDownDelayCfg: "0", }, } if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil { @@ -186,10 +186,10 @@ func TestMigratorCgrCfgAsMapInterface2(t *testing.T) { utils.UsersFiltersCfg: []string{}, utils.OutStorDBOptsCfg: map[string]interface{}{}, utils.OutDataDBOptsCfg: map[string]interface{}{ - utils.RedisSentinelNameCfg: "", - utils.RedisClusterCfg: false, - utils.ClusterSyncCfg: "5s", - utils.ClusterOnDownDelayCfg: "0", + utils.RedisSentinelNameCfg: "", + utils.RedisClusterCfg: false, + utils.RedisClusterSyncCfg: "5s", + utils.RedisClusterOnDownDelayCfg: "0", }, } if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil { diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index aa247dec5..26070b940 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -83,9 +83,10 @@ // "opts":{ // "redis_sentinel": "", // the name of sentinel when used // "redis_cluster": false, // if enabled the datadb will try to connect to the redis cluster -// "cluster_sync": "5s", // the sync interval for the redis cluster -// "cluster_ondown_delay": "0", // the delay before executing the commands if the redis cluster is in the CLUSTERDOWN state +// "redis_cluster_sync": "5s", // the sync interval for the redis cluster +// "redis_cluster_ondown_delay": "0", // the delay before executing the commands if the redis cluster is in the CLUSTERDOWN state // "query_timeout":"10s", +// "redis_tls": false, // if true it will use a tls connection and use the client certificate, key and ca_certificate for tls connection // } // }, @@ -222,6 +223,7 @@ // "*rpc_connections": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // RPC connections caching // "*uch": {"limit": -1, "ttl": "3h", "static_ttl": false, "replicate": false}, // User cache // "*stir": {"limit": -1, "ttl": "3h", "static_ttl": false, "replicate": false}, // stirShaken cache keys +// "*apiban":{"limit": -1, "ttl": "2m", "static_ttl": false, "replicate": false}, // // only for *internal database // "*versions": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // for version storing @@ -316,6 +318,7 @@ // "concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited // "source_path": "/var/spool/cgrates/ers/in", // read data from this path // "processed_path": "/var/spool/cgrates/ers/out", // move processed data here +// "opts": {}, // "xml_root_path": "", // path towards one event in case of XML CDRs // "tenant": "", // tenant used by import // "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> @@ -351,6 +354,7 @@ // "id": "*default", // identifier of the EventReader profile // "type": "*none", // exporter type // "export_path": "/var/spool/cgrates/ees", // path where the exported events will be placed +// "opts": {}, // extra options for exporter // "tenant": "", // tenant used in filterS.Pass // "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> // "filters": [], // limit parsing based on the filters @@ -512,7 +516,10 @@ // "attributes": { // AttributeS config -// "enabled": false, // starts attribute service: . +// "enabled": false, // starts attribute service: +// "stats_conns": [], // connections to StatS, empty to disable: <""|*internal|$rpc_conns_id> +// "resources_conns": [], // connections to ResourceS, empty to disable: <""|*internal|$rpc_conns_id> +// "apiers_conns": [], // connections to ApierS, empty to disable: <""|*internal|$rpc_conns_id> // "indexed_selects": true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -844,8 +851,8 @@ // "out_datadb_opts":{ // "redis_sentinel": "", // "redis_cluster": false, -// "cluster_sync": "5s", -// "cluster_ondown_delay": "0", +// "redis_cluster_sync": "5s", +// "redis_cluster_ondown_delay": "0", // }, // "out_stordb_opts":{}, // }, @@ -880,6 +887,7 @@ // "caches_conns":["*internal"], // "scheduler_conns": [], // connections to SchedulerS for reloads // "attributes_conns": [], // connections to AttributeS for CDRExporter +// "ees_conns": [], // connections to EEs // }, @@ -893,10 +901,11 @@ // "rate_indexed_selects": true, // enable profile matching exclusively on indexes // //"rate_string_indexed_fields": [], // query indexes based on these fields for faster processing // "rate_prefix_indexed_fields": [], // query indexes based on these fields for faster processing -// "rate_suffix_indexed_fields": [], // query indexes based on these fields for faster processing +// "rate_suffix_indexed_fields": [], // query indexes based on these fields for faster processing // "rate_nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) // }, + // "sip_agent": { // SIP Agents, only used for redirections // "enabled": false, // enables the SIP agent: // "listen": "127.0.0.1:5060", // address where to listen for SIP requests @@ -908,6 +917,7 @@ // ], // }, + // "templates": { // "*err": [ // {"tag": "SessionId", "path": "*rep.Session-Id", "type": "*variable", @@ -969,4 +979,17 @@ // ], // }, + +// "configs": { +// "enabled": false, +// "url": "/configs/", // configs url +// "root_dir": "/var/spool/cgrates/configs", // root directory in case of calling /configs request +// }, + + +// "apiban": { +// "enabled": false, +// "keys": [], +// }, + } diff --git a/data/conf/samples/tutredis_cluster/cgrates.json b/data/conf/samples/tutredis_cluster/cgrates.json index d1bb323df..78096f378 100755 --- a/data/conf/samples/tutredis_cluster/cgrates.json +++ b/data/conf/samples/tutredis_cluster/cgrates.json @@ -21,7 +21,7 @@ "db_name": "10", // data_db database name to connect to "opts": { "redis_cluster": true, - "cluster_sync": "100ms", // the sync interval for the redis cluster + "redis_cluster_sync": "100ms", // the sync interval for the redis cluster }, }, diff --git a/engine/storage_utils.go b/engine/storage_utils.go index aa8acb660..e92e74593 100644 --- a/engine/storage_utils.go +++ b/engine/storage_utils.go @@ -48,10 +48,10 @@ func NewDataDBConn(dbType, host, port, name, user, return } var clusterSync, clusterOnDownDelay time.Duration - if clusterSync, err = utils.IfaceAsDuration(opts[utils.ClusterSyncCfg]); err != nil { + if clusterSync, err = utils.IfaceAsDuration(opts[utils.RedisClusterSyncCfg]); err != nil { return } - if clusterOnDownDelay, err = utils.IfaceAsDuration(opts[utils.ClusterOnDownDelayCfg]); err != nil { + if clusterOnDownDelay, err = utils.IfaceAsDuration(opts[utils.RedisClusterOnDownDelayCfg]); err != nil { return } d, err = NewRedisStorage(host, dbNo, user, pass, marshaler, diff --git a/packages/debian/changelog b/packages/debian/changelog index 1456fe8ab..54caff481 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -110,6 +110,7 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium * [Templates] Added new data converter: *unixtime * [ActionsS] Add prefix *acnt and *act to cdrLog action * [AttributeS] Add support for *prefix and *suffix type + * [ConfigS] Add "redis_" prefix to "dataDB" option for redis -- DanB Wed, 19 Feb 2020 13:25:52 +0200 diff --git a/services/datadb.go b/services/datadb.go index 1139d00d3..3131cde82 100644 --- a/services/datadb.go +++ b/services/datadb.go @@ -160,8 +160,8 @@ func (db *DataDBService) needsConnectionReload() bool { return db.oldDBCfg.DataDbType == utils.REDIS && (db.oldDBCfg.Opts[utils.RedisSentinelNameCfg] != db.cfg.DataDbCfg().Opts[utils.RedisSentinelNameCfg] || db.oldDBCfg.Opts[utils.RedisClusterCfg] != db.cfg.DataDbCfg().Opts[utils.RedisClusterCfg] || - db.oldDBCfg.Opts[utils.ClusterSyncCfg] != db.cfg.DataDbCfg().Opts[utils.ClusterSyncCfg] || - db.oldDBCfg.Opts[utils.ClusterOnDownDelayCfg] != db.cfg.DataDbCfg().Opts[utils.ClusterOnDownDelayCfg]) + db.oldDBCfg.Opts[utils.RedisClusterSyncCfg] != db.cfg.DataDbCfg().Opts[utils.RedisClusterSyncCfg] || + db.oldDBCfg.Opts[utils.RedisClusterOnDownDelayCfg] != db.cfg.DataDbCfg().Opts[utils.RedisClusterOnDownDelayCfg]) } // GetDMChan returns the DataManager chanel diff --git a/services/datadb_it_test.go b/services/datadb_it_test.go index ae0f99468..ce898fdb0 100644 --- a/services/datadb_it_test.go +++ b/services/datadb_it_test.go @@ -81,11 +81,11 @@ func TestDataDBReload(t *testing.T) { DataDbName: "10", DataDbUser: "cgrates", Opts: map[string]interface{}{ - utils.QueryTimeoutCfg: "10s", - utils.ClusterOnDownDelayCfg: "0", - utils.ClusterSyncCfg: "5s", - utils.RedisClusterCfg: false, - utils.RedisSentinelNameCfg: "", + utils.QueryTimeoutCfg: "10s", + utils.RedisClusterOnDownDelayCfg: "0", + utils.RedisClusterSyncCfg: "5s", + utils.RedisClusterCfg: false, + utils.RedisSentinelNameCfg: "", }, RmtConns: []string{}, RplConns: []string{}, diff --git a/utils/consts.go b/utils/consts.go index 3a24290bc..080abd94a 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -1912,18 +1912,19 @@ const ( // DataDbCfg const ( - DataDbTypeCfg = "db_type" - DataDbHostCfg = "db_host" - DataDbPortCfg = "db_port" - DataDbNameCfg = "db_name" - DataDbUserCfg = "db_user" - DataDbPassCfg = "db_password" - RedisSentinelNameCfg = "redis_sentinel" - RmtConnsCfg = "remote_conns" - RplConnsCfg = "replication_conns" - RedisClusterCfg = "redis_cluster" - ClusterSyncCfg = "cluster_sync" - ClusterOnDownDelayCfg = "cluster_ondown_delay" + DataDbTypeCfg = "db_type" + DataDbHostCfg = "db_host" + DataDbPortCfg = "db_port" + DataDbNameCfg = "db_name" + DataDbUserCfg = "db_user" + DataDbPassCfg = "db_password" + RedisSentinelNameCfg = "redis_sentinel" + RmtConnsCfg = "remote_conns" + RplConnsCfg = "replication_conns" + RedisClusterCfg = "redis_cluster" + RedisClusterSyncCfg = "redis_cluster_sync" + RedisClusterOnDownDelayCfg = "redis_cluster_ondown_delay" + RedisTLS = "redis_tls" ) // ItemOpt