mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Alerting Unification: Use the State interface from the alerting package (#61333)
This commit is contained in:
parent
7eaa95729c
commit
f85a948214
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user