Files
grafana/pkg/storage/unified/resource/pruner.go
owensmallwood d715bda8af Unified Storage: Adds pruner to kv backend (#110549)
* WIP adding pruner to kv store impl

* pruner only keeps 20 most recent versions

* ignore grafana-kv-data folder

* extracts some stuff to pruner.go file. Adds tests. Adds kvBackendOptions.

* update logging, comments, exports kvbackendoptions fields

* update nooppruner ref

* fixes field casing in test

* fix test

* linter fixes

* remove comment

* make KvStorageBackend private

* Adds pruner key validation and tests. Fixes broken tests.

* update error message when validating pruner key
2025-09-05 10:02:11 -06:00

31 lines
664 B
Go

package resource
import "context"
// Pruner Small abstraction to allow for different Pruner implementations.
// This can be removed once the debouncer is deployed.
type Pruner interface {
Add(key PruningKey) error
Start(ctx context.Context)
}
// PruningKey is a comparable key for pruning history.
type PruningKey struct {
Namespace string
Group string
Resource string
Name string
}
func (k PruningKey) Validate() bool {
return k.Namespace != "" && k.Group != "" && k.Resource != "" && k.Name != ""
}
type NoopPruner struct{}
func (p *NoopPruner) Add(key PruningKey) error {
return nil
}
func (p *NoopPruner) Start(ctx context.Context) {}