-
Notifications
You must be signed in to change notification settings - Fork 322
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
Basic support for ConnectionPool and persistent connections #351
base: master
Are you sure you want to change the base?
Conversation
...When comparing Her to ActiveRecord it's the one of the important features Her lacks. And since creating connections is done by Her itself there is no other way to setup a pooling than add its support to Her. connection_pool gem with its simple |
You can read more about all this stuff in the updated README |
8fa2f81
to
5288afd
Compare
@hubert I don't think so. Using a connection pool is optional so installing a connection_pool gem is also optional. Her should not require it to work — marshall-lee@5288afd#diff-6b1740b8978bf165426acae9d1c17138R1 |
|
I made it a development dependency only for running connection pool-related specs. |
Maybe it is worth to add a connection_pool as a dependency and use it every time. Even if there's only one connection, having a pool will automatically solve thread safety issues. However it can confuse existing Her users that have long running queries — they can get a |
382d9a4
to
a43dad0
Compare
bump! /cc @hubert |
@marshall-lee thanks as always for your contributions. this was actually on my list of things to enhance for her, so really glad that you are taking this one. have a few questions/comments.
|
da39257
to
e498097
Compare
done!
It doesn't require a
done! |
e498097
to
5174310
Compare
cc @hubert |
+1 |
Thanks for the nudge! This looks really interesting.
A few questions (I don't know the answers!):
- Should we go one step further and use something with swappable backends like httparty?
- with a connection pool the requests are usually blocking, so you can run out of connections. Obviously, disregarding the negative side effects of resending the same tcp packets in Net::HTTP, that wouldn't happen in the current implementation. Does that mean that this could break an existing implementation if someone naively added a connection pool which is too small?
…
|
@edtjones Hi Ed! Sorry for late response.
Only if someone really-really needs it and wants to contribute :) But for me it would be ridiculous because Faraday itself is a solution for swappable backends. BTW supporting HTTParty doesn't make any sense because it's just a convenient wrapper around Nevertheless, making our own swappable backends solution won't become harder after adding a connection pool, it's implementation-agnostic.
Yes. Rule of thumb is to make a pool size equal to threads count. |
This PR adds a connection pool options and also tells in README about a benefit of persistent connections. Not informing users about
Net::HTTP
weakness is just harmful, I think :)