php-runtime / runtime

A home for runtimes.
MIT License
404 stars 32 forks source link

Question: How do I create pools? #133

Closed vrgenl closed 1 month ago

vrgenl commented 1 year ago

So I have php-runtime working with swoole and symfony. Works like a charm! The only thing I cant seem to work out is to create pools for lets say SQL or Redis.

Previously I had created a command that runs a HttpServer and also spun up some workers for pools etc to keep connections open.

Can't seem to find any answers here in the issue history or anywhere else for that matter.

Kind regards, Rogier

pistej commented 1 year ago

you can use, inspire by this lib: https://github.com/open-smf/connection-pool or if you want smth mature with sf app u can try https://github.com/pixelfederation/swoole-bundle and use worker events ... with lib above

praswicaksono commented 10 months ago

for doctrine you can use custom driver that already support connection pooling, then replace default dbal driver in symfony. Here is following dbal driver that already support connection pooling

and lastly you need to patch doctrine orm EntityManager to support long running process like this one https://github.com/opsway/doctrine-orm-swoole

for other connection pooling you can implement by hand using this https://github.com/swoole/library/blob/master/src/core/ConnectionPool.php