From 6b8c6b3fe9eb1cb80e9ef6d414e6fe5d44314857 Mon Sep 17 00:00:00 2001 From: Nate Bosscher Date: Thu, 16 Feb 2017 11:15:34 -0500 Subject: [PATCH] Added implementation for WAIT command Reference: https://redis.io/commands/wait --- commands.go | 7 +++++++ commands_test.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/commands.go b/commands.go index 8ea5def..bc93df9 100644 --- a/commands.go +++ b/commands.go @@ -273,6 +273,13 @@ func (c *cmdable) Ping() *StatusCmd { return cmd } +func (c *cmdable) Wait(numSlaves int, timeout time.Duration) *IntCmd { + + cmd := NewIntCmd("wait", numSlaves, int(timeout/time.Second)) + c.process(cmd) + return cmd +} + func (c *cmdable) Quit() *StatusCmd { panic("not implemented") } diff --git a/commands_test.go b/commands_test.go index ecfc012..66359d2 100644 --- a/commands_test.go +++ b/commands_test.go @@ -50,6 +50,13 @@ var _ = Describe("Commands", func() { Expect(ping.Val()).To(Equal("PONG")) }) + It("should Wait", func() { + // assume testing on single redis instance + wait := client.Wait(0, time.Minute) + Expect(wait.Err()).NotTo(HaveOccurred()) + Expect(wait.Val()).To(Equal(int64(0))) + }) + It("should Select", func() { pipe := client.Pipeline() sel := pipe.Select(1)