Skip to content

Commit 0637c53

Browse files
NikanVchayimofekshenawa
authored
Added the support for WAITAOF which is a new command in redis ver7.2.0 (#2629)
* implemented WaitAOF command for the redis ver7.2.0 * updated the test corresponding to WaitAOF --------- Co-authored-by: Chayim <[email protected]> Co-authored-by: ofekshenawa <[email protected]>
1 parent 7acc0cd commit 0637c53

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: commands.go

+7
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,13 @@ func (c cmdable) Wait(ctx context.Context, numSlaves int, timeout time.Duration)
558558
return cmd
559559
}
560560

561+
func (c cmdable) WaitAOF(ctx context.Context, numLocal, numSlaves int, timeout time.Duration) *IntCmd {
562+
cmd := NewIntCmd(ctx, "waitAOF", numLocal, numSlaves, int(timeout/time.Millisecond))
563+
cmd.setReadTimeout(timeout)
564+
_ = c(ctx, cmd)
565+
return cmd
566+
}
567+
561568
func (c statefulCmdable) Select(ctx context.Context, index int) *StatusCmd {
562569
cmd := NewStatusCmd(ctx, "select", index)
563570
_ = c(ctx, cmd)

Diff for: commands_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ var _ = Describe("Commands", func() {
9595
Expect(time.Now()).To(BeTemporally("~", start.Add(wait), 3*time.Second))
9696
})
9797

98+
It("should WaitAOF", func() {
99+
const waitAOF = 3 * time.Second
100+
Skip("flaky test")
101+
102+
// assuming that the redis instance doesn't have AOF enabled
103+
start := time.Now()
104+
val, err := client.WaitAOF(ctx, 1, 1, waitAOF).Result()
105+
Expect(err).NotTo(HaveOccurred())
106+
Expect(val).NotTo(ContainSubstring("ERR WAITAOF cannot be used when numlocal is set but appendonly is disabled"))
107+
Expect(time.Now()).To(BeTemporally("~", start.Add(waitAOF), 3*time.Second))
108+
})
109+
98110
It("should Select", func() {
99111
pipe := client.Pipeline()
100112
sel := pipe.Select(ctx, 1)

0 commit comments

Comments
 (0)