refactor concurrent consume

This commit is contained in:
finley
2024-09-27 21:37:48 +08:00
parent 0812e5ac21
commit a752279fa9
4 changed files with 192 additions and 93 deletions

View File

@@ -35,11 +35,15 @@ func TestPublisher(t *testing.T) {
}
}
for i := 0; i < 10*size; i++ {
err := queue.consume()
ids, err := queue.beforeConsume()
if err != nil {
t.Errorf("consume error: %v", err)
return
}
for _, id := range ids {
queue.callback(id)
}
queue.afterConsume()
}
for k, v := range deliveryCount {
i, _ := strconv.ParseInt(k, 10, 64)
@@ -53,4 +57,4 @@ func TestPublisher(t *testing.T) {
}
}
}
}
}