-
Notifications
You must be signed in to change notification settings - Fork 66
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
[WIP] Add LazyConnectionPool #148
base: 0.7.x
Are you sure you want to change the base?
Conversation
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.
@skydiablo Thank you for looking into this, like the direction this is taking!
I've also started looking into this a while back and came up with a somewhat similar structure (https://twitter.com/another_clue/status/1419633478216388612), but never quite finished this into a full PR. Implementing this as a decorator around the existing (lazy) connection makes a lot of sense and probably covers 80% of the use cases just fine! It also looks like #147 could be good starting point to simplify the API somewhat in the future.
However, it's easy to come up with use cases that break this abstraction, in particular when using transactions that probably shouldn't span multiple independent connections.
I wonder if we can use this as a base to build a proper test suite to cover most common use cases and work out an API that also takes care of the more nuanced subtleties when it comes to connection reuse for stateful properties such as the transaction state.
In either case, I'm curious what this is going to evolve into, so keep it up! 👍
yes, the transaction handling will be a new challenge. maybe this lib can give an opportunity for this feature? my basic think, i can borrow an connection and if i will be finished (transaction done), i can get back the connection to the pool? |
@skydiablo Sounds good to me, see also https://github.com/mysqljs/mysql#pooling-connections. Let's also ping @szado and see if we can integrate some similar logic into this repository 👍 |
this allow to fire up multiple querys at a time so that long-running query will not block you unique database connection point.