New dispatchers configuration and DispatcherProfile

This commit is contained in:
DanB
2019-01-30 11:19:25 +01:00
parent c71476ac81
commit e2088738df
3 changed files with 75 additions and 4 deletions

View File

@@ -737,6 +737,25 @@ const CGRATES_CFG_JSON = `
},
"dispatchers":{
"enabled": false, // starts DispatcherS service: <true|false>.
"conns": {
"sessions_eu": [
{"address": "127.0.0.1:2012", "transport": "*json"},
{"address": "127.0.0.2:2012", "transport": "*json"},
],
"sessions_us": [
{"address": "127.0.0.3:2012", "transport": "*json"},
{"address": "127.0.0.4:2012", "transport": "*json"},
],
"sessions_others": [
{"address": "127.0.0.5:2012", "transport": "*json"},
{"address": "127.0.0.6:2012", "transport": "*json"},
],
},
},
"analyzers":{
"enabled":false // starts AnalyzerS service: <true|false>.
},

View File

@@ -55,7 +55,8 @@ func NewDispatcherService(dm *engine.DataManager, rals, resS, thdS,
if chargerS != nil && reflect.ValueOf(chargerS).IsNil() {
chargerS = nil
}
return &DispatcherService{dm: dm,
return &DispatcherService{
dm: dm,
rals: rals,
resS: resS,
thdS: thdS,
@@ -66,7 +67,8 @@ func NewDispatcherService(dm *engine.DataManager, rals, resS, thdS,
chargerS: chargerS}, nil
}
// DispatcherService is the service handling dispatcher
// DispatcherService is the service handling dispatching towards internal components
// designed to handle automatic partitioning and failover
type DispatcherService struct {
dm *engine.DataManager
rals rpcclient.RpcClientConnection // RALs connections
@@ -75,8 +77,8 @@ type DispatcherService struct {
statS rpcclient.RpcClientConnection // StatS connections
splS rpcclient.RpcClientConnection // SupplierS connections
attrS rpcclient.RpcClientConnection // AttributeS connections
sessionS rpcclient.RpcClientConnection // SessionS server connections
chargerS rpcclient.RpcClientConnection // ChargerS server connections
sessionS rpcclient.RpcClientConnection // SessionS connections
chargerS rpcclient.RpcClientConnection // ChargerS connections
}
// ListenAndServe will initialize the service

View File

@@ -0,0 +1,50 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package dispatchers
import (
"sort"
"github.com/cgrates/cgrates/utils"
)
// DispatcherProfile is the config for one Dispatcher
type DispatcherProfile struct {
Tenant string
ID string
Subsystems []string
FilterIDs []string
ActivationInterval *utils.ActivationInterval // Activation interval
Strategy string
StrategyParams map[string]interface{} // ie for distribution, set here the pool weights
ConnIDs []string // dispatch to these connections
Weight float64
}
func (dP *DispatcherProfile) TenantID() string {
return utils.ConcatenatedKey(dP.Tenant, dP.ID)
}
// DispatcherProfiles is a sortable list of Dispatcher profiles
type DispatcherProfiles []*DispatcherProfile
// Sort is part of sort interface, sort based on Weight
func (dps DispatcherProfiles) Sort() {
sort.Slice(dps, func(i, j int) bool { return dps[i].Weight > dps[j].Weight })
}