diff --git a/redis/pubsub.go b/redis/pubsub.go index cc585757..f2f721af 100644 --- a/redis/pubsub.go +++ b/redis/pubsub.go @@ -15,6 +15,7 @@ package redis import ( + "context" "errors" "time" ) @@ -116,6 +117,12 @@ func (c PubSubConn) ReceiveWithTimeout(timeout time.Duration) interface{} { return c.receiveInternal(ReceiveWithTimeout(c.Conn, timeout)) } +// ReceiveContext is like Receive, but it allows termination of the receive +// via a Context. +func (c PubSubConn) ReceiveContext(ctx context.Context) interface{} { + return c.receiveInternal(ReceiveContext(c.Conn, ctx)) +} + func (c PubSubConn) receiveInternal(replyArg interface{}, errArg error) interface{} { reply, err := Values(replyArg, errArg) if err != nil {