diff --git a/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv b/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv index e8a2642e7..5a8575443 100644 --- a/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv +++ b/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv @@ -1,2 +1,2 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,"1m","2m",false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,, diff --git a/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv b/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv index ab80c356c..a237ab4b6 100644 --- a/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv +++ b/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv @@ -1,3 +1,3 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,Self,*internal,,1,3,"1m","2m",false,,, -cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,"1m","2m",false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,Self,*internal,,1,3,,"1m","2m",false,,, +cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,, diff --git a/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv b/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv index ab80c356c..a237ab4b6 100644 --- a/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv +++ b/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv @@ -1,3 +1,3 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,Self,*internal,,1,3,"1m","2m",false,,, -cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,"1m","2m",false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,Self,*internal,,1,3,,"1m","2m",false,,, +cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,, diff --git a/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv b/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv index ab80c356c..a237ab4b6 100644 --- a/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv +++ b/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv @@ -1,3 +1,3 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,Self,*internal,,1,3,"1m","2m",false,,, -cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,"1m","2m",false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,Self,*internal,,1,3,,"1m","2m",false,,, +cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,, diff --git a/data/tariffplans/dispatchers/DispatcherHosts.csv b/data/tariffplans/dispatchers/DispatcherHosts.csv index 665a0748b..1eee6f8c3 100644 --- a/data/tariffplans/dispatchers/DispatcherHosts.csv +++ b/data/tariffplans/dispatchers/DispatcherHosts.csv @@ -1,5 +1,5 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,SELF,*internal,,1,3,"1m","2m",false,,, -cgrates.org,ALL,127.0.0.1:6012,*json,1,3,"1m","2m",false,,, -cgrates.org,ALL2,127.0.0.1:7012,*json,1,3,"1m","2m",false,,, -cgrates.org,NonexistingHost,127.0.0.1:10012,*json,1,3,"1m","2m",false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,, +cgrates.org,ALL,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,, +cgrates.org,ALL2,127.0.0.1:7012,*json,1,3,,"1m","2m",false,,, +cgrates.org,NonexistingHost,127.0.0.1:10012,*json,1,3,,"1m","2m",false,,, diff --git a/data/tariffplans/dispatchers_gob/DispatcherHosts.csv b/data/tariffplans/dispatchers_gob/DispatcherHosts.csv index 7476906b7..fc24a9a96 100644 --- a/data/tariffplans/dispatchers_gob/DispatcherHosts.csv +++ b/data/tariffplans/dispatchers_gob/DispatcherHosts.csv @@ -1,5 +1,5 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,SELF,*internal,,1,3,"1m","2m",false,,, -cgrates.org,ALL,127.0.0.1:6013,*gob,1,3,"1m","2m",false,,, -cgrates.org,ALL2,127.0.0.1:7013,*gob,1,3,"1m","2m",false,,, -cgrates.org,NonexistingHost,127.0.0.1:10012,*json,1,3,"1m","2m",false,,, \ No newline at end of file +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,, +cgrates.org,ALL,127.0.0.1:6013,*gob,1,3,,"1m","2m",false,,, +cgrates.org,ALL2,127.0.0.1:7013,*gob,1,3,,"1m","2m",false,,, +cgrates.org,NonexistingHost,127.0.0.1:10012,*json,1,3,,"1m","2m",false,,, \ No newline at end of file diff --git a/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv b/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv index 508ce5256..af77eb044 100644 --- a/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv +++ b/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv @@ -1,4 +1,4 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,AU_SITE,127.0.0.1:3012,*json,1,3,"1m","2m",false,,, -cgrates.org,US_SITE,127.0.0.1:4012,*json,1,3,"1m","2m",false,,, -cgrates.org,SELF,*internal,,1,3,"1m","2m",false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,AU_SITE,127.0.0.1:3012,*json,1,3,,"1m","2m",false,,, +cgrates.org,US_SITE,127.0.0.1:4012,*json,1,3,,"1m","2m",false,,, +cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,, diff --git a/data/tariffplans/precache/DispatcherHosts.csv b/data/tariffplans/precache/DispatcherHosts.csv index f3bd855e4..15275cb62 100644 --- a/data/tariffplans/precache/DispatcherHosts.csv +++ b/data/tariffplans/precache/DispatcherHosts.csv @@ -1,2 +1,2 @@ -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,SELF,*internal,,1,3,"1m","2m",false,,, \ No newline at end of file +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,, \ No newline at end of file diff --git a/engine/libtest.go b/engine/libtest.go index aace000d1..04d5d50b9 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -278,8 +278,8 @@ cgrates.org,D1,*any,*string:~*req.Account:1001,2014-07-29T15:00:00Z,*first,,C1,* cgrates.org,D1,,,,*first,,C2,*lt:~*req.Usage:10,10,false,192.168.56.204, ` DispatcherHostCSVContent = ` -#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],ConnectTimeout[6],ReplyTimeout[7],Tls[8],ClientKey[9],ClientCertificate[10],CaCertificate[11] -cgrates.org,ALL,127.0.0.1:6012,*json,1,3,1m,2m,false,,, +#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12] +cgrates.org,ALL,127.0.0.1:6012,*json,1,3,5m,1m,2m,false,,, ` ) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 79f57e48f..87cb700f9 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -1398,13 +1398,14 @@ func TestLoadDispatcherHosts(t *testing.T) { Tenant: "cgrates.org", ID: "ALL", Conn: &utils.TPDispatcherHostConn{ - Address: "127.0.0.1:6012", - Transport: utils.MetaJSON, - ConnectAttempts: 1, - Reconnects: 3, - ConnectTimeout: 1 * time.Minute, - ReplyTimeout: 2 * time.Minute, - TLS: false, + Address: "127.0.0.1:6012", + Transport: utils.MetaJSON, + ConnectAttempts: 1, + Reconnects: 3, + MaxReconnectInterval: 5 * time.Minute, + ConnectTimeout: 1 * time.Minute, + ReplyTimeout: 2 * time.Minute, + TLS: false, }, } diff --git a/engine/model_helpers.go b/engine/model_helpers.go index be3be8f5a..a6b1f158e 100644 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -2804,7 +2804,7 @@ type DispatcherHostMdls []*DispatcherHostMdl // CSVHeader return the header for csv fields as a slice of string func (tps DispatcherHostMdls) CSVHeader() (result []string) { - return []string{"#" + utils.Tenant, utils.ID, utils.Address, utils.Transport, utils.SynchronousCfg, utils.ConnectAttemptsCfg, utils.ReconnectsCfg, utils.ConnectTimeoutCfg, utils.ReplyTimeoutCfg, utils.TLS, utils.ClientKeyCfg, utils.ClientCerificateCfg, utils.CaCertificateCfg} + return []string{"#" + utils.Tenant, utils.ID, utils.Address, utils.Transport, utils.SynchronousCfg, utils.ConnectAttemptsCfg, utils.ReconnectsCfg, utils.MaxReconnectIntervalCfg, utils.ConnectTimeoutCfg, utils.ReplyTimeoutCfg, utils.TLS, utils.ClientKeyCfg, utils.ClientCerificateCfg, utils.CaCertificateCfg} } func (tps DispatcherHostMdls) AsTPDispatcherHosts() (result []*utils.TPDispatcherHost, err error) { @@ -2832,6 +2832,11 @@ func (tps DispatcherHostMdls) AsTPDispatcherHosts() (result []*utils.TPDispatche CaCertificate: tp.CaCertificate, }, } + if tp.MaxReconnectInterval != utils.EmptyString { + if hostsMap[tntId].Conn.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(tp.MaxReconnectInterval); err != nil { + return nil, err + } + } if tp.ConnectTimeout != utils.EmptyString { if hostsMap[tntId].Conn.ConnectTimeout, err = utils.ParseDurationWithNanosecs(tp.ConnectTimeout); err != nil { return nil, err @@ -2855,19 +2860,20 @@ func APItoModelTPDispatcherHost(tpDPH *utils.TPDispatcherHost) (mdls *Dispatcher return } return &DispatcherHostMdl{ - Tpid: tpDPH.TPid, - Tenant: tpDPH.Tenant, - ID: tpDPH.ID, - Address: tpDPH.Conn.Address, - Transport: tpDPH.Conn.Transport, - ConnectAttempts: tpDPH.Conn.ConnectAttempts, - Reconnects: tpDPH.Conn.Reconnects, - ConnectTimeout: tpDPH.Conn.ConnectTimeout.String(), - ReplyTimeout: tpDPH.Conn.ReplyTimeout.String(), - TLS: tpDPH.Conn.TLS, - ClientKey: tpDPH.Conn.ClientKey, - ClientCertificate: tpDPH.Conn.ClientCertificate, - CaCertificate: tpDPH.Conn.CaCertificate, + Tpid: tpDPH.TPid, + Tenant: tpDPH.Tenant, + ID: tpDPH.ID, + Address: tpDPH.Conn.Address, + Transport: tpDPH.Conn.Transport, + ConnectAttempts: tpDPH.Conn.ConnectAttempts, + Reconnects: tpDPH.Conn.Reconnects, + MaxReconnectInterval: tpDPH.Conn.MaxReconnectInterval.String(), + ConnectTimeout: tpDPH.Conn.ConnectTimeout.String(), + ReplyTimeout: tpDPH.Conn.ReplyTimeout.String(), + TLS: tpDPH.Conn.TLS, + ClientKey: tpDPH.Conn.ClientKey, + ClientCertificate: tpDPH.Conn.ClientCertificate, + CaCertificate: tpDPH.Conn.CaCertificate, } } @@ -2878,17 +2884,18 @@ func APItoDispatcherHost(tpDPH *utils.TPDispatcherHost) (dpp *DispatcherHost) { return &DispatcherHost{ Tenant: tpDPH.Tenant, RemoteHost: &config.RemoteHost{ - ID: tpDPH.ID, - Address: tpDPH.Conn.Address, - Transport: tpDPH.Conn.Transport, - ConnectAttempts: tpDPH.Conn.ConnectAttempts, - Reconnects: tpDPH.Conn.Reconnects, - ConnectTimeout: tpDPH.Conn.ConnectTimeout, - ReplyTimeout: tpDPH.Conn.ReplyTimeout, - TLS: tpDPH.Conn.TLS, - ClientKey: tpDPH.Conn.ClientKey, - ClientCertificate: tpDPH.Conn.ClientCertificate, - CaCertificate: tpDPH.Conn.CaCertificate, + ID: tpDPH.ID, + Address: tpDPH.Conn.Address, + Transport: tpDPH.Conn.Transport, + ConnectAttempts: tpDPH.Conn.ConnectAttempts, + Reconnects: tpDPH.Conn.Reconnects, + MaxReconnectInterval: tpDPH.Conn.MaxReconnectInterval, + ConnectTimeout: tpDPH.Conn.ConnectTimeout, + ReplyTimeout: tpDPH.Conn.ReplyTimeout, + TLS: tpDPH.Conn.TLS, + ClientKey: tpDPH.Conn.ClientKey, + ClientCertificate: tpDPH.Conn.ClientCertificate, + CaCertificate: tpDPH.Conn.CaCertificate, }, } } @@ -2898,16 +2905,17 @@ func DispatcherHostToAPI(dph *DispatcherHost) (tpDPH *utils.TPDispatcherHost) { Tenant: dph.Tenant, ID: dph.ID, Conn: &utils.TPDispatcherHostConn{ - Address: dph.Address, - Transport: dph.Transport, - ConnectAttempts: dph.ConnectAttempts, - Reconnects: dph.Reconnects, - ConnectTimeout: dph.ConnectTimeout, - ReplyTimeout: dph.ReplyTimeout, - TLS: dph.TLS, - ClientKey: dph.ClientKey, - ClientCertificate: dph.ClientCertificate, - CaCertificate: dph.CaCertificate, + Address: dph.Address, + Transport: dph.Transport, + ConnectAttempts: dph.ConnectAttempts, + Reconnects: dph.Reconnects, + MaxReconnectInterval: dph.MaxReconnectInterval, + ConnectTimeout: dph.ConnectTimeout, + ReplyTimeout: dph.ReplyTimeout, + TLS: dph.TLS, + ClientKey: dph.ClientKey, + ClientCertificate: dph.ClientCertificate, + CaCertificate: dph.CaCertificate, }, } } diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 1fd6898ec..efeb4368f 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -3825,7 +3825,7 @@ func TestAPItoModelTPDispatcher(t *testing.T) { func TestTPDispatcherHostsCSVHeader(t *testing.T) { tps := &DispatcherHostMdls{} - eOut := []string{"#" + utils.Tenant, utils.ID, utils.Address, utils.Transport, utils.SynchronousCfg, utils.ConnectAttemptsCfg, utils.ReconnectsCfg, utils.ConnectTimeoutCfg, utils.ReplyTimeoutCfg, utils.TLS, utils.ClientKeyCfg, utils.ClientCerificateCfg, utils.CaCertificateCfg} + eOut := []string{"#" + utils.Tenant, utils.ID, utils.Address, utils.Transport, utils.SynchronousCfg, utils.ConnectAttemptsCfg, utils.ReconnectsCfg, utils.MaxReconnectIntervalCfg, utils.ConnectTimeoutCfg, utils.ReplyTimeoutCfg, utils.TLS, utils.ClientKeyCfg, utils.ClientCerificateCfg, utils.CaCertificateCfg} if rcv := tps.CSVHeader(); !reflect.DeepEqual(rcv, eOut) { t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv)) } @@ -3987,18 +3987,19 @@ func TestAPItoModelTPDispatcherHost(t *testing.T) { }, } eOut := &DispatcherHostMdl{ - Address: "Address1", - Transport: "*json", - Tenant: "Tenant", - ID: "ID", - ConnectAttempts: 3, - Reconnects: 5, - ConnectTimeout: "1m0s", - ReplyTimeout: "2m0s", - TLS: true, - ClientKey: "client_key", - ClientCertificate: "client_certificate", - CaCertificate: "ca_certificate", + Address: "Address1", + Transport: "*json", + Tenant: "Tenant", + ID: "ID", + ConnectAttempts: 3, + Reconnects: 5, + MaxReconnectInterval: "0s", + ConnectTimeout: "1m0s", + ReplyTimeout: "2m0s", + TLS: true, + ClientKey: "client_key", + ClientCertificate: "client_certificate", + CaCertificate: "ca_certificate", } if rcv := APItoModelTPDispatcherHost(tpDPH); !reflect.DeepEqual(eOut, rcv) { t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv)) diff --git a/engine/models.go b/engine/models.go index ba78778dc..251af17df 100644 --- a/engine/models.go +++ b/engine/models.go @@ -496,21 +496,22 @@ func (DispatcherProfileMdl) TableName() string { } type DispatcherHostMdl struct { - PK uint `gorm:"primary_key"` - Tpid string // - Tenant string `index:"0" re:""` - ID string `index:"1" re:""` - Address string `index:"2" re:""` - Transport string `index:"3" re:""` - ConnectAttempts int `index:"4" re:""` - Reconnects int `index:"5" re:""` - ConnectTimeout string `index:"6" re:""` - ReplyTimeout string `index:"7" re:""` - TLS bool `index:"8" re:""` - ClientKey string `index:"9" re:""` - ClientCertificate string `index:"10" re:""` - CaCertificate string `index:"11" re:""` - CreatedAt time.Time + PK uint `gorm:"primary_key"` + Tpid string // + Tenant string `index:"0" re:""` + ID string `index:"1" re:""` + Address string `index:"2" re:""` + Transport string `index:"3" re:""` + ConnectAttempts int `index:"4" re:""` + Reconnects int `index:"5" re:""` + MaxReconnectInterval string `index:"6" re:""` + ConnectTimeout string `index:"7" re:""` + ReplyTimeout string `index:"8" re:""` + TLS bool `index:"9" re:""` + ClientKey string `index:"10" re:""` + ClientCertificate string `index:"11" re:""` + CaCertificate string `index:"12" re:""` + CreatedAt time.Time } func (DispatcherHostMdl) TableName() string { diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 998e94cff..926ee40f3 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -1110,16 +1110,17 @@ type TPDispatcherHost struct { // TPDispatcherHostConn is used in TPDispatcherHost type TPDispatcherHostConn struct { - Address string - Transport string - ConnectAttempts int - Reconnects int - ConnectTimeout time.Duration - ReplyTimeout time.Duration - TLS bool - ClientKey string - ClientCertificate string - CaCertificate string + Address string + Transport string + ConnectAttempts int + Reconnects int + MaxReconnectInterval time.Duration + ConnectTimeout time.Duration + ReplyTimeout time.Duration + TLS bool + ClientKey string + ClientCertificate string + CaCertificate string } type UsageInterval struct {