mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 22:29:55 +05:00
DiameterAgent synced_conn_requests setting
This commit is contained in:
@@ -110,8 +110,12 @@ func (da *DiameterAgent) handlers() diam.Handler {
|
||||
}
|
||||
|
||||
dSM := sm.New(settings)
|
||||
if da.cgrCfg.DiameterAgentCfg().SyncedConnReqs {
|
||||
dSM.HandleFunc("ALL", da.handleMessage)
|
||||
} else {
|
||||
dSM.HandleFunc("ALL", da.handleMessageAsync)
|
||||
}
|
||||
|
||||
dSM.HandleFunc("ALL", da.handleMessageAsync) // route all commands to one dispatcher
|
||||
go func() {
|
||||
for err := range dSM.ErrorReports() {
|
||||
utils.Logger.Err(fmt.Sprintf("<%s> sm error: %v", utils.DiameterAgent, err))
|
||||
|
||||
@@ -372,6 +372,7 @@ const CGRATES_CFG_JSON = `
|
||||
"vendor_id": 0, // diameter Vendor-Id AVP used in replies
|
||||
"product_name": "CGRateS", // diameter Product-Name AVP used in replies
|
||||
"max_active_requests": -1, // limit the number of active requests processed by the server <-1|0-n>
|
||||
"synced_conn_requests": false, // process one request at the time per connection
|
||||
"asr_template": "", // enable AbortSession message being sent to client on DisconnectSession
|
||||
"templates":{ // default message templates
|
||||
"*err": [
|
||||
|
||||
@@ -578,12 +578,13 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
|
||||
{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
}},
|
||||
Origin_host: utils.StringPointer("CGR-DA"),
|
||||
Origin_realm: utils.StringPointer("cgrates.org"),
|
||||
Vendor_id: utils.IntPointer(0),
|
||||
Product_name: utils.StringPointer("CGRateS"),
|
||||
Max_active_requests: utils.IntPointer(-1),
|
||||
Asr_template: utils.StringPointer(""),
|
||||
Origin_host: utils.StringPointer("CGR-DA"),
|
||||
Origin_realm: utils.StringPointer("cgrates.org"),
|
||||
Vendor_id: utils.IntPointer(0),
|
||||
Product_name: utils.StringPointer("CGRateS"),
|
||||
Max_active_requests: utils.IntPointer(-1),
|
||||
Synced_conn_requests: utils.BoolPointer(false),
|
||||
Asr_template: utils.StringPointer(""),
|
||||
Templates: map[string][]*FcTemplateJsonCfg{
|
||||
utils.MetaErr: {
|
||||
{Tag: utils.StringPointer("SessionId"),
|
||||
|
||||
@@ -33,6 +33,7 @@ type DiameterAgentCfg struct {
|
||||
VendorId int
|
||||
ProductName string
|
||||
MaxActiveReqs int // limit the maximum number of requests processed
|
||||
SyncedConnReqs bool
|
||||
ASRTemplate string
|
||||
Templates map[string][]*FCTemplate
|
||||
RequestProcessors []*DARequestProcessor
|
||||
@@ -76,6 +77,9 @@ func (da *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg, separa
|
||||
if jsnCfg.Max_active_requests != nil {
|
||||
da.MaxActiveReqs = *jsnCfg.Max_active_requests
|
||||
}
|
||||
if jsnCfg.Synced_conn_requests != nil {
|
||||
da.SyncedConnReqs = *jsnCfg.Synced_conn_requests
|
||||
}
|
||||
if jsnCfg.Asr_template != nil {
|
||||
da.ASRTemplate = *jsnCfg.Asr_template
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ func TestDiameterAgentCfgloadFromJsonCfg(t *testing.T) {
|
||||
"origin_realm": "cgrates.org", // diameter Origin-Realm AVP used in replies
|
||||
"vendor_id": 0, // diameter Vendor-Id AVP used in replies
|
||||
"product_name": "CGRateS", // diameter Product-Name AVP used in replies
|
||||
"synced_conn_requests": true,
|
||||
"templates":{},
|
||||
"request_processors": [],
|
||||
},
|
||||
@@ -61,6 +62,7 @@ func TestDiameterAgentCfgloadFromJsonCfg(t *testing.T) {
|
||||
OriginRealm: "cgrates.org",
|
||||
VendorId: 0,
|
||||
ProductName: "CGRateS",
|
||||
SyncedConnReqs: true,
|
||||
Templates: make(map[string][]*FCTemplate),
|
||||
}
|
||||
if jsnCfg, err := NewCgrJsonCfgFromReader(strings.NewReader(cfgJSONStr)); err != nil {
|
||||
|
||||
@@ -320,19 +320,20 @@ type OsipsConnJsonCfg struct {
|
||||
|
||||
// DiameterAgent configuration
|
||||
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>
|
||||
Listen_net *string
|
||||
Dictionaries_path *string // path towards additional dictionaries
|
||||
Sessions_conns *[]*HaPoolJsonCfg // Connections towards SessionS
|
||||
Origin_host *string
|
||||
Origin_realm *string
|
||||
Vendor_id *int
|
||||
Product_name *string
|
||||
Max_active_requests *int
|
||||
Asr_template *string
|
||||
Templates map[string][]*FcTemplateJsonCfg
|
||||
Request_processors *[]*DARequestProcessorJsnCfg
|
||||
Enabled *bool
|
||||
Listen *string
|
||||
Listen_net *string
|
||||
Dictionaries_path *string
|
||||
Sessions_conns *[]*HaPoolJsonCfg
|
||||
Origin_host *string
|
||||
Origin_realm *string
|
||||
Vendor_id *int
|
||||
Product_name *string
|
||||
Max_active_requests *int
|
||||
Synced_conn_requests *bool
|
||||
Asr_template *string
|
||||
Templates map[string][]*FcTemplateJsonCfg
|
||||
Request_processors *[]*DARequestProcessorJsnCfg
|
||||
}
|
||||
|
||||
// One Diameter request processor configuration
|
||||
@@ -341,7 +342,7 @@ type DARequestProcessorJsnCfg struct {
|
||||
Tenant *string
|
||||
Filters *[]string
|
||||
Flags *[]string
|
||||
Timezone *string // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
|
||||
Timezone *string
|
||||
Continue_on_success *bool
|
||||
Request_fields *[]*FcTemplateJsonCfg
|
||||
Reply_fields *[]*FcTemplateJsonCfg
|
||||
|
||||
Reference in New Issue
Block a user