From f495a10c3be25f169c657842bed362d768789e44 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 26 May 2022 17:10:16 +0300 Subject: [PATCH] Remove json tags and rename the new option to be consistent with the others --- config/config_json_test.go | 72 +++++++++++++------------ config/generalcfg.go | 4 +- config/kamagentcfg.go | 4 +- config/libconfig_json.go | 106 ++++++++++++++++++------------------- config/rpcconn.go | 4 +- config/sessionscfg.go | 8 +-- 6 files changed, 101 insertions(+), 97 deletions(-) diff --git a/config/config_json_test.go b/config/config_json_test.go index dec4529d4..53da9df43 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -29,29 +29,30 @@ import ( func TestDfGeneralJsonCfg(t *testing.T) { eCfg := &GeneralJsonCfg{ - Node_id: utils.StringPointer(""), - Logger: utils.StringPointer(utils.MetaSysLog), - Log_level: utils.IntPointer(utils.LOGLEVEL_INFO), - Rounding_decimals: utils.IntPointer(5), - Dbdata_encoding: utils.StringPointer("*msgpack"), - Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"), - Poster_attempts: utils.IntPointer(3), - Failed_posts_dir: utils.StringPointer("/var/spool/cgrates/failed_posts"), - Failed_posts_ttl: utils.StringPointer("5s"), - Default_request_type: utils.StringPointer(utils.MetaRated), - Default_category: utils.StringPointer("call"), - Default_tenant: utils.StringPointer("cgrates.org"), - Default_caching: utils.StringPointer(utils.MetaReload), - Default_timezone: utils.StringPointer("Local"), - Connect_attempts: utils.IntPointer(5), - Reconnects: utils.IntPointer(-1), - Connect_timeout: utils.StringPointer("1s"), - Reply_timeout: utils.StringPointer("2s"), - Locking_timeout: utils.StringPointer("0"), - Digest_separator: utils.StringPointer(","), - Digest_equal: utils.StringPointer(":"), - Rsr_separator: utils.StringPointer(";"), - Max_parallel_conns: utils.IntPointer(100), + Node_id: utils.StringPointer(""), + Logger: utils.StringPointer(utils.MetaSysLog), + Log_level: utils.IntPointer(utils.LOGLEVEL_INFO), + Rounding_decimals: utils.IntPointer(5), + Dbdata_encoding: utils.StringPointer("*msgpack"), + Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"), + Poster_attempts: utils.IntPointer(3), + Failed_posts_dir: utils.StringPointer("/var/spool/cgrates/failed_posts"), + Failed_posts_ttl: utils.StringPointer("5s"), + Default_request_type: utils.StringPointer(utils.MetaRated), + Default_category: utils.StringPointer("call"), + Default_tenant: utils.StringPointer("cgrates.org"), + Default_caching: utils.StringPointer(utils.MetaReload), + Default_timezone: utils.StringPointer("Local"), + Connect_attempts: utils.IntPointer(5), + Reconnects: utils.IntPointer(-1), + Max_reconnect_interval: utils.StringPointer(utils.EmptyString), + Connect_timeout: utils.StringPointer("1s"), + Reply_timeout: utils.StringPointer("2s"), + Locking_timeout: utils.StringPointer("0"), + Digest_separator: utils.StringPointer(","), + Digest_equal: utils.StringPointer(":"), + Rsr_separator: utils.StringPointer(";"), + Max_parallel_conns: utils.IntPointer(100), } dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON)) if err != nil { @@ -862,10 +863,11 @@ func TestFsAgentJsonCfg(t *testing.T) { Max_wait_connection: utils.StringPointer("2s"), Event_socket_conns: &[]*FsConnJsonCfg{ { - Address: utils.StringPointer("127.0.0.1:8021"), - Password: utils.StringPointer("ClueCon"), - Reconnects: utils.IntPointer(5), - Alias: utils.StringPointer(""), + Address: utils.StringPointer("127.0.0.1:8021"), + Password: utils.StringPointer("ClueCon"), + Reconnects: utils.IntPointer(5), + Max_reconnect_interval: utils.StringPointer(utils.EmptyString), + Alias: utils.StringPointer(""), }}, } dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON)) @@ -886,8 +888,9 @@ func TestKamAgentJsonCfg(t *testing.T) { Create_cdr: utils.BoolPointer(false), Evapi_conns: &[]*KamConnJsonCfg{ { - Address: utils.StringPointer("127.0.0.1:8448"), - Reconnects: utils.IntPointer(5), + Address: utils.StringPointer("127.0.0.1:8448"), + Reconnects: utils.IntPointer(5), + Max_reconnect_interval: utils.StringPointer(utils.EmptyString), }, }, Timezone: utils.StringPointer(utils.EmptyString), @@ -911,11 +914,12 @@ func TestAsteriskAgentJsonCfg(t *testing.T) { Create_cdr: utils.BoolPointer(false), Asterisk_conns: &[]*AstConnJsonCfg{ { - Address: utils.StringPointer("127.0.0.1:8088"), - User: utils.StringPointer("cgrates"), - Password: utils.StringPointer("CGRateS.org"), - Connect_attempts: utils.IntPointer(3), - Reconnects: utils.IntPointer(5), + Address: utils.StringPointer("127.0.0.1:8088"), + User: utils.StringPointer("cgrates"), + Password: utils.StringPointer("CGRateS.org"), + Connect_attempts: utils.IntPointer(3), + Reconnects: utils.IntPointer(5), + Max_reconnect_interval: utils.StringPointer(utils.EmptyString), }, }, } diff --git a/config/generalcfg.go b/config/generalcfg.go index 4e804cde0..8c5b5c8d7 100644 --- a/config/generalcfg.go +++ b/config/generalcfg.go @@ -86,8 +86,8 @@ func (gencfg *GeneralCfg) loadFromJSONCfg(jsnGeneralCfg *GeneralJsonCfg) (err er if jsnGeneralCfg.Reconnects != nil { gencfg.Reconnects = *jsnGeneralCfg.Reconnects } - if jsnGeneralCfg.MaxReconnectInterval != nil { - if gencfg.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnGeneralCfg.MaxReconnectInterval); err != nil { + if jsnGeneralCfg.Max_reconnect_interval != nil { + if gencfg.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnGeneralCfg.Max_reconnect_interval); err != nil { return err } } diff --git a/config/kamagentcfg.go b/config/kamagentcfg.go index 16c1a46ac..df95b5196 100644 --- a/config/kamagentcfg.go +++ b/config/kamagentcfg.go @@ -55,8 +55,8 @@ func (kamCfg *KamConnCfg) loadFromJSONCfg(jsnCfg *KamConnJsonCfg) (err error) { if jsnCfg.Reconnects != nil { kamCfg.Reconnects = *jsnCfg.Reconnects } - if jsnCfg.MaxReconnectInterval != nil { - if kamCfg.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.MaxReconnectInterval); err != nil { + if jsnCfg.Max_reconnect_interval != nil { + if kamCfg.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Max_reconnect_interval); err != nil { return } } diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 5bc414b6d..963ebb8cc 100644 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -24,30 +24,30 @@ import ( // General config section type GeneralJsonCfg struct { - Node_id *string - Logger *string - Log_level *int - Rounding_decimals *int - Dbdata_encoding *string - Tpexport_dir *string - Poster_attempts *int - Failed_posts_dir *string - Failed_posts_ttl *string - Default_request_type *string - Default_category *string - Default_tenant *string - Default_timezone *string - Default_caching *string - Connect_attempts *int - Reconnects *int - MaxReconnectInterval *string `json:"max_reconnect_interval"` - Connect_timeout *string - Reply_timeout *string - Locking_timeout *string - Digest_separator *string - Digest_equal *string - Rsr_separator *string - Max_parallel_conns *int + Node_id *string + Logger *string + Log_level *int + Rounding_decimals *int + Dbdata_encoding *string + Tpexport_dir *string + Poster_attempts *int + Failed_posts_dir *string + Failed_posts_ttl *string + Default_request_type *string + Default_category *string + Default_tenant *string + Default_timezone *string + Default_caching *string + Connect_attempts *int + Reconnects *int + Max_reconnect_interval *string + Connect_timeout *string + Reply_timeout *string + Locking_timeout *string + Digest_separator *string + Digest_equal *string + Rsr_separator *string + Max_parallel_conns *int } // Listen config section @@ -387,11 +387,11 @@ type FreeswitchAgentJsonCfg struct { // Represents one connection instance towards FreeSWITCH type FsConnJsonCfg struct { - Address *string - Password *string - Reconnects *int - MaxReconnectInterval *string `json:"max_reconnect_interval"` - Alias *string + Address *string + Password *string + Reconnects *int + Max_reconnect_interval *string + Alias *string } type RPCConnsJson struct { @@ -402,29 +402,29 @@ type RPCConnsJson struct { // Represents one connection instance towards a rater/cdrs server type RemoteHostJson struct { - Id *string - Address *string - Transport *string - Synchronous *bool - Tls *bool - Key_path *string - Cert_path *string - Ca_path *string - Conn_attempts *int - Reconnects *int - MaxReconnectInterval *string `json:"max_reconnect_interval"` - Connect_timeout *string - Reply_timeout *string + Id *string + Address *string + Transport *string + Synchronous *bool + Tls *bool + Key_path *string + Cert_path *string + Ca_path *string + Conn_attempts *int + Reconnects *int + Max_reconnect_interval *string + Connect_timeout *string + Reply_timeout *string } type AstConnJsonCfg struct { - Alias *string - Address *string - User *string - Password *string - Connect_attempts *int - Reconnects *int - MaxReconnectInterval *string `json:"max_reconnect_interval"` + Alias *string + Address *string + User *string + Password *string + Connect_attempts *int + Reconnects *int + Max_reconnect_interval *string } type AsteriskAgentJsonCfg struct { @@ -458,10 +458,10 @@ type KamAgentJsonCfg struct { // Represents one connection instance towards Kamailio type KamConnJsonCfg struct { - Alias *string - Address *string - Reconnects *int - MaxReconnectInterval *string `json:"max_reconnect_interval"` + Alias *string + Address *string + Reconnects *int + Max_reconnect_interval *string } // Represents one connection instance towards OpenSIPS diff --git a/config/rpcconn.go b/config/rpcconn.go index a5aebc1d8..225a5da3b 100644 --- a/config/rpcconn.go +++ b/config/rpcconn.go @@ -167,8 +167,8 @@ func (rh *RemoteHost) loadFromJSONCfg(jsnCfg *RemoteHostJson) (err error) { if jsnCfg.Reconnects != nil { rh.Reconnects = *jsnCfg.Reconnects } - if jsnCfg.MaxReconnectInterval != nil { - if rh.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.MaxReconnectInterval); err != nil { + if jsnCfg.Max_reconnect_interval != nil { + if rh.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Max_reconnect_interval); err != nil { return err } } diff --git a/config/sessionscfg.go b/config/sessionscfg.go index f1c4a2f01..77eedbcd4 100644 --- a/config/sessionscfg.go +++ b/config/sessionscfg.go @@ -58,8 +58,8 @@ func (fs *FsConnCfg) loadFromJSONCfg(jsnCfg *FsConnJsonCfg) (err error) { if jsnCfg.Reconnects != nil { fs.Reconnects = *jsnCfg.Reconnects } - if jsnCfg.MaxReconnectInterval != nil { - if fs.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.MaxReconnectInterval); err != nil { + if jsnCfg.Max_reconnect_interval != nil { + if fs.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Max_reconnect_interval); err != nil { return } } @@ -738,8 +738,8 @@ func (aConnCfg *AsteriskConnCfg) loadFromJSONCfg(jsnCfg *AstConnJsonCfg) (err er if jsnCfg.Reconnects != nil { aConnCfg.Reconnects = *jsnCfg.Reconnects } - if jsnCfg.MaxReconnectInterval != nil { - if aConnCfg.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.MaxReconnectInterval); err != nil { + if jsnCfg.Max_reconnect_interval != nil { + if aConnCfg.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Max_reconnect_interval); err != nil { return } }