mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add *localhost rpc conn in config_defaults and if not specified use *first as strategy
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user