add DoContext and ReceiveContext,use context to control the life#537
add DoContext and ReceiveContext,use context to control the life#537stevenh merged 12 commits intogomodule:masterfrom chenjie199234:master
Conversation
|
Why not just use |
|
@stevenh pool.GetContext(ctx) only get a connection.The ctx will not effect the Do function. 1.when a connection create,the connection has 2 timeout,readtimeout and writetimeout,they are setted by DialReadTimeout and DialWriteTimeout The comment above the GetContext also said this. |
|
@stevenh can this be merged?The opensource's working efficiency is really a nightmare. 0_0!!! |
|
@stevenh |
stevenh
left a comment
There was a problem hiding this comment.
No need to force push as it makes it hard to see the changes I will squash the commits to one on merge anyway.
Here's some more feedback on top of the previous pieces.
|
Any progress on this? It's indeed important :( |
|
My thoughts Why are we redefining a brand new context cancelation error type: Can't we use the one from standard library: https://godoc.org/context#pkg-variables Lots of people like to check the returned error and compare it to the standard library to distinguish between whether the context was cancelled or whether a deadline exceeded.
All that is needed is this added to a
There should be no need for adding timeout/deadline facilities to make it "appear" more convenient for developers. Alternatively, |
|
I think maintainer wants to go in this direction: #351 |
|
Ah, I think I should consider using github.com/go-redis/redis instead :) |
stevenh
left a comment
There was a problem hiding this comment.
My thoughts
Why are we redefining a brand new context cancelation error type:
var ErrContextCanceled = errors.New("redis: context canceled")Can't we use the one from standard library: https://godoc.org/context#pkg-variables
Lots of people like to check the returned error and compare it to the standard library to distinguish between whether the context was cancelled or whether a deadline exceeded.
Good call, we should definitely do that.
- This PR increases the API surface substantially (and in my opinion excessively).
All that is needed is this added to a
v2Conninterface:
func DoContext(ctx context.Context, commandName string, args ...interface{}) (reply interface{}, err error) {There should be no need for adding timeout/deadline facilities to make it "appear" more convenient for developers.
Developers can easily do it themselves via the context package.Alternatively,
Conn2interface can be defined which embedsConninterface.
Not sure I follow you there, could you clarify?
Is there something that is missing that is driving that comment? |
fix typo Co-authored-by: Mikhail Mazurskiy <126021+ash2k@users.noreply.github.com>
fix typo Co-authored-by: Mikhail Mazurskiy <126021+ash2k@users.noreply.github.com>
|
Any updates on this? We would really like to use this library in our Thola project, but Context support is critical for us. |
|
@TheFireMike this is now merged, sorry I'm not been getting some github emails, so didn't realise this was now complete. Thanks to everyone for their contributions to this PR. |
|
may i ask, why i cant find DoContext in the current realease (v1.8.5)? |
|
this is awesome, thank you very much |
context is mostly used when develop a project
I think the with timeout function can also change to this rule
don't override the readtime
can this be merged and make a new tag?my project need this
by the way,can we fix the tag version number?