Skip to content

Commit

Permalink
Added the support for WAITAOF which is a new command in redis ver7.2.0 (
Browse files Browse the repository at this point in the history
#2629)

* implemented WaitAOF command for the redis ver7.2.0

* updated the test corresponding to WaitAOF

---------

Co-authored-by: Chayim <chayim@users.noreply.github.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 7acc0cd commit 0637c53
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,13 @@ func (c cmdable) Wait(ctx context.Context, numSlaves int, timeout time.Duration)
return cmd
}

func (c cmdable) WaitAOF(ctx context.Context, numLocal, numSlaves int, timeout time.Duration) *IntCmd {
cmd := NewIntCmd(ctx, "waitAOF", numLocal, numSlaves, int(timeout/time.Millisecond))
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}

func (c statefulCmdable) Select(ctx context.Context, index int) *StatusCmd {
cmd := NewStatusCmd(ctx, "select", index)
_ = c(ctx, cmd)
Expand Down
12 changes: 12 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ var _ = Describe("Commands", func() {
Expect(time.Now()).To(BeTemporally("~", start.Add(wait), 3*time.Second))
})

It("should WaitAOF", func() {
const waitAOF = 3 * time.Second
Skip("flaky test")

// assuming that the redis instance doesn't have AOF enabled
start := time.Now()
val, err := client.WaitAOF(ctx, 1, 1, waitAOF).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).NotTo(ContainSubstring("ERR WAITAOF cannot be used when numlocal is set but appendonly is disabled"))
Expect(time.Now()).To(BeTemporally("~", start.Add(waitAOF), 3*time.Second))
})

It("should Select", func() {
pipe := client.Pipeline()
sel := pipe.Select(ctx, 1)
Expand Down

0 comments on commit 0637c53

Please sign in to comment.