-
-
Notifications
You must be signed in to change notification settings - Fork 35
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 support for redigo's Pool.GetContext (to support waiting with timeout when pool is full) #22
Comments
Hello, This package only deals with redis cluster, all of the standard redis features (including connections) are handled by the Thanks, |
Hello, I send it here instead of to
But of course it is your call :) |
It doesn't modify |
Ah, i really didn't aware about it
It seems you are open to this, right? Then i'll be more than happy to work on it. |
Definitely, thanks for looking into this. Just make sure the |
Hi @mna
I tried to add The reason is that we have to keep the passed I propose to do this:
call
Unfortunately, my proposal couldn't satisfy this requirement. |
Hey, thanks for the update! Yeah I understand that it's not obvious to change a codebase you're not familiar with. Your proposal makes sense, but that's only one of the benefits of using I'll try to take a closer look later this week. If it fails then your proposal is definitely a plan B to consider! |
@iwanbk I started work on GetContext support in the I will also have to document the very narrow use of the context that redigo makes, it is really only used when waiting for an active connection to be available (i.e. it cannot stop a dial in progress, as I'm not 100% convinced this makes much sense to support because of this (such a narrow use-case). But anyway, the initial support is there, let me know how it works for you and I'll keep thinking about it. |
Yes, true
Yes, agree From above statement, did you also imply that Line 245 in d3c4b20
RetryConn ?
I 100% agree with your concern and i feel the same
i'll do the same |
No, it is called whenever a (pooled) connection needs to be established, but in |
I think your proposal may make more sense than adding |
sure, will do. |
I created the initial implementation at https://github.com/mna/redisc/compare/master...iwanbk:add-get-timeout?expand=1 Is it OK for me to add dependency to miniredis for the test. |
I'd rather not, the existing testing helpers should already allow testing this, you can get inspiration from how they tested it in redigo, only thing is I don't think they covered the case where the wait allows getting a conn (i.e. an active conn got closed during the wait time), we should cover that. Thanks for tackling this, much appreciated! |
Also, one small thing, you should use |
OK, i wrote some initial code using
sure
oh my bad |
Hey, thanks, I just took a quick look, your changes look great! Only thing is the test file should have the build go1.7 tag on it too, otherwise it would fail on go < 1.7. Feel free to open a PR whenever you're ready to get this merged! |
Default behaviour of redigo Pool is to simply returns invalid connection
when the pool is full/exhausted (no available connection).
The problem is described in more details at gomodule/redigo#56
We could add a kind of blocking with timeout when getting connection from redigo pool.
So, instead of simply returns invalid connection, we could wait first for a configurable amount of time.
It could be implemented using sempahore (from https://godoc.org/golang.org/x/sync/semaphore).
I have some implementation at tokopedia@2fa113e.
If you have interest, i could create a proper PR with proper tests
The text was updated successfully, but these errors were encountered: