diff --git a/config/config.go b/config/config.go index 92eb52e44..95e7d7c85 100755 --- a/config/config.go +++ b/config/config.go @@ -349,7 +349,7 @@ func (cfg *CGRConfig) loadRPCConns(jsnCfg *CgrJsonCfg) (err error) { if jsnRpcConns, err = jsnCfg.RPCConnJsonCfg(); err != nil { return } - // hardoded the *internal and *localhost connections + // hardoded the *internal connection cfg.rpcConns[utils.MetaInternal] = &RPCConn{ Strategy: rpcclient.PoolFirst, PoolSize: 0, @@ -359,18 +359,8 @@ func (cfg *CGRConfig) loadRPCConns(jsnCfg *CgrJsonCfg) (err error) { }, }, } - cfg.rpcConns[utils.MetaLocalHost] = &RPCConn{ - Strategy: rpcclient.PoolFirst, - PoolSize: 0, - Conns: []*RemoteHost{ - &RemoteHost{ - Address: "127.0.0.1:2012", - Transport: utils.MetaJSON, - }, - }, - } for key, val := range jsnRpcConns { - cfg.rpcConns[key] = new(RPCConn) + cfg.rpcConns[key] = NewDfltRPCConn() if err = cfg.rpcConns[key].loadFromJsonCfg(val); err != nil { return } diff --git a/config/config_defaults.go b/config/config_defaults.go index a521c2034..65dee6949 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -53,7 +53,12 @@ const CGRATES_CFG_JSON = ` }, -"rpc_conns": {}, // rpc connections definitions +"rpc_conns": { + "*localhost": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2012", "transport":"*json"}], + }, +}, // rpc connections definitions "data_db": { // database used to store runtime data (eg: accounts) diff --git a/config/rpcconn.go b/config/rpcconn.go index a6c3a96bb..24de0e77c 100644 --- a/config/rpcconn.go +++ b/config/rpcconn.go @@ -18,6 +18,8 @@ along with this program. If not, see package config +import "github.com/cgrates/rpcclient" + // Returns the first cached default value for a RemoteHost connection func NewDfltRemoteHost() *RemoteHost { if dfltRemoteHost == nil { @@ -27,6 +29,10 @@ func NewDfltRemoteHost() *RemoteHost { return &dfltVal } +func NewDfltRPCConn() *RPCConn { + return &RPCConn{Strategy: rpcclient.PoolFirst} +} + type RPCConn struct { Strategy string PoolSize int