mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Configuratin changes: smg -> sessions, smg_replication_conns -> session_replication_conns
This commit is contained in:
@@ -135,52 +135,52 @@ func startSmGeneric(internalSMGChan, internalRaterChan, internalResourceSChan, i
|
||||
utils.Logger.Info("Starting CGRateS SMGeneric service.")
|
||||
var err error
|
||||
var ralsConns, resSConns, suplSConns, attrSConns, cdrsConn *rpcclient.RpcClientPool
|
||||
if len(cfg.SMGConfig.RALsConns) != 0 {
|
||||
if len(cfg.SessionSCfg().RALsConns) != 0 {
|
||||
ralsConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.SMGConfig.RALsConns, internalRaterChan, cfg.InternalTtl)
|
||||
cfg.SessionSCfg().RALsConns, internalRaterChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to RALs: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(cfg.SMGConfig.ResSConns) != 0 {
|
||||
if len(cfg.SessionSCfg().ResSConns) != 0 {
|
||||
resSConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.SMGConfig.ResSConns, internalResourceSChan, cfg.InternalTtl)
|
||||
cfg.SessionSCfg().ResSConns, internalResourceSChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to ResourceS: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(cfg.SMGConfig.SupplSConns) != 0 {
|
||||
if len(cfg.SessionSCfg().SupplSConns) != 0 {
|
||||
suplSConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.SMGConfig.SupplSConns, internalSupplierSChan, cfg.InternalTtl)
|
||||
cfg.SessionSCfg().SupplSConns, internalSupplierSChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to SupplierS: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(cfg.SMGConfig.AttrSConns) != 0 {
|
||||
if len(cfg.SessionSCfg().AttrSConns) != 0 {
|
||||
attrSConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.SMGConfig.AttrSConns, internalAttrSChan, cfg.InternalTtl)
|
||||
cfg.SessionSCfg().AttrSConns, internalAttrSChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to AttributeS: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(cfg.SMGConfig.CDRsConns) != 0 {
|
||||
if len(cfg.SessionSCfg().CDRsConns) != 0 {
|
||||
cdrsConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.SMGConfig.CDRsConns, internalCDRSChan, cfg.InternalTtl)
|
||||
cfg.SessionSCfg().CDRsConns, internalCDRSChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to RALs: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
}
|
||||
smgReplConns, err := sessionmanager.NewSMGReplicationConns(cfg.SMGConfig.SMGReplicationConns, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout)
|
||||
smgReplConns, err := sessionmanager.NewSessionReplicationConns(cfg.SessionSCfg().SessionReplicationConns, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to SMGReplicationConnection error: <%s>", err.Error()))
|
||||
exitChan <- true
|
||||
@@ -200,7 +200,7 @@ func startSmGeneric(internalSMGChan, internalRaterChan, internalResourceSChan, i
|
||||
smgv1 := v1.NewSMGv1(sm) // methods with multiple options
|
||||
server.RpcRegister(smgv1)
|
||||
// Register BiRpc handlers
|
||||
if cfg.SMGConfig.ListenBijson != "" {
|
||||
if cfg.SessionSCfg().ListenBijson != "" {
|
||||
smgBiRpc := v1.NewSMGenericBiRpcV1(sm)
|
||||
for method, handler := range smgBiRpc.Handlers() {
|
||||
server.BiRPCRegisterName(method, handler)
|
||||
@@ -208,7 +208,7 @@ func startSmGeneric(internalSMGChan, internalRaterChan, internalResourceSChan, i
|
||||
for method, handler := range smgv1.Handlers() {
|
||||
server.BiRPCRegisterName(method, handler)
|
||||
}
|
||||
server.ServeBiJSON(cfg.SMGConfig.ListenBijson)
|
||||
server.ServeBiJSON(cfg.SessionSCfg().ListenBijson)
|
||||
exitChan <- true
|
||||
}
|
||||
}
|
||||
@@ -236,9 +236,9 @@ func startDiameterAgent(internalSMGChan, internalPubSubSChan chan rpcclient.RpcC
|
||||
var err error
|
||||
utils.Logger.Info("Starting CGRateS DiameterAgent service")
|
||||
var smgConn, pubsubConn *rpcclient.RpcClientPool
|
||||
if len(cfg.DiameterAgentCfg().SMGConns) != 0 {
|
||||
if len(cfg.DiameterAgentCfg().SessionSConns) != 0 {
|
||||
smgConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.DiameterAgentCfg().SMGConns, internalSMGChan, cfg.InternalTtl)
|
||||
cfg.DiameterAgentCfg().SessionSConns, internalSMGChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<DiameterAgent> Could not connect to SMG: %s", err.Error()))
|
||||
exitChan <- true
|
||||
@@ -270,10 +270,10 @@ func startRadiusAgent(internalSMGChan chan rpcclient.RpcClientConnection, exitCh
|
||||
var err error
|
||||
utils.Logger.Info("Starting CGRateS RadiusAgent service")
|
||||
var smgConn *rpcclient.RpcClientPool
|
||||
if len(cfg.RadiusAgentCfg().SMGConns) != 0 {
|
||||
if len(cfg.RadiusAgentCfg().SessionSConns) != 0 {
|
||||
smgConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts,
|
||||
cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.RadiusAgentCfg().SMGConns, internalSMGChan, cfg.InternalTtl)
|
||||
cfg.RadiusAgentCfg().SessionSConns, internalSMGChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<RadiusAgent> Could not connect to SMG: %s", err.Error()))
|
||||
exitChan <- true
|
||||
@@ -920,7 +920,7 @@ func main() {
|
||||
go startCdrcs(internalCdrSChan, internalRaterChan, exitChan)
|
||||
|
||||
// Start SM-Generic
|
||||
if cfg.SMGConfig.Enabled {
|
||||
if cfg.SessionSCfg().Enabled {
|
||||
go startSmGeneric(internalSMGChan, internalRaterChan, internalRsChan,
|
||||
internalSupplierSChan, internalAttributeSChan, internalCdrSChan, server, exitChan)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
},
|
||||
],
|
||||
|
||||
"smg": {
|
||||
"sessions": {
|
||||
"enabled": true, // enable Rater service: <true|false>
|
||||
},
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func NewDefaultCGRConfig() (*CGRConfig, error) {
|
||||
cfg.RALsMaxComputedUsage = make(map[string]time.Duration)
|
||||
cfg.NodeID = utils.GenUUID()
|
||||
cfg.DataFolderPath = "/usr/share/cgrates/"
|
||||
cfg.SMGConfig = new(SMGConfig)
|
||||
cfg.sessionSCfg = new(SessionSCfg)
|
||||
cfg.cacheConfig = make(CacheConfig)
|
||||
cfg.fsAgentCfg = new(FsAgentConfig)
|
||||
cfg.SmKamConfig = new(SmKamConfig)
|
||||
@@ -259,7 +259,7 @@ type CGRConfig struct {
|
||||
CDRStatsSaveInterval time.Duration // Save interval duration
|
||||
CdreProfiles map[string]*CdreConfig
|
||||
CdrcProfiles map[string][]*CdrcConfig // Number of CDRC instances running imports, format map[dirPath][]{Configs}
|
||||
SMGConfig *SMGConfig
|
||||
sessionSCfg *SessionSCfg
|
||||
fsAgentCfg *FsAgentConfig // SMFreeSWITCH configuration
|
||||
SmKamConfig *SmKamConfig // SM-Kamailio Configuration
|
||||
SmOsipsConfig *SmOsipsConfig // SMOpenSIPS Configuration
|
||||
@@ -405,34 +405,34 @@ func (self *CGRConfig) checkConfigSanity() error {
|
||||
}
|
||||
}
|
||||
// SMGeneric checks
|
||||
if self.SMGConfig.Enabled {
|
||||
if len(self.SMGConfig.RALsConns) == 0 {
|
||||
if self.sessionSCfg.Enabled {
|
||||
if len(self.sessionSCfg.RALsConns) == 0 {
|
||||
return errors.New("<SMGeneric> RALs definition is mandatory!")
|
||||
}
|
||||
for _, smgRALsConn := range self.SMGConfig.RALsConns {
|
||||
for _, smgRALsConn := range self.sessionSCfg.RALsConns {
|
||||
if smgRALsConn.Address == utils.MetaInternal && !self.RALsEnabled {
|
||||
return errors.New("<SMGeneric> RALs not enabled but requested by SMGeneric component.")
|
||||
}
|
||||
}
|
||||
for _, conn := range self.SMGConfig.ResSConns {
|
||||
for _, conn := range self.sessionSCfg.ResSConns {
|
||||
if conn.Address == utils.MetaInternal && !self.resourceSCfg.Enabled {
|
||||
return errors.New("<SMGeneric> ResourceS not enabled but requested by SMGeneric component.")
|
||||
}
|
||||
}
|
||||
for _, conn := range self.SMGConfig.SupplSConns {
|
||||
for _, conn := range self.sessionSCfg.SupplSConns {
|
||||
if conn.Address == utils.MetaInternal && !self.supplierSCfg.Enabled {
|
||||
return errors.New("<SMGeneric> SupplierS not enabled but requested by SMGeneric component.")
|
||||
}
|
||||
}
|
||||
for _, conn := range self.SMGConfig.AttrSConns {
|
||||
for _, conn := range self.sessionSCfg.AttrSConns {
|
||||
if conn.Address == utils.MetaInternal && !self.attributeSCfg.Enabled {
|
||||
return errors.New("<SMGeneric> AttributeS not enabled but requested by SMGeneric component.")
|
||||
}
|
||||
}
|
||||
if len(self.SMGConfig.CDRsConns) == 0 {
|
||||
if len(self.sessionSCfg.CDRsConns) == 0 {
|
||||
return errors.New("<SMGeneric> CDRs definition is mandatory!")
|
||||
}
|
||||
for _, smgCDRSConn := range self.SMGConfig.CDRsConns {
|
||||
for _, smgCDRSConn := range self.sessionSCfg.CDRsConns {
|
||||
if smgCDRSConn.Address == utils.MetaInternal && !self.CDRSEnabled {
|
||||
return errors.New("<SMGeneric> CDRS not enabled but referenced by SMGeneric component")
|
||||
}
|
||||
@@ -440,12 +440,12 @@ func (self *CGRConfig) checkConfigSanity() error {
|
||||
}
|
||||
// SMFreeSWITCH checks
|
||||
if self.fsAgentCfg.Enabled {
|
||||
for _, connCfg := range self.fsAgentCfg.SMGConns {
|
||||
for _, connCfg := range self.fsAgentCfg.SessionSConns {
|
||||
if connCfg.Address != utils.MetaInternal {
|
||||
return errors.New("Only <*internal> connectivity allowed in in SMFreeSWITCH towards SMG for now")
|
||||
}
|
||||
if connCfg.Address == utils.MetaInternal &&
|
||||
!self.SMGConfig.Enabled {
|
||||
!self.sessionSCfg.Enabled {
|
||||
return errors.New("SMGeneric not enabled but referenced by SM-FreeSWITCH")
|
||||
}
|
||||
}
|
||||
@@ -496,23 +496,23 @@ func (self *CGRConfig) checkConfigSanity() error {
|
||||
}
|
||||
// SMAsterisk checks
|
||||
if self.asteriskAgentCfg.Enabled {
|
||||
/*if len(self.asteriskAgentCfg.SMGConns) == 0 {
|
||||
/*if len(self.asteriskAgentCfg.SessionSConns) == 0 {
|
||||
return errors.New("<SMAsterisk> SMG definition is mandatory!")
|
||||
}
|
||||
for _, smAstSMGConn := range self.asteriskAgentCfg.SMGConns {
|
||||
if smAstSMGConn.Address == utils.MetaInternal && !self.SMGConfig.Enabled {
|
||||
for _, smAstSMGConn := range self.asteriskAgentCfg.SessionSConns {
|
||||
if smAstSMGConn.Address == utils.MetaInternal && !self.sessionSCfg.Enabled {
|
||||
return errors.New("<SMAsterisk> SMG not enabled.")
|
||||
}
|
||||
}
|
||||
*/
|
||||
if !self.SMGConfig.Enabled {
|
||||
if !self.sessionSCfg.Enabled {
|
||||
return errors.New("<SMAsterisk> SMG not enabled.")
|
||||
}
|
||||
}
|
||||
// DAgent checks
|
||||
if self.diameterAgentCfg.Enabled {
|
||||
for _, daSMGConn := range self.diameterAgentCfg.SMGConns {
|
||||
if daSMGConn.Address == utils.MetaInternal && !self.SMGConfig.Enabled {
|
||||
for _, daSMGConn := range self.diameterAgentCfg.SessionSConns {
|
||||
if daSMGConn.Address == utils.MetaInternal && !self.sessionSCfg.Enabled {
|
||||
return errors.New("SMGeneric not enabled but referenced by DiameterAgent component")
|
||||
}
|
||||
}
|
||||
@@ -523,8 +523,8 @@ func (self *CGRConfig) checkConfigSanity() error {
|
||||
}
|
||||
}
|
||||
if self.radiusAgentCfg.Enabled {
|
||||
for _, raSMGConn := range self.radiusAgentCfg.SMGConns {
|
||||
if raSMGConn.Address == utils.MetaInternal && !self.SMGConfig.Enabled {
|
||||
for _, raSMGConn := range self.radiusAgentCfg.SessionSConns {
|
||||
if raSMGConn.Address == utils.MetaInternal && !self.sessionSCfg.Enabled {
|
||||
return errors.New("SMGeneric not enabled but referenced by RadiusAgent component")
|
||||
}
|
||||
}
|
||||
@@ -640,7 +640,7 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
jsnSmGenericCfg, err := jsnCfg.SmgJsonCfg()
|
||||
jsnsessionSCfg, err := jsnCfg.SessionSJsonCfg()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1116,8 +1116,8 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if jsnSmGenericCfg != nil {
|
||||
if err := self.SMGConfig.loadFromJsonCfg(jsnSmGenericCfg); err != nil {
|
||||
if jsnsessionSCfg != nil {
|
||||
if err := self.sessionSCfg.loadFromJsonCfg(jsnsessionSCfg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1289,6 +1289,10 @@ func (cfg *CGRConfig) SupplierSCfg() *SupplierSCfg {
|
||||
return cfg.supplierSCfg
|
||||
}
|
||||
|
||||
func (cfg *CGRConfig) SessionSCfg() *SessionSCfg {
|
||||
return cfg.sessionSCfg
|
||||
}
|
||||
|
||||
func (self *CGRConfig) FsAgentCfg() *FsAgentConfig {
|
||||
return self.fsAgentCfg
|
||||
}
|
||||
|
||||
@@ -277,11 +277,11 @@ const CGRATES_CFG_JSON = `
|
||||
],
|
||||
|
||||
|
||||
"smg": {
|
||||
"enabled": false, // starts SessionManager service: <true|false>
|
||||
"sessions": {
|
||||
"enabled": false, // starts session manager service: <true|false>
|
||||
"listen_bijson": "127.0.0.1:2014", // address where to listen for bidirectional JSON-RPC requests
|
||||
"rals_conns": [
|
||||
{"address": "*internal"} // address where to reach the Rater <""|*internal|127.0.0.1:2013>
|
||||
{"address": "*internal"} // address where to reach the RALs <""|*internal|127.0.0.1:2013>
|
||||
],
|
||||
"cdrs_conns": [
|
||||
{"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing <*internal|x.y.z.y:1234>
|
||||
@@ -289,7 +289,7 @@ const CGRATES_CFG_JSON = `
|
||||
"resources_conns": [], // address where to reach the ResourceS <""|*internal|127.0.0.1:2013>
|
||||
"suppliers_conns": [], // address where to reach the SupplierS <""|*internal|127.0.0.1:2013>
|
||||
"attributes_conns": [], // address where to reach the AttributeS <""|*internal|127.0.0.1:2013>
|
||||
"smg_replication_conns": [], // replicate sessions towards these SMGs
|
||||
"session_replication_conns": [], // replicate sessions towards these session services
|
||||
"debit_interval": "0s", // interval to perform debits on.
|
||||
"min_call_duration": "0s", // only authorize calls with allowed duration higher than this
|
||||
"max_call_duration": "3h", // maximum call duration a prepaid call can last
|
||||
@@ -302,9 +302,9 @@ const CGRATES_CFG_JSON = `
|
||||
|
||||
|
||||
"asterisk_agent": {
|
||||
"enabled": false, // starts Asterisk SessionManager service: <true|false>
|
||||
"smg_conns": [
|
||||
{"address": "*internal"} // connection towards SMG component for session management: <*internal>
|
||||
"enabled": false, // starts the Asterisk agent: <true|false>
|
||||
"sessions_conns": [
|
||||
{"address": "*internal"} // connection towards session service: <*internal>
|
||||
],
|
||||
"create_cdr": false, // create CDR out of events and sends it to CDRS component
|
||||
"asterisk_conns":[ // instantiate connections to multiple Asterisk servers
|
||||
@@ -314,9 +314,9 @@ const CGRATES_CFG_JSON = `
|
||||
|
||||
|
||||
"freeswitch_agent": {
|
||||
"enabled": false, // starts SessionManager service: <true|false>
|
||||
"smg_conns": [
|
||||
{"address": "*internal"} // connection towards SMG component for session management: <*internal>
|
||||
"enabled": false, // starts the FreeSWITCH agent: <true|false>
|
||||
"sessions_conns": [
|
||||
{"address": "*internal"} // connection towards session service: <*internal>
|
||||
],
|
||||
"subscribe_park": true, // subscribe via fsock to receive park events
|
||||
"create_cdr": false, // create CDR out of events and sends them to CDRS component
|
||||
@@ -374,11 +374,11 @@ const CGRATES_CFG_JSON = `
|
||||
"enabled": false, // enables the diameter agent: <true|false>
|
||||
"listen": "127.0.0.1:3868", // address where to listen for diameter requests <x.y.z.y:1234>
|
||||
"dictionaries_dir": "/usr/share/cgrates/diameter/dict/", // path towards directory holding additional dictionaries to load
|
||||
"smg_conns": [
|
||||
{"address": "*internal"} // connection towards SMG component for session management
|
||||
"sessions_conns": [
|
||||
{"address": "*internal"} // connection towards SessionService
|
||||
],
|
||||
"pubsubs_conns": [], // address where to reach the pubusb service, empty to disable pubsub functionality: <""|*internal|x.y.z.y:1234>
|
||||
"create_cdr": true, // create CDR out of CCR terminate and send it to SMG component
|
||||
"create_cdr": true, // create CDR out of CCR terminate and send it to SessionS
|
||||
"cdr_requires_session": true, // only create CDR if there is an active session at terminate
|
||||
"debit_interval": "5m", // interval for CCR updates
|
||||
"timezone": "", // timezone for timestamps where not specified, empty for general defaults <""|UTC|Local|$IANA_TZ_DB>
|
||||
@@ -401,10 +401,10 @@ const CGRATES_CFG_JSON = `
|
||||
"client_dictionaries": { // per client path towards directory holding additional dictionaries to load (extra to RFC)
|
||||
"*default": "/usr/share/cgrates/radius/dict/", // key represents the client IP or catch-all <*default|$client_ip>
|
||||
},
|
||||
"smg_conns": [
|
||||
{"address": "*internal"} // connection towards SMG component for session management
|
||||
"sessions_conns": [
|
||||
{"address": "*internal"} // connection towards SessionService
|
||||
],
|
||||
"create_cdr": true, // create CDR out of Accounting-Stop and send it to SMG component
|
||||
"create_cdr": true, // create CDR out of Accounting-Stop and send it to SessionS
|
||||
"cdr_requires_session": false, // only create CDR if there is an active session at terminate
|
||||
"timezone": "", // timezone for timestamps where not specified, empty for general defaults <""|UTC|Local|$IANA_TZ_DB>
|
||||
"request_processors": [],
|
||||
|
||||
@@ -28,42 +28,43 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
GENERAL_JSN = "general"
|
||||
CACHE_JSN = "cache"
|
||||
LISTEN_JSN = "listen"
|
||||
HTTP_JSN = "http"
|
||||
DATADB_JSN = "data_db"
|
||||
STORDB_JSN = "stor_db"
|
||||
FilterSjsn = "filters"
|
||||
RALS_JSN = "rals"
|
||||
SCHEDULER_JSN = "scheduler"
|
||||
CDRS_JSN = "cdrs"
|
||||
MEDIATOR_JSN = "mediator"
|
||||
CDRSTATS_JSN = "cdrstats"
|
||||
CDRE_JSN = "cdre"
|
||||
CDRC_JSN = "cdrc"
|
||||
SMG_JSON = "smg"
|
||||
SMFS_JSN = "sm_freeswitch"
|
||||
SMKAM_JSN = "sm_kamailio"
|
||||
SMOSIPS_JSN = "sm_opensips"
|
||||
SMAsteriskJSN = "sm_asterisk"
|
||||
SM_JSN = "session_manager"
|
||||
FS_JSN = "freeswitch"
|
||||
KAMAILIO_JSN = "kamailio"
|
||||
OSIPS_JSN = "opensips"
|
||||
DA_JSN = "diameter_agent"
|
||||
RA_JSN = "radius_agent"
|
||||
PUBSUBSERV_JSN = "pubsubs"
|
||||
ALIASESSERV_JSN = "aliases"
|
||||
USERSERV_JSN = "users"
|
||||
ATTRIBUTE_JSN = "attributes"
|
||||
RESOURCES_JSON = "resources"
|
||||
STATS_JSON = "stats"
|
||||
THRESHOLDS_JSON = "thresholds"
|
||||
SupplierSJson = "suppliers"
|
||||
FILTERS_JSON = "filters"
|
||||
MAILER_JSN = "mailer"
|
||||
SURETAX_JSON = "suretax"
|
||||
GENERAL_JSN = "general"
|
||||
CACHE_JSN = "cache"
|
||||
LISTEN_JSN = "listen"
|
||||
HTTP_JSN = "http"
|
||||
DATADB_JSN = "data_db"
|
||||
STORDB_JSN = "stor_db"
|
||||
FilterSjsn = "filters"
|
||||
RALS_JSN = "rals"
|
||||
SCHEDULER_JSN = "scheduler"
|
||||
CDRS_JSN = "cdrs"
|
||||
MEDIATOR_JSN = "mediator"
|
||||
CDRSTATS_JSN = "cdrstats"
|
||||
CDRE_JSN = "cdre"
|
||||
CDRC_JSN = "cdrc"
|
||||
SessionSJson = "sessions"
|
||||
FreeSWITCHAgentJSN = "freeswitch_agent"
|
||||
SMKAM_JSN = "sm_kamailio"
|
||||
SMOSIPS_JSN = "sm_opensips"
|
||||
AsteriskAgentJSN = "asterisk_agent"
|
||||
SM_JSN = "session_manager"
|
||||
FS_JSN = "freeswitch"
|
||||
KAMAILIO_JSN = "kamailio"
|
||||
OSIPS_JSN = "opensips"
|
||||
DA_JSN = "diameter_agent"
|
||||
RA_JSN = "radius_agent"
|
||||
HISTSERV_JSN = "historys"
|
||||
PUBSUBSERV_JSN = "pubsubs"
|
||||
ALIASESSERV_JSN = "aliases"
|
||||
USERSERV_JSN = "users"
|
||||
ATTRIBUTE_JSN = "attributes"
|
||||
RESOURCES_JSON = "resources"
|
||||
STATS_JSON = "stats"
|
||||
THRESHOLDS_JSON = "thresholds"
|
||||
SupplierSJson = "suppliers"
|
||||
FILTERS_JSON = "filters"
|
||||
MAILER_JSN = "mailer"
|
||||
SURETAX_JSON = "suretax"
|
||||
)
|
||||
|
||||
// Loads the json config out of io.Reader, eg other sources than file, maybe over http
|
||||
@@ -233,12 +234,12 @@ func (self CgrJsonCfg) CdrcJsonCfg() ([]*CdrcJsonCfg, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func (self CgrJsonCfg) SmgJsonCfg() (*SmgJsonCfg, error) {
|
||||
rawCfg, hasKey := self[SMG_JSON]
|
||||
func (self CgrJsonCfg) SessionSJsonCfg() (*SessionSJsonCfg, error) {
|
||||
rawCfg, hasKey := self[SessionSJson]
|
||||
if !hasKey {
|
||||
return nil, nil
|
||||
}
|
||||
cfg := new(SmgJsonCfg)
|
||||
cfg := new(SessionSJsonCfg)
|
||||
if err := json.Unmarshal(*rawCfg, cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ func TestDfCdrcJsonCfg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSmgJsonCfg(t *testing.T) {
|
||||
eCfg := &SmgJsonCfg{
|
||||
eCfg := &SessionSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Listen_bijson: utils.StringPointer("127.0.0.1:2014"),
|
||||
Rals_conns: &[]*HaPoolJsonCfg{
|
||||
@@ -495,17 +495,17 @@ func TestSmgJsonCfg(t *testing.T) {
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
}},
|
||||
Resources_conns: &[]*HaPoolJsonCfg{},
|
||||
Suppliers_conns: &[]*HaPoolJsonCfg{},
|
||||
Attributes_conns: &[]*HaPoolJsonCfg{},
|
||||
Smg_replication_conns: &[]*HaPoolJsonCfg{},
|
||||
Debit_interval: utils.StringPointer("0s"),
|
||||
Min_call_duration: utils.StringPointer("0s"),
|
||||
Max_call_duration: utils.StringPointer("3h"),
|
||||
Session_ttl: utils.StringPointer("0s"),
|
||||
Session_indexes: utils.StringSlicePointer([]string{}),
|
||||
Resources_conns: &[]*HaPoolJsonCfg{},
|
||||
Suppliers_conns: &[]*HaPoolJsonCfg{},
|
||||
Attributes_conns: &[]*HaPoolJsonCfg{},
|
||||
Session_replication_conns: &[]*HaPoolJsonCfg{},
|
||||
Debit_interval: utils.StringPointer("0s"),
|
||||
Min_call_duration: utils.StringPointer("0s"),
|
||||
Max_call_duration: utils.StringPointer("3h"),
|
||||
Session_ttl: utils.StringPointer("0s"),
|
||||
Session_indexes: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.SmgJsonCfg(); err != nil {
|
||||
if cfg, err := dfCgrJsonCfg.SessionSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eCfg, cfg) {
|
||||
t.Error("Received: ", cfg)
|
||||
@@ -515,7 +515,7 @@ func TestSmgJsonCfg(t *testing.T) {
|
||||
func TestFsAgentJsonCfg(t *testing.T) {
|
||||
eCfg := &FreeswitchAgentJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Smg_conns: &[]*HaPoolJsonCfg{
|
||||
Sessions_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
}},
|
||||
@@ -600,7 +600,7 @@ func TestSmOsipsJsonCfg(t *testing.T) {
|
||||
func TestAsteriskAgentJsonCfg(t *testing.T) {
|
||||
eCfg := &AsteriskAgentJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Smg_conns: &[]*HaPoolJsonCfg{
|
||||
Sessions_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
}},
|
||||
@@ -627,7 +627,7 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Listen: utils.StringPointer("127.0.0.1:3868"),
|
||||
Dictionaries_dir: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
|
||||
Smg_conns: &[]*HaPoolJsonCfg{
|
||||
Sessions_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
}},
|
||||
@@ -662,7 +662,7 @@ func TestRadiusAgentJsonCfg(t *testing.T) {
|
||||
Client_dictionaries: utils.MapStringStringPointer(map[string]string{
|
||||
utils.META_DEFAULT: "/usr/share/cgrates/radius/dict/",
|
||||
}),
|
||||
Smg_conns: &[]*HaPoolJsonCfg{
|
||||
Sessions_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
}},
|
||||
|
||||
@@ -446,26 +446,25 @@ func TestCgrCfgJSONDefaultsCdreProfiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCgrCfgJSONDefaultsSMGenericCfg(t *testing.T) {
|
||||
eSmGeCfg := &SMGConfig{
|
||||
eSessionSCfg := &SessionSCfg{
|
||||
Enabled: false,
|
||||
ListenBijson: "127.0.0.1:2014",
|
||||
RALsConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{Address: "*internal"}},
|
||||
CDRsConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{Address: "*internal"}},
|
||||
ResSConns: []*HaPoolConfig{},
|
||||
SupplSConns: []*HaPoolConfig{},
|
||||
AttrSConns: []*HaPoolConfig{},
|
||||
SMGReplicationConns: []*HaPoolConfig{},
|
||||
DebitInterval: 0 * time.Second,
|
||||
MinCallDuration: 0 * time.Second,
|
||||
MaxCallDuration: 3 * time.Hour,
|
||||
SessionTTL: 0 * time.Second,
|
||||
SessionIndexes: utils.StringMap{},
|
||||
ResSConns: []*HaPoolConfig{},
|
||||
SupplSConns: []*HaPoolConfig{},
|
||||
AttrSConns: []*HaPoolConfig{},
|
||||
SessionReplicationConns: []*HaPoolConfig{},
|
||||
DebitInterval: 0 * time.Second,
|
||||
MinCallDuration: 0 * time.Second,
|
||||
MaxCallDuration: 3 * time.Hour,
|
||||
SessionTTL: 0 * time.Second,
|
||||
SessionIndexes: utils.StringMap{},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cgrCfg.SMGConfig, eSmGeCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.SMGConfig, eSmGeCfg)
|
||||
if !reflect.DeepEqual(cgrCfg.SessionSCfg, eSessionSCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.SessionSCfg, eSessionSCfg)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -552,7 +551,7 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
|
||||
func TestCgrCfgJSONDefaultsSMFsConfig(t *testing.T) {
|
||||
eFsAgentCfg := &FsAgentConfig{
|
||||
Enabled: false,
|
||||
SMGConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
|
||||
SessionSConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
|
||||
SubscribePark: true,
|
||||
CreateCdr: false,
|
||||
ExtraFields: nil,
|
||||
@@ -609,7 +608,7 @@ func TestCgrCfgJSONDefaultsSMOsipsConfig(t *testing.T) {
|
||||
func TestCgrCfgJSONDefaultssteriskAgentCfg(t *testing.T) {
|
||||
eAstAgentCfg := &AsteriskAgentCfg{
|
||||
Enabled: false,
|
||||
SMGConns: []*HaPoolConfig{
|
||||
SessionSConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{Address: "*internal"}},
|
||||
CreateCDR: false,
|
||||
AsteriskConns: []*AsteriskConnCfg{
|
||||
@@ -721,7 +720,7 @@ func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) {
|
||||
Enabled: false,
|
||||
Listen: "127.0.0.1:3868",
|
||||
DictionariesDir: "/usr/share/cgrates/diameter/dict/",
|
||||
SMGConns: []*HaPoolConfig{
|
||||
SessionSConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{Address: "*internal"}},
|
||||
PubSubConns: []*HaPoolConfig{},
|
||||
CreateCDR: true,
|
||||
@@ -743,8 +742,8 @@ func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) {
|
||||
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.DictionariesDir, testDA.DictionariesDir) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.DictionariesDir, testDA.DictionariesDir)
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.SMGConns, testDA.SMGConns) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.SMGConns, testDA.SMGConns)
|
||||
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.SessionSConns, testDA.SessionSConns) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.SessionSConns, testDA.SessionSConns)
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.PubSubConns, testDA.PubSubConns) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.PubSubConns, testDA.PubSubConns)
|
||||
@@ -851,7 +850,7 @@ func TestRadiusAgentCfg(t *testing.T) {
|
||||
ListenAcct: "127.0.0.1:1813",
|
||||
ClientSecrets: map[string]string{utils.META_DEFAULT: "CGRateS.org"},
|
||||
ClientDictionaries: map[string]string{utils.META_DEFAULT: "/usr/share/cgrates/radius/dict/"},
|
||||
SMGConns: []*HaPoolConfig{&HaPoolConfig{Address: utils.MetaInternal}},
|
||||
SessionSConns: []*HaPoolConfig{&HaPoolConfig{Address: utils.MetaInternal}},
|
||||
CreateCDR: true,
|
||||
CDRRequiresSession: false,
|
||||
Timezone: "",
|
||||
@@ -875,8 +874,8 @@ func TestRadiusAgentCfg(t *testing.T) {
|
||||
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.ClientDictionaries, testRA.ClientDictionaries) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.radiusAgentCfg.ClientDictionaries, testRA.ClientDictionaries)
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.SMGConns, testRA.SMGConns) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.radiusAgentCfg.SMGConns, testRA.SMGConns)
|
||||
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.SessionSConns, testRA.SessionSConns) {
|
||||
t.Errorf("expecting: %+v, received: %+v", cgrCfg.radiusAgentCfg.SessionSConns, testRA.SessionSConns)
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.CreateCDR, testRA.CreateCDR) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.radiusAgentCfg.CreateCDR, testRA.CreateCDR)
|
||||
|
||||
@@ -28,7 +28,7 @@ type DiameterAgentCfg struct {
|
||||
Enabled bool // enables the diameter agent: <true|false>
|
||||
Listen string // address where to listen for diameter requests <x.y.z.y:1234>
|
||||
DictionariesDir string
|
||||
SMGConns []*HaPoolConfig // connections towards SMG component
|
||||
SessionSConns []*HaPoolConfig // connections towards SMG component
|
||||
PubSubConns []*HaPoolConfig // connection towards pubsubs
|
||||
CreateCDR bool
|
||||
CDRRequiresSession bool
|
||||
@@ -54,11 +54,11 @@ func (self *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg) erro
|
||||
if jsnCfg.Dictionaries_dir != nil {
|
||||
self.DictionariesDir = *jsnCfg.Dictionaries_dir
|
||||
}
|
||||
if jsnCfg.Smg_conns != nil {
|
||||
self.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
|
||||
self.SMGConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
if jsnCfg.Sessions_conns != nil {
|
||||
self.SessionSConns = make([]*HaPoolConfig, len(*jsnCfg.Sessions_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Sessions_conns {
|
||||
self.SessionSConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SessionSConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Pubsubs_conns != nil {
|
||||
|
||||
@@ -194,29 +194,29 @@ type CdrcJsonCfg struct {
|
||||
}
|
||||
|
||||
// SM-Generic config section
|
||||
type SmgJsonCfg struct {
|
||||
Enabled *bool
|
||||
Listen_bijson *string
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Resources_conns *[]*HaPoolJsonCfg
|
||||
Suppliers_conns *[]*HaPoolJsonCfg
|
||||
Cdrs_conns *[]*HaPoolJsonCfg
|
||||
Smg_replication_conns *[]*HaPoolJsonCfg
|
||||
Attributes_conns *[]*HaPoolJsonCfg
|
||||
Debit_interval *string
|
||||
Min_call_duration *string
|
||||
Max_call_duration *string
|
||||
Session_ttl *string
|
||||
Session_ttl_max_delay *string
|
||||
Session_ttl_last_used *string
|
||||
Session_ttl_usage *string
|
||||
Session_indexes *[]string
|
||||
type SessionSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Listen_bijson *string
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Resources_conns *[]*HaPoolJsonCfg
|
||||
Suppliers_conns *[]*HaPoolJsonCfg
|
||||
Cdrs_conns *[]*HaPoolJsonCfg
|
||||
Session_replication_conns *[]*HaPoolJsonCfg
|
||||
Attributes_conns *[]*HaPoolJsonCfg
|
||||
Debit_interval *string
|
||||
Min_call_duration *string
|
||||
Max_call_duration *string
|
||||
Session_ttl *string
|
||||
Session_ttl_max_delay *string
|
||||
Session_ttl_last_used *string
|
||||
Session_ttl_usage *string
|
||||
Session_indexes *[]string
|
||||
}
|
||||
|
||||
// SM-FreeSWITCH config section
|
||||
type FreeswitchAgentJsonCfg struct {
|
||||
Enabled *bool
|
||||
Smg_conns *[]*HaPoolJsonCfg // Connections towards generic SMG
|
||||
Sessions_conns *[]*HaPoolJsonCfg
|
||||
Subscribe_park *bool
|
||||
Create_cdr *bool
|
||||
Extra_fields *[]string
|
||||
@@ -253,7 +253,7 @@ type AstConnJsonCfg struct {
|
||||
|
||||
type AsteriskAgentJsonCfg struct {
|
||||
Enabled *bool
|
||||
Smg_conns *[]*HaPoolJsonCfg // Connections towards generic SMG
|
||||
Sessions_conns *[]*HaPoolJsonCfg
|
||||
Create_cdr *bool
|
||||
Asterisk_conns *[]*AstConnJsonCfg
|
||||
}
|
||||
@@ -311,7 +311,7 @@ type DiameterAgentJsonCfg struct {
|
||||
Enabled *bool // enables the diameter agent: <true|false>
|
||||
Listen *string // address where to listen for diameter requests <x.y.z.y:1234>
|
||||
Dictionaries_dir *string // path towards additional dictionaries
|
||||
Smg_conns *[]*HaPoolJsonCfg // Connections towards generic SM
|
||||
Sessions_conns *[]*HaPoolJsonCfg // Connections towards generic SM
|
||||
Pubsubs_conns *[]*HaPoolJsonCfg // connection towards pubsubs
|
||||
Create_cdr *bool
|
||||
Cdr_requires_session *bool
|
||||
@@ -345,7 +345,7 @@ type RadiusAgentJsonCfg struct {
|
||||
Listen_acct *string
|
||||
Client_secrets *map[string]string
|
||||
Client_dictionaries *map[string]string
|
||||
Smg_conns *[]*HaPoolJsonCfg
|
||||
Sessions_conns *[]*HaPoolJsonCfg
|
||||
Create_cdr *bool
|
||||
Cdr_requires_session *bool
|
||||
Timezone *string
|
||||
|
||||
@@ -29,7 +29,7 @@ type RadiusAgentCfg struct {
|
||||
ListenAcct string
|
||||
ClientSecrets map[string]string
|
||||
ClientDictionaries map[string]string
|
||||
SMGConns []*HaPoolConfig
|
||||
SessionSConns []*HaPoolConfig
|
||||
CreateCDR bool
|
||||
CDRRequiresSession bool
|
||||
Timezone string
|
||||
@@ -68,11 +68,11 @@ func (self *RadiusAgentCfg) loadFromJsonCfg(jsnCfg *RadiusAgentJsonCfg) error {
|
||||
self.ClientDictionaries[k] = v
|
||||
}
|
||||
}
|
||||
if jsnCfg.Smg_conns != nil {
|
||||
self.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
|
||||
self.SMGConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
if jsnCfg.Sessions_conns != nil {
|
||||
self.SessionSConns = make([]*HaPoolConfig, len(*jsnCfg.Sessions_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Sessions_conns {
|
||||
self.SessionSConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SessionSConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Create_cdr != nil {
|
||||
|
||||
@@ -88,26 +88,26 @@ func (self *FsConnConfig) loadFromJsonCfg(jsnCfg *FsConnJsonCfg) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type SMGConfig struct {
|
||||
Enabled bool
|
||||
ListenBijson string
|
||||
RALsConns []*HaPoolConfig
|
||||
ResSConns []*HaPoolConfig
|
||||
SupplSConns []*HaPoolConfig
|
||||
AttrSConns []*HaPoolConfig
|
||||
CDRsConns []*HaPoolConfig
|
||||
SMGReplicationConns []*HaPoolConfig
|
||||
DebitInterval time.Duration
|
||||
MinCallDuration time.Duration
|
||||
MaxCallDuration time.Duration
|
||||
SessionTTL time.Duration
|
||||
SessionTTLMaxDelay *time.Duration
|
||||
SessionTTLLastUsed *time.Duration
|
||||
SessionTTLUsage *time.Duration
|
||||
SessionIndexes utils.StringMap
|
||||
type SessionSCfg struct {
|
||||
Enabled bool
|
||||
ListenBijson string
|
||||
RALsConns []*HaPoolConfig
|
||||
ResSConns []*HaPoolConfig
|
||||
SupplSConns []*HaPoolConfig
|
||||
AttrSConns []*HaPoolConfig
|
||||
CDRsConns []*HaPoolConfig
|
||||
SessionReplicationConns []*HaPoolConfig
|
||||
DebitInterval time.Duration
|
||||
MinCallDuration time.Duration
|
||||
MaxCallDuration time.Duration
|
||||
SessionTTL time.Duration
|
||||
SessionTTLMaxDelay *time.Duration
|
||||
SessionTTLLastUsed *time.Duration
|
||||
SessionTTLUsage *time.Duration
|
||||
SessionIndexes utils.StringMap
|
||||
}
|
||||
|
||||
func (self *SMGConfig) loadFromJsonCfg(jsnCfg *SmgJsonCfg) error {
|
||||
func (self *SessionSCfg) loadFromJsonCfg(jsnCfg *SessionSJsonCfg) error {
|
||||
if jsnCfg == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -153,11 +153,11 @@ func (self *SMGConfig) loadFromJsonCfg(jsnCfg *SmgJsonCfg) error {
|
||||
self.CDRsConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Smg_replication_conns != nil {
|
||||
self.SMGReplicationConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_replication_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Smg_replication_conns {
|
||||
self.SMGReplicationConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SMGReplicationConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
if jsnCfg.Session_replication_conns != nil {
|
||||
self.SessionReplicationConns = make([]*HaPoolConfig, len(*jsnCfg.Session_replication_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Session_replication_conns {
|
||||
self.SessionReplicationConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SessionReplicationConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Debit_interval != nil {
|
||||
@@ -202,7 +202,7 @@ func (self *SMGConfig) loadFromJsonCfg(jsnCfg *SmgJsonCfg) error {
|
||||
|
||||
type FsAgentConfig struct {
|
||||
Enabled bool
|
||||
SMGConns []*HaPoolConfig
|
||||
SessionSConns []*HaPoolConfig
|
||||
SubscribePark bool
|
||||
CreateCdr bool
|
||||
ExtraFields []*utils.RSRField
|
||||
@@ -223,11 +223,11 @@ func (self *FsAgentConfig) loadFromJsonCfg(jsnCfg *FreeswitchAgentJsonCfg) error
|
||||
if jsnCfg.Enabled != nil {
|
||||
self.Enabled = *jsnCfg.Enabled
|
||||
}
|
||||
if jsnCfg.Smg_conns != nil {
|
||||
self.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
|
||||
self.SMGConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
if jsnCfg.Sessions_conns != nil {
|
||||
self.SessionSConns = make([]*HaPoolConfig, len(*jsnCfg.Sessions_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Sessions_conns {
|
||||
self.SessionSConns[idx] = NewDfltHaPoolConfig()
|
||||
self.SessionSConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Subscribe_park != nil {
|
||||
@@ -486,7 +486,7 @@ func (aConnCfg *AsteriskConnCfg) loadFromJsonCfg(jsnCfg *AstConnJsonCfg) error {
|
||||
|
||||
type AsteriskAgentCfg struct {
|
||||
Enabled bool
|
||||
SMGConns []*HaPoolConfig
|
||||
SessionSConns []*HaPoolConfig
|
||||
CreateCDR bool
|
||||
AsteriskConns []*AsteriskConnCfg
|
||||
}
|
||||
@@ -495,11 +495,11 @@ func (aCfg *AsteriskAgentCfg) loadFromJsonCfg(jsnCfg *AsteriskAgentJsonCfg) (err
|
||||
if jsnCfg.Enabled != nil {
|
||||
aCfg.Enabled = *jsnCfg.Enabled
|
||||
}
|
||||
if jsnCfg.Smg_conns != nil {
|
||||
aCfg.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
|
||||
aCfg.SMGConns[idx] = NewDfltHaPoolConfig()
|
||||
aCfg.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
if jsnCfg.Sessions_conns != nil {
|
||||
aCfg.SessionSConns = make([]*HaPoolConfig, len(*jsnCfg.Sessions_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Sessions_conns {
|
||||
aCfg.SessionSConns[idx] = NewDfltHaPoolConfig()
|
||||
aCfg.SessionSConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Create_cdr != nil {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
"sm_generic": {
|
||||
"sessions": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
"enabled": true, // start the CDR Server service: <true|false>
|
||||
},
|
||||
|
||||
"sm_generic": {
|
||||
"sessions": {
|
||||
"enabled": true, // starts SessionManager service: <true|false>
|
||||
"listen_bijson": "127.0.0.1:22014", // address where to listen for bidirectional JSON-RPC requests
|
||||
"smg_replication_conns": [
|
||||
"sessions_replication_conns": [
|
||||
{"address": "127.0.0.1:2012", "transport": "*json"},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -45,7 +45,7 @@ var (
|
||||
ErrActiveSession = errors.New("ACTIVE_SESSION")
|
||||
)
|
||||
|
||||
func NewSMGReplicationConns(conns []*config.HaPoolConfig, reconnects int, connTimeout, replyTimeout time.Duration) (smgConns []*SMGReplicationConn, err error) {
|
||||
func NewSessionReplicationConns(conns []*config.HaPoolConfig, reconnects int, connTimeout, replyTimeout time.Duration) (smgConns []*SMGReplicationConn, err error) {
|
||||
smgConns = make([]*SMGReplicationConn, len(conns))
|
||||
for i, replConnCfg := range conns {
|
||||
if replCon, err := rpcclient.NewRpcClient("tcp", replConnCfg.Address, 0, reconnects,
|
||||
@@ -142,8 +142,8 @@ type smgSessionTerminator struct {
|
||||
|
||||
// setSessionTerminator installs a new terminator for a session
|
||||
func (smg *SMGeneric) setSessionTerminator(s *SMGSession) {
|
||||
ttl := s.EventStart.GetSessionTTL(smg.cgrCfg.SMGConfig.SessionTTL,
|
||||
smg.cgrCfg.SMGConfig.SessionTTLMaxDelay)
|
||||
ttl := s.EventStart.GetSessionTTL(smg.cgrCfg.SessionSCfg().SessionTTL,
|
||||
smg.cgrCfg.SessionSCfg().SessionTTLMaxDelay)
|
||||
if ttl == 0 {
|
||||
return
|
||||
}
|
||||
@@ -405,9 +405,9 @@ func (smg *SMGeneric) sessionStart(evStart SMGenericEvent,
|
||||
CD: sessionRun.CallDescriptor, clntConn: clntConn}
|
||||
smg.recordASession(s)
|
||||
//utils.Logger.Info(fmt.Sprintf("<SMGeneric> Starting session: %s, runId: %s", sessionId, s.runId))
|
||||
if smg.cgrCfg.SMGConfig.DebitInterval != 0 {
|
||||
if smg.cgrCfg.SessionSCfg().DebitInterval != 0 {
|
||||
s.stopDebit = stopDebitChan
|
||||
go s.debitLoop(smg.cgrCfg.SMGConfig.DebitInterval)
|
||||
go s.debitLoop(smg.cgrCfg.SessionSCfg().DebitInterval)
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
@@ -487,7 +487,7 @@ func (smg *SMGeneric) sessionRelocate(initialID, cgrID, newOriginID string) erro
|
||||
// replicateSessions will replicate session based on configuration
|
||||
func (smg *SMGeneric) replicateSessionsWithID(cgrID string, passiveSessions bool, smgReplConns []*SMGReplicationConn) (err error) {
|
||||
if len(smgReplConns) == 0 ||
|
||||
(smg.cgrCfg.SMGConfig.DebitInterval != 0 && !passiveSessions) { // Replicating active not supported
|
||||
(smg.cgrCfg.SessionSCfg().DebitInterval != 0 && !passiveSessions) { // Replicating active not supported
|
||||
return
|
||||
}
|
||||
ssMux := &smg.aSessionsMux
|
||||
@@ -734,7 +734,7 @@ func (smg *SMGeneric) InitiateSession(gev SMGenericEvent, clnt rpcclient.RpcClie
|
||||
smg.sessionEnd(cgrID, 0)
|
||||
return
|
||||
}
|
||||
if smg.cgrCfg.SMGConfig.DebitInterval != 0 { // Session handled by debit loop
|
||||
if smg.cgrCfg.SessionSCfg().DebitInterval != 0 { // Session handled by debit loop
|
||||
maxUsage = time.Duration(-1 * time.Second)
|
||||
return
|
||||
}
|
||||
@@ -753,7 +753,7 @@ func (smg *SMGeneric) UpdateSession(gev SMGenericEvent, clnt rpcclient.RpcClient
|
||||
return item.Value.(time.Duration), item.Err
|
||||
}
|
||||
defer smg.responseCache.Cache(cacheKey, &cache.CacheItem{Value: maxUsage, Err: err})
|
||||
if smg.cgrCfg.SMGConfig.DebitInterval != 0 { // Not possible to update a session with debit loop active
|
||||
if smg.cgrCfg.SessionSCfg().DebitInterval != 0 { // Not possible to update a session with debit loop active
|
||||
err = errors.New("ACTIVE_DEBIT_LOOP")
|
||||
return
|
||||
}
|
||||
@@ -770,8 +770,8 @@ func (smg *SMGeneric) UpdateSession(gev SMGenericEvent, clnt rpcclient.RpcClient
|
||||
}
|
||||
smg.resetTerminatorTimer(cgrID,
|
||||
gev.GetSessionTTL(
|
||||
smg.cgrCfg.SMGConfig.SessionTTL,
|
||||
smg.cgrCfg.SMGConfig.SessionTTLMaxDelay),
|
||||
smg.cgrCfg.SessionSCfg().SessionTTL,
|
||||
smg.cgrCfg.SessionSCfg().SessionTTLMaxDelay),
|
||||
gev.GetSessionTTLLastUsed(), gev.GetSessionTTLUsage())
|
||||
var lastUsed *time.Duration
|
||||
var evLastUsed time.Duration
|
||||
@@ -781,7 +781,7 @@ func (smg *SMGeneric) UpdateSession(gev SMGenericEvent, clnt rpcclient.RpcClient
|
||||
return
|
||||
}
|
||||
if maxUsage, err = gev.GetMaxUsage(utils.META_DEFAULT,
|
||||
smg.cgrCfg.SMGConfig.MaxCallDuration); err != nil {
|
||||
smg.cgrCfg.SessionSCfg().MaxCallDuration); err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
err = utils.ErrMandatoryIeMissing
|
||||
}
|
||||
@@ -1283,7 +1283,7 @@ func (smg *SMGeneric) BiRPCV1ReplicateActiveSessions(clnt rpcclient.RpcClientCon
|
||||
args ArgsReplicateSessions, reply *string) (err error) {
|
||||
smgConns := smg.smgReplConns
|
||||
if len(args.Connections) != 0 {
|
||||
if smgConns, err = NewSMGReplicationConns(args.Connections, smg.cgrCfg.Reconnects,
|
||||
if smgConns, err = NewSessionReplicationConns(args.Connections, smg.cgrCfg.Reconnects,
|
||||
smg.cgrCfg.ConnectTimeout, smg.cgrCfg.ReplyTimeout); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ func (smg *SMGeneric) BiRPCV1ReplicatePassiveSessions(clnt rpcclient.RpcClientCo
|
||||
args ArgsReplicateSessions, reply *string) (err error) {
|
||||
smgConns := smg.smgReplConns
|
||||
if len(args.Connections) != 0 {
|
||||
if smgConns, err = NewSMGReplicationConns(args.Connections, smg.cgrCfg.Reconnects,
|
||||
if smgConns, err = NewSessionReplicationConns(args.Connections, smg.cgrCfg.Reconnects,
|
||||
smg.cgrCfg.ConnectTimeout, smg.cgrCfg.ReplyTimeout); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user