mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 05:30:12 +08:00
Storage: Add resource version matching in unified storage API (#102417)
Add NotOlderThan support to getHistory Add support for Exact Add tests Refactor tests Add error test Co-authored-by: Marco de Abreu <18629099+marcoabreu@users.noreply.github.com>
This commit is contained in:
@ -798,6 +798,19 @@ func (b *backend) getHistory(ctx context.Context, req *resource.ListRequest, cb
|
||||
listReq.StartRV = continueToken.ResourceVersion
|
||||
}
|
||||
|
||||
// Set ExactRV when using Exact matching
|
||||
if req.VersionMatch == resource.ResourceVersionMatch_Exact {
|
||||
if req.ResourceVersion <= 0 {
|
||||
return 0, fmt.Errorf("expecting an explicit resource version query when using Exact matching")
|
||||
}
|
||||
listReq.ExactRV = req.ResourceVersion
|
||||
}
|
||||
|
||||
// Set MinRV when using NotOlderThan matching to filter at the database level
|
||||
if req.ResourceVersion > 0 && req.VersionMatch == resource.ResourceVersionMatch_NotOlderThan {
|
||||
listReq.MinRV = req.ResourceVersion
|
||||
}
|
||||
|
||||
err := b.db.WithTx(ctx, ReadCommittedRO, func(ctx context.Context, tx db.Tx) error {
|
||||
var err error
|
||||
iter.listRV, err = fetchLatestRV(ctx, tx, b.dialect, req.Options.Key.Group, req.Options.Key.Resource)
|
||||
|
Reference in New Issue
Block a user