mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* Reduce piecemeal state fields * Read data directly off state instead of rule * Unify state and context into single struct * Expose contextual information to layer above setNextState * Work in terms of ContextualState and call historian in batches * Call annotations service in batches * Export format state and reason and remove workaround in unrelated test package * Add new method to annotation service for batch inserting * Fix loop variable aliasing bug caught by linter, didn't change behavior * Incl timerange on annotation tests * Insert one at a time if tags are present * Point to rule from ContextualState rather than copy fields * Build annotations and copy data prior to starting goroutine * Rename to StateTransition * Use new bulk-insert utility * Remove rule from StateTransition and pass in directly to historian * Simplify annotations logic since we have only one rule * Fix logs and context, nilcheck, simplify method name * Regenerate mock
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package annotations
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
"github.com/grafana/grafana/pkg/util/errutil"
|
|
)
|
|
|
|
var (
|
|
ErrTimerangeMissing = errors.New("missing timerange")
|
|
ErrBaseTagLimitExceeded = errutil.NewBase(errutil.StatusBadRequest, "annotations.tag-limit-exceeded", errutil.WithPublicMessage("Tags length exceeds the maximum allowed."))
|
|
)
|
|
|
|
//go:generate mockery --name Repository --structname FakeAnnotationsRepo --inpackage --filename annotations_repository_mock.go
|
|
type Repository interface {
|
|
Save(ctx context.Context, item *Item) error
|
|
SaveMany(ctx context.Context, items []Item) error
|
|
Update(ctx context.Context, item *Item) error
|
|
Find(ctx context.Context, query *ItemQuery) ([]*ItemDTO, error)
|
|
Delete(ctx context.Context, params *DeleteParams) error
|
|
FindTags(ctx context.Context, query *TagsQuery) (FindTagsResult, error)
|
|
}
|
|
|
|
// Cleaner is responsible for cleaning up old annotations
|
|
type Cleaner interface {
|
|
Run(ctx context.Context, cfg *setting.Cfg) (int64, int64, error)
|
|
}
|