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
{{ message }}
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
This isn't an issue per se, more of a request. I'm working on an api using mongo and this library and as of now, I've a connection instantiated when the server starts. Every time a request comes in (as of now all requests communicate w/ mongo), the connection is cloned. Is this the correct way to do this? Should I be using a mongodb::pool::ConnectionPool instead? If so, I'm not sure how to query using a PooledStream.
Thanks!
The text was updated successfully, but these errors were encountered:
Hey, I didn't see this issue until now! The connection pool is maintained internally by a MongoDB Client, so you shouldn't ever have to deal with the pool directly. MongoDB apps are designed to have one Client across the entire application, so developers can clone Client (which is actually an alias of an Arc type), allowing them to use multiple references of the same connection pool.
... Client is actually just an alias of an Arc type, which means you can open the connection at the top of the function and then just use .clone() to get an (owned) atomic reference to it inside each of your routes that need it.
It sounds like you are doing this in your application, which is great! If you're using cloned references to a single Client, the internal connection pool will automatically handle connection recycling for you and create new connections under heavy load.
This isn't an issue per se, more of a request. I'm working on an api using mongo and this library and as of now, I've a connection instantiated when the server starts. Every time a request comes in (as of now all requests communicate w/ mongo), the connection is cloned. Is this the correct way to do this? Should I be using a
mongodb::pool::ConnectionPool
instead? If so, I'm not sure how to query using aPooledStream
.Thanks!
The text was updated successfully, but these errors were encountered: