[WIP] Add LazyConnectionPool#148
[WIP] Add LazyConnectionPool#148skydiablo wants to merge 4 commits intofriends-of-reactphp:0.7.xfrom
Conversation
clue
left a comment
There was a problem hiding this comment.
@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.