Removing static hosts from DispatcherS

This commit is contained in:
DanB
2019-04-01 18:36:41 +02:00
parent fccaf489a4
commit 2767a6a3d5
8 changed files with 4 additions and 56 deletions

View File

@@ -944,25 +944,7 @@ func startDispatcherService(internalDispatcherSChan chan *dispatchers.Dispatcher
return
}
}
conns := make(map[string]*rpcclient.RpcClientPool)
for connID, haPoolCfg := range cfg.DispatcherSCfg().Conns {
var connPool *rpcclient.RpcClientPool
if connPool, err = engine.NewRPCPool(
rpcclient.POOL_FIRST,
cfg.TlsCfg().ClientKey,
cfg.TlsCfg().ClientCerificate, cfg.TlsCfg().CaCertificate,
cfg.GeneralCfg().ConnectAttempts, cfg.GeneralCfg().Reconnects,
cfg.GeneralCfg().ConnectTimeout, cfg.GeneralCfg().ReplyTimeout,
haPoolCfg, nil, time.Duration(0), false); err != nil {
utils.Logger.Crit(
fmt.Sprintf("<%s> could not connect to connID: <%s>, err: <%s>",
utils.DispatcherS, connID, err.Error()))
exitChan <- true
return
}
conns[connID] = connPool
}
dspS, err := dispatchers.NewDispatcherService(dm, cfg, fltrS, attrSConn, conns)
dspS, err := dispatchers.NewDispatcherService(dm, cfg, fltrS, attrSConn)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("<%s> Could not init, error: %s", utils.DispatcherS, err.Error()))
exitChan <- true

View File

@@ -687,18 +687,6 @@ func (self *CGRConfig) checkConfigSanity() error {
if self.attributeSCfg.Enabled {
return fmt.Errorf("<%s> cannot start in tandem with <%s>", utils.DispatcherS, utils.AttributeS)
}
if len(self.dispatcherSCfg.Conns) == 0 {
return fmt.Errorf("<%s> no connections defined", utils.DispatcherS)
}
for connID, haPool := range self.dispatcherSCfg.Conns {
for _, connCfg := range haPool {
if connCfg.Address == utils.MetaInternal {
return fmt.Errorf(
"<%s> connID: <%s> %s connections are not supported",
utils.DispatcherS, connID, utils.MetaInternal)
}
}
}
}
// Scheduler check connection with CDR Server
if !self.cdrsCfg.CDRSEnabled {

View File

@@ -743,8 +743,6 @@ const CGRATES_CFG_JSON = `
//"string_indexed_fields": [], // query indexes based on these fields for faster processing
"prefix_indexed_fields": [], // query indexes based on these fields for faster processing
"attributes_conns": [], // connections to AttributeS for API authorization, empty to disable auth functionality: <""|*internal|x.y.z.y:1234>
"conns": { // connection pools to use for dispatching requests
},
},

View File

@@ -1414,7 +1414,6 @@ func TestDfDispatcherSJsonCfg(t *testing.T) {
String_indexed_fields: nil,
Prefix_indexed_fields: &[]string{},
Attributes_conns: &[]*HaPoolJsonCfg{},
Conns: &map[string]*[]*HaPoolJsonCfg{},
}
if cfg, err := dfCgrJsonCfg.DispatcherSJsonCfg(); err != nil {
t.Error(err)

View File

@@ -1476,7 +1476,6 @@ func TestCgrCfgJSONDefaultDispatcherSCfg(t *testing.T) {
StringIndexedFields: nil,
PrefixIndexedFields: &[]string{},
AttributeSConns: []*RemoteHost{},
Conns: map[string][]*RemoteHost{},
}
if !reflect.DeepEqual(cgrCfg.dispatcherSCfg, eDspSCfg) {
t.Errorf("received: %+v, expecting: %+v", cgrCfg.dispatcherSCfg, eDspSCfg)

View File

@@ -25,7 +25,6 @@ type DispatcherSCfg struct {
StringIndexedFields *[]string
PrefixIndexedFields *[]string
AttributeSConns []*RemoteHost
Conns map[string][]*RemoteHost
}
func (dps *DispatcherSCfg) loadFromJsonCfg(jsnCfg *DispatcherSJsonCfg) (err error) {
@@ -59,19 +58,5 @@ func (dps *DispatcherSCfg) loadFromJsonCfg(jsnCfg *DispatcherSJsonCfg) (err erro
dps.AttributeSConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Conns != nil {
dps.Conns = make(map[string][]*RemoteHost, len(*jsnCfg.Conns))
for id, conns := range *jsnCfg.Conns {
if conns == nil {
continue
}
Conns := make([]*RemoteHost, len(*conns))
for idx, jsnHaCfg := range *conns {
Conns[idx] = NewDfltRemoteHost()
Conns[idx].loadFromJsonCfg(jsnHaCfg)
}
dps.Conns[id] = Conns
}
}
return nil
}

View File

@@ -527,7 +527,6 @@ type DispatcherSJsonCfg struct {
String_indexed_fields *[]string
Prefix_indexed_fields *[]string
Attributes_conns *[]*HaPoolJsonCfg
Conns *map[string]*[]*HaPoolJsonCfg
}
type LoaderCfgJson struct {

View File

@@ -32,13 +32,12 @@ import (
// NewDispatcherService constructs a DispatcherService
func NewDispatcherService(dm *engine.DataManager,
cfg *config.CGRConfig, fltrS *engine.FilterS,
attrS *rpcclient.RpcClientPool,
conns map[string]*rpcclient.RpcClientPool) (*DispatcherService, error) {
attrS *rpcclient.RpcClientPool) (*DispatcherService, error) {
if attrS != nil && reflect.ValueOf(attrS).IsNil() {
attrS = nil
}
return &DispatcherService{dm: dm, cfg: cfg,
fltrS: fltrS, attrS: attrS, conns: conns}, nil
fltrS: fltrS, attrS: attrS}, nil
}
// DispatcherService is the service handling dispatching towards internal components
@@ -47,8 +46,7 @@ type DispatcherService struct {
dm *engine.DataManager
cfg *config.CGRConfig
fltrS *engine.FilterS
attrS *rpcclient.RpcClientPool // used for API auth
conns map[string]*rpcclient.RpcClientPool // available connections, accessed based on connID
attrS *rpcclient.RpcClientPool // used for API auth
}
// ListenAndServe will initialize the service