mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Finish update for thresholds
This commit is contained in:
committed by
Dan Christian Bogos
parent
e55d6629dc
commit
9b8a57a12d
@@ -270,9 +270,9 @@ func (kev KamEvent) AsKamAuthReply(authArgs *sessions.V1AuthorizeArgs,
|
||||
kar.Suppliers = authReply.Suppliers.Digest()
|
||||
}
|
||||
|
||||
// if authArgs.ProcessThresholds != nil && *authArgs.ProcessThresholds {
|
||||
// kar.ThresholdIDs = *authReply.ThresholdHits
|
||||
// }
|
||||
if authArgs.ProcessThresholds != nil && *authArgs.ProcessThresholds {
|
||||
kar.Thresholds = strings.Join(*authReply.ThresholdIDs, utils.FIELDS_SEP)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -345,8 +345,8 @@ type KamAuthReply struct {
|
||||
ResourceAllocation string
|
||||
MaxUsage int // Maximum session time in case of success, -1 for unlimited
|
||||
Suppliers string // List of suppliers, comma separated
|
||||
//ThresholdIDs string need to check if can use []string
|
||||
Error string // Reply in case of error
|
||||
Thresholds string
|
||||
Error string // Reply in case of error
|
||||
}
|
||||
|
||||
func (self *KamAuthReply) String() string {
|
||||
|
||||
@@ -1089,9 +1089,9 @@ func (acnt *Account) Publish() {
|
||||
utils.Account: acntTnt.ID,
|
||||
utils.AllowNegative: acnt.AllowNegative,
|
||||
utils.Disabled: acnt.Disabled}}}
|
||||
var hits int
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent,
|
||||
thEv, &hits); err != nil &&
|
||||
thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing account event %+v with ThresholdS.", err.Error(), thEv))
|
||||
|
||||
@@ -715,8 +715,8 @@ func (b *Balance) Publish() {
|
||||
if !b.ExpirationDate.IsZero() {
|
||||
thEv.Event[utils.ExpiryTime] = b.ExpirationDate.Format(time.RFC3339)
|
||||
}
|
||||
var hits int
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil &&
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing balance event %+v with ThresholdS.",
|
||||
@@ -825,8 +825,8 @@ func (bc Balances) SaveDirtyBalances(acc *Account) {
|
||||
thEv.Event[utils.ExpiryTime] = b.ExpirationDate.Format(time.RFC3339)
|
||||
}
|
||||
if thresholdS != nil {
|
||||
var hits int
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil &&
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing balance event %+v with ThresholdS.",
|
||||
@@ -873,8 +873,8 @@ func (bc Balances) SaveDirtyBalances(acc *Account) {
|
||||
utils.Account: acntTnt.ID,
|
||||
utils.AllowNegative: acnt.AllowNegative,
|
||||
utils.Disabled: acnt.Disabled}}}
|
||||
var hits int
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil &&
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing account event %+v with ThresholdS.", err.Error(), thEv))
|
||||
|
||||
@@ -193,10 +193,10 @@ func (self *CdrServer) processCdr(cdr *CDR) (err error) {
|
||||
}
|
||||
}
|
||||
if self.thdS != nil {
|
||||
var hits int
|
||||
var tIDs []string
|
||||
thEv := &ArgsProcessEvent{
|
||||
CGREvent: *cdr.AsCGREvent()}
|
||||
if err := self.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil &&
|
||||
if err := self.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<CDRS> error: %s processing CDR event %+v with thdS.", err.Error(), thEv))
|
||||
|
||||
@@ -1476,6 +1476,7 @@ type V1AuthorizeReplyWithDigest struct {
|
||||
ResourceAllocation *string
|
||||
MaxUsage *float64 // special treat returning time.Duration.Seconds()
|
||||
SuppliersDigest *string
|
||||
Thresholds *string
|
||||
}
|
||||
|
||||
// BiRPCv1AuthorizeEventWithDigest performs authorization for CGREvent based on specific components
|
||||
@@ -1486,7 +1487,6 @@ func (smg *SMGeneric) BiRPCv1AuthorizeEventWithDigest(clnt rpcclient.RpcClientCo
|
||||
!args.GetMaxUsage && !args.GetSuppliers {
|
||||
return utils.NewErrMandatoryIeMissing("subsystems")
|
||||
}
|
||||
|
||||
var initAuthRply V1AuthorizeReply
|
||||
if err = smg.BiRPCv1AuthorizeEvent(clnt, args, &initAuthRply); err != nil {
|
||||
return
|
||||
@@ -1506,6 +1506,10 @@ func (smg *SMGeneric) BiRPCv1AuthorizeEventWithDigest(clnt rpcclient.RpcClientCo
|
||||
if args.GetSuppliers {
|
||||
authReply.SuppliersDigest = utils.StringPointer(initAuthRply.Suppliers.Digest())
|
||||
}
|
||||
if *args.ProcessThresholds {
|
||||
authReply.Thresholds = utils.StringPointer(
|
||||
strings.Join(*initAuthRply.ThresholdIDs, utils.FIELDS_SEP))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1649,7 +1653,7 @@ type V1InitReplyWithDigest struct {
|
||||
AttributesDigest *string
|
||||
ResourceAllocation *string
|
||||
MaxUsage *float64
|
||||
//ThresholdsHits *int
|
||||
Thresholds *string
|
||||
}
|
||||
|
||||
func (smg *SMGeneric) BiRPCv1InitiateSessionWithDigest(clnt rpcclient.RpcClientConnection,
|
||||
@@ -1678,6 +1682,10 @@ func (smg *SMGeneric) BiRPCv1InitiateSessionWithDigest(clnt rpcclient.RpcClientC
|
||||
}
|
||||
}
|
||||
|
||||
if *args.ProcessThresholds {
|
||||
initReply.Thresholds = utils.StringPointer(
|
||||
strings.Join(*initSessionRply.ThresholdIDs, utils.FIELDS_SEP))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user