Alerting: Use org store to read organization IDs (#99938)
This commit is contained in:
@@ -3,8 +3,6 @@ package state
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -28,30 +26,6 @@ func NewMultiInstanceReader(logger log.Logger, r1, r2 InstanceReader) *MultiInst
|
||||
}
|
||||
}
|
||||
|
||||
// FetchOrgIds merges org IDs from both readers.
|
||||
func (m *MultiInstanceReader) FetchOrgIds(ctx context.Context) ([]int64, error) {
|
||||
orgsOne, err := m.ProtoDBReader.FetchOrgIds(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to fetch org IDs from ProtoDBReader: %w", err)
|
||||
}
|
||||
|
||||
orgsTwo, err := m.DBReader.FetchOrgIds(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to fetch org IDs from DBReader: %w", err)
|
||||
}
|
||||
|
||||
orgsSet := make(map[int64]struct{})
|
||||
|
||||
for _, orgID := range orgsOne {
|
||||
orgsSet[orgID] = struct{}{}
|
||||
}
|
||||
for _, orgID := range orgsTwo {
|
||||
orgsSet[orgID] = struct{}{}
|
||||
}
|
||||
|
||||
return slices.Collect(maps.Keys(orgsSet)), nil
|
||||
}
|
||||
|
||||
// ListAlertInstances fetches alert instances for a query from both readers,
|
||||
// groups them by rule UID, and returns the newest instances for each rule as a
|
||||
// single slice.
|
||||
|
||||
Reference in New Issue
Block a user