From 07ea67e638d5584ee4e8f8e22403af7c3383a40c Mon Sep 17 00:00:00 2001 From: gezimbll Date: Tue, 7 May 2024 10:57:38 -0400 Subject: [PATCH] update threshold to set snooze time after actions --- engine/thresholds.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/engine/thresholds.go b/engine/thresholds.go index 476b40631..b7713b034 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -172,14 +172,18 @@ func processEventWithThreshold(ctx *context.Context, connMgr *ConnManager, actio var reply string if !t.tPrfl.Async { - return connMgr.Call(ctx, actionsConns, utils.ActionSv1ExecuteActions, args, &reply) - } - go func() { - if errExec := connMgr.Call(context.Background(), actionsConns, utils.ActionSv1ExecuteActions, - args, &reply); errExec != nil { - utils.Logger.Warning(fmt.Sprintf(" failed executing actions for threshold: %s, error: %s", t.TenantID(), errExec.Error())) + if err = connMgr.Call(ctx, actionsConns, utils.ActionSv1ExecuteActions, args, &reply); err != nil { + return } - }() + } else { + go func() { + if errExec := connMgr.Call(context.Background(), actionsConns, utils.ActionSv1ExecuteActions, + args, &reply); errExec != nil { + utils.Logger.Warning(fmt.Sprintf(" failed executing actions for threshold: %s, error: %s", t.TenantID(), errExec.Error())) + } + }() + } + t.Snooze = time.Now().Add(t.tPrfl.MinSleep) return } @@ -465,7 +469,7 @@ func (tS *ThresholdS) processEvent(ctx *context.Context, tnt string, args *utils } continue } - t.Snooze = time.Now().Add(t.tPrfl.MinSleep) + // recurrent threshold *t.dirty = true // mark it to be saved if tS.cfg.ThresholdSCfg().StoreInterval == -1 {