From 066d922e720cf8c1a9573664c4b143432f0f84c3 Mon Sep 17 00:00:00 2001 From: Mustafain Ali Khan Date: Thu, 20 Feb 2025 12:50:50 -0800 Subject: [PATCH] fix lint errors Signed-off-by: Mustafain Ali Khan --- rules/group.go | 6 +++--- rules/store.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rules/group.go b/rules/group.go index a00801a01c..d31f6da75b 100644 --- a/rules/group.go +++ b/rules/group.go @@ -73,9 +73,9 @@ type Group struct { // Rule group evaluation iteration function, // defaults to DefaultEvalIterationFunc. evalIterationFunc GroupEvalIterationFunc + alertStore AlertStore - appOpts *storage.AppendOptions - alertStore AlertStore + appOpts *storage.AppendOptions } // GroupEvalIterationFunc is used to implement and extend rule group @@ -146,8 +146,8 @@ func NewGroup(o GroupOptions) *Group { logger: opts.Logger.With("file", o.File, "group", o.Name), metrics: metrics, evalIterationFunc: evalIterationFunc, - appOpts: &storage.AppendOptions{DiscardOutOfOrder: true}, alertStore: o.AlertStore, + appOpts: &storage.AppendOptions{DiscardOutOfOrder: true}, } } diff --git a/rules/store.go b/rules/store.go index e18401a48d..631f5e2799 100644 --- a/rules/store.go +++ b/rules/store.go @@ -115,12 +115,12 @@ func (s *FileStore) SetAlerts(key uint64, groupKey string, alerts []*Alert) erro s.stateMtx.Lock() defer s.stateMtx.Unlock() - // Update in memory - if alerts != nil { - s.alertsByRule[key] = alerts - } else { + if alerts == nil { return nil } + // Update in memory + s.alertsByRule[key] = alerts + // flush in memory state to file storage file, err := os.Create(s.path) if err != nil {