fix #1758
This commit is contained in:
monkey92t 2021-05-19 16:52:13 +08:00 committed by GitHub
parent 76393b5b71
commit 1393126c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -1769,8 +1769,14 @@ func xStreamInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
info.LastGeneratedID, err = rd.ReadString()
case "first-entry":
info.FirstEntry, err = readXMessage(rd)
if err == Nil {
err = nil
}
case "last-entry":
info.LastEntry, err = readXMessage(rd)
if err == Nil {
err = nil
}
default:
return nil, fmt.Errorf("redis: unexpected content %s "+
"in XINFO STREAM reply", key)
@ -2034,7 +2040,7 @@ func readXInfoStreamConsumers(rd *proto.Reader) ([]XInfoStreamConsumer, error) {
c.Pending = make([]XInfoStreamConsumerPending, 0, pendingNumber)
for f := 0; f < pendingNumber; f++ {
for pn := 0; pn < pendingNumber; pn++ {
nn, err := rd.ReadArrayLen()
if err != nil {
return nil, err

View File

@ -4390,6 +4390,26 @@ var _ = Describe("Commands", func() {
FirstEntry: redis.XMessage{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
LastEntry: redis.XMessage{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
}))
// stream is empty
n, err := client.XDel(ctx, "stream", "1-0", "2-0", "3-0").Result()
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(3)))
res, err = client.XInfoStream(ctx, "stream").Result()
Expect(err).NotTo(HaveOccurred())
res.RadixTreeKeys = 0
res.RadixTreeNodes = 0
Expect(res).To(Equal(&redis.XInfoStream{
Length: 0,
RadixTreeKeys: 0,
RadixTreeNodes: 0,
Groups: 2,
LastGeneratedID: "3-0",
FirstEntry: redis.XMessage{},
LastEntry: redis.XMessage{},
}))
})
It("should XINFO STREAM FULL", func() {