mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
LcrRequest.IgnoreErrors flag implementation, fixes #142
This commit is contained in:
@@ -38,14 +38,17 @@ func (self *ApierV1) GetLcr(lcrReq engine.LcrRequest, lcrReply *engine.LcrReply)
|
||||
if lcrQried.Entry == nil {
|
||||
return utils.ErrNotFound
|
||||
}
|
||||
if lcrQried.HasErrors() {
|
||||
lcrQried.LogErrors()
|
||||
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_COMPUTE_ERRORS")
|
||||
}
|
||||
lcrReply.DestinationId = lcrQried.Entry.DestinationId
|
||||
lcrReply.RPCategory = lcrQried.Entry.RPCategory
|
||||
lcrReply.Strategy = lcrQried.Entry.Strategy
|
||||
for _, qriedSuppl := range lcrQried.SupplierCosts {
|
||||
if qriedSuppl.Error != "" {
|
||||
engine.Logger.Err(fmt.Sprintf("LCR_ERROR: supplier <%s>, error <%s>", qriedSuppl.Supplier, qriedSuppl.Error))
|
||||
if !lcrReq.IgnoreErrors {
|
||||
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_COMPUTE_ERRORS")
|
||||
}
|
||||
continue
|
||||
}
|
||||
if dtcs, err := utils.NewDTCSFromRPKey(qriedSuppl.Supplier); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
} else {
|
||||
@@ -65,7 +68,7 @@ func (self *ApierV1) GetLcrSuppliers(lcrReq engine.LcrRequest, suppliers *string
|
||||
if err := self.Responder.GetLCR(&engine.AttrGetLcr{CallDescriptor: cd, Paginator: lcrReq.Paginator}, &lcrQried); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
if lcrQried.HasErrors() {
|
||||
if lcrQried.HasErrors() && !lcrReq.IgnoreErrors {
|
||||
lcrQried.LogErrors()
|
||||
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_ERRORS")
|
||||
}
|
||||
|
||||
@@ -48,14 +48,15 @@ const (
|
||||
|
||||
// A request for LCR, used in APIer and SM where we need to expose it
|
||||
type LcrRequest struct {
|
||||
Direction string
|
||||
Tenant string
|
||||
Category string
|
||||
Account string
|
||||
Subject string
|
||||
Destination string
|
||||
StartTime string
|
||||
Duration string
|
||||
Direction string
|
||||
Tenant string
|
||||
Category string
|
||||
Account string
|
||||
Subject string
|
||||
Destination string
|
||||
StartTime string
|
||||
Duration string
|
||||
IgnoreErrors bool
|
||||
*utils.Paginator
|
||||
}
|
||||
|
||||
@@ -434,6 +435,9 @@ func (lc *LCRCost) SuppliersSlice() ([]string, error) {
|
||||
}
|
||||
supps := []string{}
|
||||
for _, supplCost := range lc.SupplierCosts {
|
||||
if supplCost.Error != "" {
|
||||
continue // Do not add the supplier with cost errors to list of suppliers available
|
||||
}
|
||||
if dtcs, err := utils.NewDTCSFromRPKey(supplCost.Supplier); err != nil {
|
||||
return nil, err
|
||||
} else if len(dtcs.Subject) != 0 {
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestTutLocalCacheStats(t *testing.T) {
|
||||
}
|
||||
var rcvStats *utils.CacheStats
|
||||
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 8, Actions: 7, SharedGroups: 1, RatingAliases: 1, AccountAliases: 1,
|
||||
DerivedChargers: 1, LcrProfiles: 4, CdrStats: 6, Users: 2}
|
||||
DerivedChargers: 1, LcrProfiles: 5, CdrStats: 6, Users: 2}
|
||||
var args utils.AttrCacheStats
|
||||
if err := tutLocalRpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
|
||||
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
|
||||
@@ -898,8 +898,8 @@ func TestTutLocalLeastCost(t *testing.T) {
|
||||
Direction: "*out",
|
||||
Category: "call",
|
||||
Tenant: "cgrates.org",
|
||||
Subject: "1004",
|
||||
Account: "1004",
|
||||
Subject: "1005",
|
||||
Account: "1005",
|
||||
Destination: "1002",
|
||||
TimeStart: tStart,
|
||||
TimeEnd: tEnd,
|
||||
@@ -924,8 +924,8 @@ func TestTutLocalLeastCost(t *testing.T) {
|
||||
Direction: "*out",
|
||||
Category: "call",
|
||||
Tenant: "cgrates.org",
|
||||
Subject: "1004",
|
||||
Account: "1004",
|
||||
Subject: "1005",
|
||||
Account: "1005",
|
||||
Destination: "1003",
|
||||
TimeStart: tStart,
|
||||
TimeEnd: tEnd,
|
||||
|
||||
Reference in New Issue
Block a user