Update Threshold ProcessEvent in Stats and Resource

This commit is contained in:
TeoV
2018-05-16 09:56:29 -04:00
committed by Dan Christian Bogos
parent 94363df4d6
commit e55d6629dc
8 changed files with 97 additions and 96 deletions

View File

@@ -519,8 +519,8 @@ func (rS *ResourceService) processThresholds(r *Resource) (err error) {
utils.EventType: utils.ResourceUpdate,
utils.ResourceID: r.ID,
utils.Usage: r.totalUsage()}}}
var hits int
if err = rS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil &&
var tIDs []string
if err = rS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
err.Error() != utils.ErrNotFound.Error() {
utils.Logger.Warning(
fmt.Sprintf("<ResourceS> error: %s processing event %+v with ThresholdS.", err.Error(), thEv))

View File

@@ -260,8 +260,8 @@ func (sS *StatService) processEvent(ev *utils.CGREvent) (err error) {
thEv.Event[metricID] = metric.GetValue()
}
if sS.thdS != nil {
var hits int
if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil &&
var tIDs []string
if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
err.Error() != utils.ErrNotFound.Error() {
utils.Logger.Warning(
fmt.Sprintf("<StatS> error: %s processing event %+v with ThresholdS.", err.Error(), thEv))

View File

@@ -280,15 +280,15 @@ type ArgsProcessEvent struct {
}
// processEvent processes a new event, dispatching to matching thresholds
func (tS *ThresholdService) processEvent(args *ArgsProcessEvent) (eventIDs []string, err error) {
func (tS *ThresholdService) processEvent(args *ArgsProcessEvent) (thresholdsIDs []string, err error) {
matchTs, err := tS.matchingThresholdsForEvent(args)
if err != nil {
return nil, err
}
var withErrors bool
var evIds []string
var tIDs []string
for _, t := range matchTs {
evIds = append(evIds, utils.ConcatenatedKey(t.TenantID(), args.CGREvent.ID))
tIDs = append(tIDs, t.ID)
t.Hits += 1
err = t.ProcessEvent(args, tS.dm)
if err != nil {
@@ -319,10 +319,10 @@ func (tS *ThresholdService) processEvent(args *ArgsProcessEvent) (eventIDs []str
tS.stMux.Unlock()
}
}
if len(evIds) != 0 {
eventIDs = append(eventIDs, evIds...)
if len(tIDs) != 0 {
thresholdsIDs = append(thresholdsIDs, tIDs...)
} else {
eventIDs = []string{}
thresholdsIDs = []string{}
}
if withErrors {
err = utils.ErrPartiallyExecuted