mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Agents: changing continue_on_success to continue
This commit is contained in:
committed by
Dan Christian Bogos
parent
7ea7c98ea4
commit
b9d89edb4b
@@ -218,7 +218,7 @@ func (da *DiameterAgent) handleMessage(c diam.Conn, m *diam.Message) {
|
||||
processed = lclProcessed
|
||||
}
|
||||
if err != nil ||
|
||||
(lclProcessed && !reqProcessor.ContinueOnSuccess) {
|
||||
(lclProcessed && !reqProcessor.Continue) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func (da *DNSAgent) handleMessage(w dns.ResponseWriter, req *dns.Msg) {
|
||||
processed = lclProcessed
|
||||
}
|
||||
if err != nil ||
|
||||
(lclProcessed && !reqProcessor.ContinueOnSuccess) {
|
||||
(lclProcessed && !reqProcessor.Continue) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (ha *HTTPAgent) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
utils.HTTPAgent, err.Error(), utils.ToJSON(agReq.Reply)))
|
||||
return
|
||||
}
|
||||
if lclProcessed && !reqProcessor.ContinueOnSuccess {
|
||||
if lclProcessed && !reqProcessor.Continue {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (ra *RadiusAgent) handleAuth(req *radigo.Packet) (rpl *radigo.Packet, err e
|
||||
if lclProcessed, err = ra.processRequest(reqProcessor, agReq, rpl); lclProcessed {
|
||||
processed = lclProcessed
|
||||
}
|
||||
if err != nil || (lclProcessed && !reqProcessor.ContinueOnSuccess) {
|
||||
if err != nil || (lclProcessed && !reqProcessor.Continue) {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (ra *RadiusAgent) handleAcct(req *radigo.Packet) (rpl *radigo.Packet, err e
|
||||
if lclProcessed, err = ra.processRequest(reqProcessor, agReq, rpl); lclProcessed {
|
||||
processed = lclProcessed
|
||||
}
|
||||
if err != nil || (lclProcessed && !reqProcessor.ContinueOnSuccess) {
|
||||
if err != nil || (lclProcessed && !reqProcessor.Continue) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,18 +80,18 @@ func TestRequestProcessorloadFromJsonCfg(t *testing.T) {
|
||||
t.Errorf("Expected: %+v ,recived: %+v", expected, dareq)
|
||||
}
|
||||
json := &ReqProcessorJsnCfg{
|
||||
ID: utils.StringPointer("cgrates"),
|
||||
Tenant: utils.StringPointer("tenant"),
|
||||
Filters: &[]string{"filter1", "filter2"},
|
||||
Flags: &[]string{"flag1", "flag2"},
|
||||
Continue_on_success: utils.BoolPointer(true),
|
||||
ID: utils.StringPointer("cgrates"),
|
||||
Tenant: utils.StringPointer("tenant"),
|
||||
Filters: &[]string{"filter1", "filter2"},
|
||||
Flags: &[]string{"flag1", "flag2"},
|
||||
Continue: utils.BoolPointer(true),
|
||||
}
|
||||
expected = RequestProcessor{
|
||||
ID: "cgrates",
|
||||
Tenant: NewRSRParsersMustCompile("tenant", true, utils.INFIELD_SEP),
|
||||
Filters: []string{"filter1", "filter2"},
|
||||
Flags: utils.FlagsWithParams{"flag1": []string{}, "flag2": []string{}},
|
||||
ContinueOnSuccess: true,
|
||||
ID: "cgrates",
|
||||
Tenant: NewRSRParsersMustCompile("tenant", true, utils.INFIELD_SEP),
|
||||
Filters: []string{"filter1", "filter2"},
|
||||
Flags: utils.FlagsWithParams{"flag1": []string{}, "flag2": []string{}},
|
||||
Continue: true,
|
||||
}
|
||||
if err = dareq.loadFromJsonCfg(json, utils.INFIELD_SEP); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -78,14 +78,14 @@ func (da *DNSAgentCfg) loadFromJsonCfg(jsnCfg *DNSAgentJsonCfg, sep string) (err
|
||||
|
||||
// One request processor configuration
|
||||
type RequestProcessor struct {
|
||||
ID string
|
||||
Tenant RSRParsers
|
||||
Filters []string
|
||||
Flags utils.FlagsWithParams
|
||||
ContinueOnSuccess bool
|
||||
Timezone string
|
||||
RequestFields []*FCTemplate
|
||||
ReplyFields []*FCTemplate
|
||||
ID string
|
||||
Tenant RSRParsers
|
||||
Filters []string
|
||||
Flags utils.FlagsWithParams
|
||||
Continue bool
|
||||
Timezone string
|
||||
RequestFields []*FCTemplate
|
||||
ReplyFields []*FCTemplate
|
||||
}
|
||||
|
||||
func (rp *RequestProcessor) loadFromJsonCfg(jsnCfg *ReqProcessorJsnCfg, sep string) (err error) {
|
||||
@@ -109,8 +109,8 @@ func (rp *RequestProcessor) loadFromJsonCfg(jsnCfg *ReqProcessorJsnCfg, sep stri
|
||||
if jsnCfg.Timezone != nil {
|
||||
rp.Timezone = *jsnCfg.Timezone
|
||||
}
|
||||
if jsnCfg.Continue_on_success != nil {
|
||||
rp.ContinueOnSuccess = *jsnCfg.Continue_on_success
|
||||
if jsnCfg.Continue != nil {
|
||||
rp.Continue = *jsnCfg.Continue
|
||||
}
|
||||
if jsnCfg.Tenant != nil {
|
||||
if rp.Tenant, err = NewRSRParsers(*jsnCfg.Tenant, true, sep); err != nil {
|
||||
|
||||
@@ -338,14 +338,14 @@ type DNSAgentJsonCfg struct {
|
||||
}
|
||||
|
||||
type ReqProcessorJsnCfg struct {
|
||||
ID *string
|
||||
Filters *[]string
|
||||
Tenant *string
|
||||
Timezone *string
|
||||
Flags *[]string
|
||||
Continue_on_success *bool
|
||||
Request_fields *[]*FcTemplateJsonCfg
|
||||
Reply_fields *[]*FcTemplateJsonCfg
|
||||
ID *string
|
||||
Filters *[]string
|
||||
Tenant *string
|
||||
Timezone *string
|
||||
Flags *[]string
|
||||
Continue *bool
|
||||
Request_fields *[]*FcTemplateJsonCfg
|
||||
Reply_fields *[]*FcTemplateJsonCfg
|
||||
}
|
||||
|
||||
// Attribute service config section
|
||||
|
||||
@@ -203,7 +203,7 @@ func TestMfHttpAgentMultipleFields(t *testing.T) {
|
||||
RequestProcessors: []*RequestProcessor{{
|
||||
ID: "cdr_from_xml",
|
||||
Tenant: NewRSRParsersMustCompile("cgrates.org", true, utils.INFIELD_SEP),
|
||||
Flags: utils.FlagsWithParams{"*cdrs": true},
|
||||
Flags: utils.FlagsWithParams{"*cdrs": []string{}},
|
||||
RequestFields: []*FCTemplate{
|
||||
{
|
||||
Tag: "TOR",
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
|
||||
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"],
|
||||
"flags": ["*update", "*accounts"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"},
|
||||
{"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed",
|
||||
@@ -61,6 +60,7 @@
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"id": "dryrun1",
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"],
|
||||
"flags": ["*dryrun"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"},
|
||||
{"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"},
|
||||
@@ -36,6 +35,7 @@
|
||||
{"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum",
|
||||
"value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
{
|
||||
"id": "dryrun2",
|
||||
|
||||
@@ -76,9 +76,9 @@
|
||||
"id": "maxconn",
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"],
|
||||
"flags": ["*dryrun"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[],
|
||||
"reply_fields":[],
|
||||
"continue": true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
|
||||
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"],
|
||||
"flags": ["*update", "*accounts"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"},
|
||||
{"tag": "InitialOriginID", "field_id": "InitialOriginID", "type": "*composed",
|
||||
@@ -61,6 +60,7 @@
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"id": "dryrun1",
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"],
|
||||
"flags": ["*dryrun"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"},
|
||||
{"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"},
|
||||
@@ -36,6 +35,7 @@
|
||||
{"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum",
|
||||
"value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
{
|
||||
"id": "dryrun2",
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
|
||||
"*string:*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:*req.Service-Context-Id:gprs"],
|
||||
"flags": ["*update", "*accounts"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*data"},
|
||||
{"tag": "*api_key", "field_id": "*api_key", "type": "*constant", "value": "ses12345"},
|
||||
@@ -63,6 +62,7 @@
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"id": "dryrun1",
|
||||
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"],
|
||||
"flags": ["*dryrun"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"},
|
||||
{"tag": "*api_key", "field_id": "*api_key", "type": "*constant", "value": "ses12345"},
|
||||
@@ -37,6 +36,7 @@
|
||||
{"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum",
|
||||
"value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
{
|
||||
"id": "dryrun2",
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
"id": "KamailioAuth",
|
||||
"filters": ["*string:~*vars.*radReqType:*radAuth"],
|
||||
"flags": ["*auth", "*accounts","*dispatchers"],
|
||||
"continue_on_success": false,
|
||||
"request_fields":[
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
|
||||
// {"tag": "*api_key", "field_id": "*api_key", "type": "*constant", "value": "ses12345"},
|
||||
@@ -83,7 +82,6 @@
|
||||
"id": "KamailioAccountingStart",
|
||||
"filters": ["*string:~*req.Acct-Status-Type:Start"],
|
||||
"flags": ["*initiate", "*attributes", "*resources", "*accounts","*dispatchers"],
|
||||
"continue_on_success": false,
|
||||
"request_fields":[
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
|
||||
// {"tag": "*api_key", "field_id": "*api_key", "type": "*constant", "value": "ses12345"},
|
||||
@@ -111,7 +109,6 @@
|
||||
"id": "KamailioAccountingStop",
|
||||
"filters": ["*string:~*req.Acct-Status-Type:Stop"],
|
||||
"flags": ["*terminate", "*resources", "*accounts", "*cdrs","*dispatchers"],
|
||||
"continue_on_success": false,
|
||||
"request_fields":[
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
|
||||
// {"tag": "*api_key", "field_id": "*api_key", "type": "*constant", "value": "ses12345"},
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"filters": ["*string:~*vars.QueryType:NAPTR",
|
||||
"*string:~*vars.E164Address:4986517174965"],
|
||||
"flags": ["*event", "*suppliers"],
|
||||
"continue_on_success": true,
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile
|
||||
],
|
||||
@@ -15,6 +14,7 @@
|
||||
{"tag": "DispatchReply", "type": "*none",
|
||||
"blocker": true}, // enforces continue_on_success so we can check answer with filters
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersOneSupplier",
|
||||
@@ -22,7 +22,6 @@
|
||||
"*string:~*vars.E164Address:4986517174965",
|
||||
"*gte:~*cgrep.Suppliers.Count:1"],
|
||||
"flags": ["*none"], // do not send request to CGRateS
|
||||
"continue_on_success": true,
|
||||
"reply_fields":[
|
||||
{"tag": "NAPTROrder", "field_id": "Order",
|
||||
"type": "*constant", "value": "100"},
|
||||
@@ -35,6 +34,7 @@
|
||||
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable",
|
||||
"value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersTwoSuppliers",
|
||||
@@ -42,7 +42,6 @@
|
||||
"*string:~*vars.E164Address:4986517174965",
|
||||
"*gte:~*cgrep.Suppliers.Count:2"],
|
||||
"flags": ["*none"],
|
||||
"continue_on_success": true,
|
||||
"reply_fields":[
|
||||
{"tag": "NAPTROrder", "type": "*constant", "new_branch": true,
|
||||
"field_id": "Order", "value": "100"},
|
||||
@@ -55,6 +54,7 @@
|
||||
{"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable",
|
||||
"value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"},
|
||||
],
|
||||
"continue": true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -88,7 +88,6 @@
|
||||
"id": "KamailioAuth",
|
||||
"filters": ["*string:~*vars.*radReqType:*radAuth"],
|
||||
"flags": ["*auth", "*accounts"],
|
||||
"continue_on_success": false,
|
||||
"request_fields":[
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
|
||||
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
|
||||
@@ -115,7 +114,6 @@
|
||||
"id": "KamailioAccountingStart",
|
||||
"filters": ["*string:~*req.Acct-Status-Type:Start"],
|
||||
"flags": ["*initiate", "*attributes", "*resources", "*accounts"],
|
||||
"continue_on_success": false,
|
||||
"request_fields":[
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
|
||||
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
|
||||
@@ -142,7 +140,6 @@
|
||||
"id": "KamailioAccountingStop",
|
||||
"filters": ["*string:~*req.Acct-Status-Type:Stop"],
|
||||
"flags": ["*terminate", "*resources", "*accounts", "*cdrs"],
|
||||
"continue_on_success": false,
|
||||
"request_fields":[
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
|
||||
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant",
|
||||
|
||||
Reference in New Issue
Block a user