Added missing idle args in XPendingExtArgs (#1750)

Added missing idle args in XPendingExtArgs
This commit is contained in:
Parvez 2021-05-13 20:45:37 +05:30 committed by GitHub
parent 44f5c06755
commit 31495ac570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -1811,6 +1811,7 @@ func (c cmdable) XPending(ctx context.Context, stream, group string) *XPendingCm
type XPendingExtArgs struct { type XPendingExtArgs struct {
Stream string Stream string
Group string Group string
Idle time.Duration
Start string Start string
End string End string
Count int64 Count int64
@ -1818,8 +1819,12 @@ type XPendingExtArgs struct {
} }
func (c cmdable) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd { func (c cmdable) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd {
args := make([]interface{}, 0, 7) args := make([]interface{}, 0, 9)
args = append(args, "xpending", a.Stream, a.Group, a.Start, a.End, a.Count) args = append(args, "xpending", a.Stream, a.Group)
if a.Idle != 0 {
args = append(args, "idle", formatMs(ctx, a.Idle))
}
args = append(args, a.Start, a.End, a.Count)
if a.Consumer != "" { if a.Consumer != "" {
args = append(args, a.Consumer) args = append(args, a.Consumer)
} }

View File

@ -4225,15 +4225,15 @@ var _ = Describe("Commands", func() {
Higher: "3-0", Higher: "3-0",
Consumers: map[string]int64{"consumer": 3}, Consumers: map[string]int64{"consumer": 3},
})) }))
args := &redis.XPendingExtArgs{
infoExt, err := client.XPendingExt(ctx, &redis.XPendingExtArgs{
Stream: "stream", Stream: "stream",
Group: "group", Group: "group",
Start: "-", Start: "-",
End: "+", End: "+",
Count: 10, Count: 10,
Consumer: "consumer", Consumer: "consumer",
}).Result() }
infoExt, err := client.XPendingExt(ctx, args).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
for i := range infoExt { for i := range infoExt {
infoExt[i].Idle = 0 infoExt[i].Idle = 0
@ -4244,6 +4244,11 @@ var _ = Describe("Commands", func() {
{ID: "3-0", Consumer: "consumer", Idle: 0, RetryCount: 1}, {ID: "3-0", Consumer: "consumer", Idle: 0, RetryCount: 1},
})) }))
args.Idle = 72 * time.Hour
infoExt, err = client.XPendingExt(ctx, args).Result()
Expect(err).NotTo(HaveOccurred())
Expect(infoExt).To(HaveLen(0))
n, err := client.XGroupDelConsumer(ctx, "stream", "group", "consumer").Result() n, err := client.XGroupDelConsumer(ctx, "stream", "group", "consumer").Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(3))) Expect(n).To(Equal(int64(3)))