Manually getting connection from pool: why? #261
Replies: 1 comment 1 reply
-
There are several reasons of this design: Now I don't know your code base but assuming that it is the "usual" web server setup you can consider to just have a custom extractor via your web server framework and just pull out the connection from the pool via by having it as function argument. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I initially used SeaORM but can't live with it's quirks. I now discovered diesel (async) and its amzing!
One thing I noticed that when using a connection pool (we use bb8), it's up to the developer to check out a connection from the pool.
Why is this? In my code, I find myself getting a connection, running a query and releasing it again, over and over again.
In seaorm, I would give a ref to my connection pool, and Seaorm would take the connection for me. This also means I dont have to worry about holding a lock on a connection for longer than needed.
Was this designed like so on purpose?
Beta Was this translation helpful? Give feedback.
All reactions