Skip to content

Commit

Permalink
feat: add RequestContext to PubSubConn (TBD)
Browse files Browse the repository at this point in the history
Add a wrapper that goes through the standard receiveInternal
processing to match the API of the existing PubSubConn Receive
methods.

Fixes: #592
  • Loading branch information
pabigot committed Mar 17, 2022
1 parent 8eb5625 commit bf087ba
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions redis/pubsub.go
Expand Up @@ -15,6 +15,7 @@
package redis

import (
"context"
"errors"
"time"
)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bf087ba

Please sign in to comment.