Alerting: Add a feature flag to periodically save states (#80987)

This commit is contained in:
Jean-Philippe Quéméner
2024-01-23 17:03:30 +01:00
committed by GitHub
parent f7fd8e6cd1
commit aa25776f81
14 changed files with 81 additions and 23 deletions

View File

@@ -30,7 +30,7 @@ type AlertInstanceManager interface {
}
type StatePersister interface {
Async(ctx context.Context, ticker *clock.Ticker, cache *cache)
Async(ctx context.Context, cache *cache)
Sync(ctx context.Context, span trace.Span, states, staleStates []StateTransition)
}
@@ -103,6 +103,11 @@ func NewManager(cfg ManagerCfg, statePersister StatePersister) *Manager {
return m
}
func (st *Manager) Run(ctx context.Context) error {
st.persister.Async(ctx, st.cache)
return nil
}
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")