You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are plans to simplify the API by removing the Factory and instead replacing it with a simpler MysqlClient constructor. In other words, this:
$factory = newReact\MySQL\Factory();
$db = $factory->createLazyConnection('alice:secret@localhost/bookstore');
$db->query('INSERT INTO book (title) VALUES (?)', ['Hello wörld!']);
Could potentially look like this:
$db = newReact\Mysql\MysqlClient('alice:secret@localhost/bookstore');
$db->query('INSERT INTO book (title) VALUES (?)', ['Hello wörld!']);
Internally, the MysqlClient would work similar to what is currently called a "lazy" connection, but we'll probably get rid of this wording altogether. This means it would automatically create the underlying database connection only when it's actually needed and will close this connection after a short while when it is not in use anymore. What is currently called "idle" time would probably be reworded to be more of a "keepalive" with much lower defaults.
Additionally, we'll probably fire "open" and "close" events as needed (loosely inspired by https://github.com/clue/reactphp-eventsource). Unlike the current version, my idea is to also keep the instance in a usable state even after calling close() on it. Reusing the same instance at a later time makes a lot more sense in long-running applications instead of locking it in an unusable state.
This is obviously a BC break, but there are no plans to break any of the existing code besides this. Most consumers should be able to upgrade to the new instantiation without issues, actual query APIs etc. would not be affected.
Obviously the biggest hindrance: I'm not entirely sure about the casing of the namespace and class name (MySQL vs. Mysql).
There are plans to simplify the API by removing the
Factory
and instead replacing it with a simplerMysqlClient
constructor. In other words, this:Could potentially look like this:
Internally, the
MysqlClient
would work similar to what is currently called a "lazy" connection, but we'll probably get rid of this wording altogether. This means it would automatically create the underlying database connection only when it's actually needed and will close this connection after a short while when it is not in use anymore. What is currently called "idle" time would probably be reworded to be more of a "keepalive" with much lower defaults.Additionally, we'll probably fire "open" and "close" events as needed (loosely inspired by https://github.com/clue/reactphp-eventsource). Unlike the current version, my idea is to also keep the instance in a usable state even after calling
close()
on it. Reusing the same instance at a later time makes a lot more sense in long-running applications instead of locking it in an unusable state.This is obviously a BC break, but there are no plans to break any of the existing code besides this. Most consumers should be able to upgrade to the new instantiation without issues, actual query APIs etc. would not be affected.
Obviously the biggest hindrance: I'm not entirely sure about the casing of the namespace and class name (MySQL vs. Mysql).
The same API discussion also applies to SQLite (clue/reactphp-sqlite#47) and others
Builds on top of #134
The text was updated successfully, but these errors were encountered: