From f85a948214eeeb714eefa4ae4474b075d33f11bb Mon Sep 17 00:00:00 2001 From: gotjosh Date: Wed, 11 Jan 2023 19:50:45 -0400 Subject: [PATCH] Alerting Unification: Use the State interface from the alerting package (#61333) --- pkg/services/ngalert/notifier/file_store.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/services/ngalert/notifier/file_store.go b/pkg/services/ngalert/notifier/file_store.go index b5913456ede..c9acb0f0ad4 100644 --- a/pkg/services/ngalert/notifier/file_store.go +++ b/pkg/services/ngalert/notifier/file_store.go @@ -7,18 +7,14 @@ import ( "os" "path/filepath" + "github.com/grafana/alerting/alerting" + "github.com/grafana/grafana/pkg/infra/kvstore" "github.com/grafana/grafana/pkg/infra/log" ) const KVNamespace = "alertmanager" -// State represents any of the two 'states' of the alertmanager. Notification log or Silences. -// MarshalBinary returns the binary representation of this internal state based on the protobuf. -type State interface { - MarshalBinary() ([]byte, error) -} - // FileStore is in charge of persisting the alertmanager files to the database. // It uses the KVstore table and encodes the files as a base64 string. type FileStore struct { @@ -67,7 +63,7 @@ func (fileStore *FileStore) FilepathFor(ctx context.Context, filename string) (s } // Persist takes care of persisting the binary representation of internal state to the database as a base64 encoded string. -func (fileStore *FileStore) Persist(ctx context.Context, filename string, st State) (int64, error) { +func (fileStore *FileStore) Persist(ctx context.Context, filename string, st alerting.State) (int64, error) { var size int64 bytes, err := st.MarshalBinary()