What happen when a pool is cloned? #917
-
Hi, Is a new pool created (and thus doubling the number of max open connections)? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Refer to: sqlx/sqlx-core/src/pool/mod.rs Line 217 in 3aeb46f The actual connection pool is a private In effect, all that It's fully intended to be cloned all over the place and given to different threads, etc. |
Beta Was this translation helpful? Give feedback.
-
For the record, this is documented on the It's not immediately obvious from the docs though since documentation on trait impls is collapsed by default. |
Beta Was this translation helpful? Give feedback.
-
Awesome thank you! May I submit a little PR this afternoon to add a line in the docs to describe this behavior? |
Beta Was this translation helpful? Give feedback.
Refer to:
sqlx/sqlx-core/src/pool/mod.rs
Line 217 in 3aeb46f
The actual connection pool is a private
SharedPool
type. The publicPool
type wraps that type in anArc
.In effect, all that
pool.clone()
does is clone the reference, thus giving you more places you can reference the pool from.It's fully intended to be cloned all over the place and given to different threads, etc.