mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 15:48:44 +05:00
Connect to dispatcher only when the call is made
This commit is contained in:
committed by
Dan Christian Bogos
parent
530dd6fa59
commit
72d1e7fd2f
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/ltcache"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -2958,20 +2957,10 @@ func (dm *DataManager) GetDispatcherHost(tenant, id string, cacheRead, cacheWrit
|
||||
}
|
||||
}
|
||||
if cacheWrite {
|
||||
cfg := config.CgrConfig()
|
||||
if dH.rpcConn, err = NewRPCPool( // send it wil lazy connect on true and try to connect only when the call is make
|
||||
rpcclient.PoolFirst,
|
||||
cfg.TlsCfg().ClientKey,
|
||||
cfg.TlsCfg().ClientCerificate, cfg.TlsCfg().CaCertificate,
|
||||
cfg.GeneralCfg().ConnectAttempts, cfg.GeneralCfg().Reconnects,
|
||||
cfg.GeneralCfg().ConnectTimeout, cfg.GeneralCfg().ReplyTimeout,
|
||||
dH.Conns, IntRPC.GetInternalChanel(), true); err != nil {
|
||||
if err = Cache.Set(utils.CacheDispatcherHosts, tntID, dH, nil,
|
||||
cacheCommit(transactionID), transactionID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if errCh := Cache.Set(utils.CacheDispatcherHosts, tntID, dH, nil,
|
||||
cacheCommit(transactionID), transactionID); errCh != nil {
|
||||
return nil, errCh
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user