notify: optimize length check. (#2106)

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2019-11-19 16:00:06 +08:00 committed by Simon Pasquier
parent 66a0ed21bd
commit d965ac6393
1 changed files with 3 additions and 2 deletions

View File

@ -576,18 +576,19 @@ func (n *DedupStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Al
ctx = WithResolvedAlerts(ctx, resolved)
entries, err := n.nflog.Query(nflog.QGroupKey(gkey), nflog.QReceiver(n.recv))
if err != nil && err != nflog.ErrNotFound {
return ctx, nil, err
}
var entry *nflogpb.Entry
switch len(entries) {
case 0:
case 1:
entry = entries[0]
case 2:
default:
return ctx, nil, fmt.Errorf("unexpected entry result size %d", len(entries))
}
if n.needsUpdate(entry, firingSet, resolvedSet, repeatInterval) {
return ctx, alerts, nil
}