mirror of https://github.com/go-redis/redis.git
fix the reading of the "entries-read" field in XInfoStreamFull (#2595)
* fix: In the response of the XInfoStreamFull command, the "entries-read" field may be nil Signed-off-by: monkey92t <golang@88.com> * add XInfoStreamFull test Signed-off-by: monkey92t <golang@88.com> * add test XInfoStreamFull entries_read = nil Signed-off-by: monkey92t <golang@88.com> --------- Signed-off-by: monkey92t <golang@88.com>
This commit is contained in:
parent
9a9423d3df
commit
6f0af685cf
|
@ -2373,7 +2373,7 @@ func readStreamGroups(rd *proto.Reader) ([]XInfoStreamGroup, error) {
|
|||
}
|
||||
case "entries-read":
|
||||
group.EntriesRead, err = rd.ReadInt()
|
||||
if err != nil {
|
||||
if err != nil && err != Nil {
|
||||
return nil, err
|
||||
}
|
||||
case "lag":
|
||||
|
|
|
@ -5912,6 +5912,97 @@ var _ = Describe("Commands", func() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Expect(res.Groups).To(Equal([]redis.XInfoStreamGroup{
|
||||
{
|
||||
Name: "group1",
|
||||
LastDeliveredID: "3-0",
|
||||
EntriesRead: 3,
|
||||
Lag: 0,
|
||||
PelCount: 3,
|
||||
Pending: []redis.XInfoStreamGroupPending{
|
||||
{ID: "1-0", Consumer: "consumer1", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
{ID: "2-0", Consumer: "consumer1", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
},
|
||||
Consumers: []redis.XInfoStreamConsumer{
|
||||
{
|
||||
Name: "consumer1",
|
||||
SeenTime: time.Time{},
|
||||
ActiveTime: time.Time{},
|
||||
PelCount: 2,
|
||||
Pending: []redis.XInfoStreamConsumerPending{
|
||||
{ID: "1-0", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
{ID: "2-0", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "consumer2",
|
||||
SeenTime: time.Time{},
|
||||
ActiveTime: time.Time{},
|
||||
PelCount: 1,
|
||||
Pending: []redis.XInfoStreamConsumerPending{
|
||||
{ID: "3-0", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "group2",
|
||||
LastDeliveredID: "3-0",
|
||||
EntriesRead: 3,
|
||||
Lag: 0,
|
||||
PelCount: 2,
|
||||
Pending: []redis.XInfoStreamGroupPending{
|
||||
{ID: "2-0", Consumer: "consumer1", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
{ID: "3-0", Consumer: "consumer1", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
},
|
||||
Consumers: []redis.XInfoStreamConsumer{
|
||||
{
|
||||
Name: "consumer1",
|
||||
SeenTime: time.Time{},
|
||||
ActiveTime: time.Time{},
|
||||
PelCount: 2,
|
||||
Pending: []redis.XInfoStreamConsumerPending{
|
||||
{ID: "2-0", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
{ID: "3-0", DeliveryTime: time.Time{}, DeliveryCount: 1},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
// entries-read = nil
|
||||
Expect(client.Del(ctx, "xinfo-stream-full-stream").Err()).NotTo(HaveOccurred())
|
||||
id, err := client.XAdd(ctx, &redis.XAddArgs{
|
||||
Stream: "xinfo-stream-full-stream",
|
||||
ID: "*",
|
||||
Values: []any{"k1", "v1"},
|
||||
}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(client.XGroupCreateMkStream(ctx, "xinfo-stream-full-stream", "xinfo-stream-full-group", "0").Err()).NotTo(HaveOccurred())
|
||||
res, err = client.XInfoStreamFull(ctx, "xinfo-stream-full-stream", 0).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res).To(Equal(&redis.XInfoStreamFull{
|
||||
Length: 1,
|
||||
RadixTreeKeys: 1,
|
||||
RadixTreeNodes: 2,
|
||||
LastGeneratedID: id,
|
||||
MaxDeletedEntryID: "0-0",
|
||||
EntriesAdded: 1,
|
||||
Entries: []redis.XMessage{{ID: id, Values: map[string]any{"k1": "v1"}}},
|
||||
Groups: []redis.XInfoStreamGroup{
|
||||
{
|
||||
Name: "xinfo-stream-full-group",
|
||||
LastDeliveredID: "0-0",
|
||||
EntriesRead: 0,
|
||||
Lag: 1,
|
||||
PelCount: 0,
|
||||
Pending: []redis.XInfoStreamGroupPending{},
|
||||
Consumers: []redis.XInfoStreamConsumer{},
|
||||
},
|
||||
},
|
||||
RecordedFirstEntryID: id,
|
||||
}))
|
||||
})
|
||||
|
||||
It("should XINFO GROUPS", func() {
|
||||
|
|
Loading…
Reference in New Issue