mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 02:29:33 +08:00
Annotation: Add clean up job for old annotations (#26156)
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
package annotations
|
||||
|
||||
import "github.com/grafana/grafana/pkg/components/simplejson"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type Repository interface {
|
||||
Save(item *Item) error
|
||||
@ -9,6 +14,11 @@ type Repository interface {
|
||||
Delete(params *DeleteParams) error
|
||||
}
|
||||
|
||||
// AnnotationCleaner is responsible for cleaning up old annotations
|
||||
type AnnotationCleaner interface {
|
||||
CleanAnnotations(ctx context.Context, cfg *setting.Cfg) error
|
||||
}
|
||||
|
||||
type ItemQuery struct {
|
||||
OrgId int64 `json:"orgId"`
|
||||
From int64 `json:"from"`
|
||||
@ -43,6 +53,15 @@ type DeleteParams struct {
|
||||
}
|
||||
|
||||
var repositoryInstance Repository
|
||||
var cleanerInstance AnnotationCleaner
|
||||
|
||||
func GetAnnotationCleaner() AnnotationCleaner {
|
||||
return cleanerInstance
|
||||
}
|
||||
|
||||
func SetAnnotationCleaner(rep AnnotationCleaner) {
|
||||
cleanerInstance = rep
|
||||
}
|
||||
|
||||
func GetRepository() Repository {
|
||||
return repositoryInstance
|
||||
@ -74,6 +93,10 @@ type Item struct {
|
||||
Title string
|
||||
}
|
||||
|
||||
func (i Item) TableName() string {
|
||||
return "annotation"
|
||||
}
|
||||
|
||||
type ItemDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
AlertId int64 `json:"alertId"`
|
||||
|
Reference in New Issue
Block a user