-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add DoContext and ReceiveContext,use context to control the life #537
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!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things to address not mentioned in the inline comments:
- How does this deal cancelled context on connections? See Add DoWithCancel #351 for some interesting points, it's not as easy as it first appears.
- Needs tests
@stevenh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
v2
Conn
interface:
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,
Conn2
interface can be defined which embedsConn
interface.
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 <[email protected]>
fix typo Co-authored-by: Mikhail Mazurskiy <[email protected]>
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?