fix
This commit is contained in:
1 parent
e81b8c2fcd
commit
0052822e49
7 files changed
+94
-1
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"container/ring"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -230,6 +231,22 @@ func (c *Collector) SetIssueStatusStore(ctx context.Context, store issues.Status
|
||||
return c.issues.SetStatusStore(ctx, store)
|
||||
}
|
||||
|
||||
// RestoreIssues rebuilds the bounded in-memory issue index from persisted
|
||||
// occurrences. This keeps /issues aligned with alerting after a restart.
|
||||
func (c *Collector) RestoreIssues(ctx context.Context, occurrences []storage.Occurrence) (int, error) {
|
||||
for _, occurrence := range occurrences {
|
||||
var sample issues.Sample
|
||||
if err := json.Unmarshal(occurrence.Sample, &sample); err != nil {
|
||||
return 0, fmt.Errorf("decode persisted issue sample: %w", err)
|
||||
}
|
||||
if sample.Message == "" {
|
||||
continue
|
||||
}
|
||||
c.issues.Restore(occurrence.Kind, occurrence.Service, sample.Message, sample)
|
||||
}
|
||||
return len(occurrences), nil
|
||||
}
|
||||
|
||||
func (c *Collector) SimilarIssues(id string, limit int) ([]issues.SimilarIssue, bool) {
|
||||
return c.issues.Similar(id, limit)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user