Resumable handles watch with revision zero

Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
Marek Siarkowicz 2024-04-15 20:23:45 +02:00
parent 0cd5999b78
commit 94a47a7cbd
2 changed files with 4 additions and 4 deletions

View File

@ -821,8 +821,6 @@ func TestValidateWatch(t *testing.T) {
putPersistedEvent("b", "2", 3, true),
putPersistedEvent("c", "3", 4, true),
},
// TODO: Should pass as watch with revision 0 might start from any revision.
expectError: errBrokeResumable.Error(),
},
{
name: "Reliable - missing last event - pass",

View File

@ -176,9 +176,11 @@ func validateReliable(lg *zap.Logger, events []model.PersistedEvent, report repo
func validateResumable(lg *zap.Logger, events []model.PersistedEvent, report report.ClientReport) (err error) {
for _, op := range report.Watch {
if op.Request.Revision == 0 {
continue
}
index := 0
revision := op.Request.Revision
for index < len(events) && (events[index].Revision < revision || !events[index].Match(op.Request)) {
for index < len(events) && (events[index].Revision < op.Request.Revision || !events[index].Match(op.Request)) {
index++
}
if index == len(events) {