mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Update state manager to accept rule store as Warm method argument (#58244)
This commit is contained in:
@@ -32,22 +32,19 @@ type Manager struct {
|
||||
quit chan struct{}
|
||||
ResendDelay time.Duration
|
||||
|
||||
ruleStore RuleReader
|
||||
instanceStore InstanceStore
|
||||
imageService image.ImageService
|
||||
historian Historian
|
||||
externalURL *url.URL
|
||||
}
|
||||
|
||||
func NewManager(metrics *metrics.State, externalURL *url.URL,
|
||||
ruleStore RuleReader, instanceStore InstanceStore, imageService image.ImageService, clock clock.Clock, historian Historian) *Manager {
|
||||
func NewManager(metrics *metrics.State, externalURL *url.URL, instanceStore InstanceStore, imageService image.ImageService, clock clock.Clock, historian Historian) *Manager {
|
||||
manager := &Manager{
|
||||
cache: newCache(),
|
||||
quit: make(chan struct{}),
|
||||
ResendDelay: ResendDelay, // TODO: make this configurable
|
||||
log: log.New("ngalert.state.manager"),
|
||||
metrics: metrics,
|
||||
ruleStore: ruleStore,
|
||||
instanceStore: instanceStore,
|
||||
imageService: imageService,
|
||||
historian: historian,
|
||||
@@ -64,12 +61,10 @@ func (st *Manager) Close() {
|
||||
st.quit <- struct{}{}
|
||||
}
|
||||
|
||||
func (st *Manager) Warm(ctx context.Context) {
|
||||
func (st *Manager) Warm(ctx context.Context, rulesReader RuleReader) {
|
||||
if st.instanceStore == nil {
|
||||
st.log.Info("Skip warming the state because instance store is not configured")
|
||||
}
|
||||
if st.ruleStore == nil {
|
||||
st.log.Info("Skip warming the state because rule store is not configured")
|
||||
return
|
||||
}
|
||||
startTime := time.Now()
|
||||
st.log.Info("Warming state cache for startup")
|
||||
@@ -86,7 +81,7 @@ func (st *Manager) Warm(ctx context.Context) {
|
||||
ruleCmd := ngModels.ListAlertRulesQuery{
|
||||
OrgID: orgId,
|
||||
}
|
||||
if err := st.ruleStore.ListAlertRules(ctx, &ruleCmd); err != nil {
|
||||
if err := rulesReader.ListAlertRules(ctx, &ruleCmd); err != nil {
|
||||
st.log.Error("Unable to fetch previous state", "error", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user