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
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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) {}
|
||||
Reference in New Issue
Block a user