Skip to content

Commit

Permalink
Added missing idle args in XPendingExtArgs (#1750)
Browse files Browse the repository at this point in the history
Added missing idle args in XPendingExtArgs
  • Loading branch information
parvez0 authored May 13, 2021
1 parent 44f5c06 commit 31495ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1811,15 +1811,20 @@ func (c cmdable) XPending(ctx context.Context, stream, group string) *XPendingCm
type XPendingExtArgs struct {
Stream string
Group string
Idle time.Duration
Start string
End string
Count int64
Consumer string
}

func (c cmdable) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd {
args := make([]interface{}, 0, 7)
args = append(args, "xpending", a.Stream, a.Group, a.Start, a.End, a.Count)
args := make([]interface{}, 0, 9)
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 != "" {
args = append(args, a.Consumer)
}
Expand Down
11 changes: 8 additions & 3 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4225,15 +4225,15 @@ var _ = Describe("Commands", func() {
Higher: "3-0",
Consumers: map[string]int64{"consumer": 3},
}))

infoExt, err := client.XPendingExt(ctx, &redis.XPendingExtArgs{
args := &redis.XPendingExtArgs{
Stream: "stream",
Group: "group",
Start: "-",
End: "+",
Count: 10,
Consumer: "consumer",
}).Result()
}
infoExt, err := client.XPendingExt(ctx, args).Result()
Expect(err).NotTo(HaveOccurred())
for i := range infoExt {
infoExt[i].Idle = 0
Expand All @@ -4244,6 +4244,11 @@ var _ = Describe("Commands", func() {
{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()
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(3)))
Expand Down

0 comments on commit 31495ac

Please sign in to comment.