-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add PubSubConn.ReceiveContext() #592
Comments
I'm sorry I don't understand what you're trying to say, do you have some code which demonstrates the issue you have? |
func run(ctx context.Context){
psc := &redis.PubSubConn{Conn: conn}
err := psc.Subscribe(topicStr)
for {
r: = psc.ReceiveContext(ctx) // add this
err, ok := r.(error)
_ = ok
if errors.Is(v, context.DeadlineExceeded) || errors.Is(v, context.Canceled) {
break; // break loop
}
msg, ok := r.(redis.Message)
// ....
// if not have the psc.ReceiveContext(ctx), and i try "v, err := redis.ReceiveContext(psc.Conn, ctx)"
// the v was can not convert redis.Message, because not decode by Subscription.receiveInternal
// so , please add PubSubConn.ReceiveContext
}
}
func main(){
ctx,cancel := context.WithCancel(context.TODO())
go run(ctx)
time.Sleep(time.Second*10)
cancel()
time.Sleep(time.Second*10)
} for {
v := psc.ReceiveWithTimeout(time.Second)
fmt.Println(v)
// first print: os.ErrDeadlineExceeded, and this connection was closed!!!!
// second print: net.ErrClosed , can not receive any redis message!!!
}
|
To confirm my understanding you're looking for a new feature You're also saying that |
These are two questions..... second question it was an unexpected discovery |
So to confirm you should be able to use If you're seeing an unexpected result, please provide a working example and the error you are seeing. |
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
I was just looking for this. @stevenh The reason we need a new method is shown by the following:
The output from this given three successive publications is:
The enhancement is trivial, and is in #603. |
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: gomodule#592
Add a wrapper that goes through the standard receiveInternal processing to match the API of the existing PubSubConn Receive methods. Fixes: #592
add "PubSubConn.ReceiveContext" support watch the <-context.Done() .
because "redis.ReceiveContext" is return native redis response. was not call "Subscription.receiveInternal" decode this response.
and, "ReceiveWithTimeout" is return net.ErrClosed, can not loop call receive
The text was updated successfully, but these errors were encountered: