Repository: redis/go-redis

Issue:
Add support for new redis command WAITAOF
7.2.0 adds support for the new redis command WAITAOF. We need to add support, documented [here](https://redis.io/commands/WAITAOF).

Hints from issue comments:
@NikanV: Hi, i would be happy to help you with this task and just made a pull request for it

Solution patch:
diff --git a/commands.go b/commands.go
index dbbad08..2537c0a 100644
--- a/commands.go
+++ b/commands.go
@@ -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)



Test patch:
diff --git a/commands_test.go b/commands_test.go
index 812d682..8e00c83 100644
--- a/commands_test.go
+++ b/commands_test.go
@@ -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)