Comments (3)
Thanks @patrickfreed for the feedback!
I'll see if I can figure out how to do the latter (single runtime for multithreaded tests), since that more closely resembles the webapp experience.
Really what I'm looking for is a way to access a static pool of connections in a multithreaded environment, without the overhead of reestablishing a connection each time I need one.
Re: a few other notes:
- Good to know. I'll do away with the wrapping
Arc
- The purpose is along the lines of a singleton connection instance... trying to accomplish a shared connection (or pool) as mentioned.
Thanks again!
from mongo-rust-driver.
Each #[tokio::test]
spins up its own runtime, so it's not possible to share the same client from each of them. Instead, I'd recommend creating a new client in each test. Alternatively, you can create a single runtime outside of the tests that is shared by each test, and annotate them with the regular #[test]
instead.
A few other notes:
- Collection
internally is just a wrapper around an Arc
and is Clone
, so you don't need to wrap it in an Arc
- It's not clear to me what the expected behavior of using futures::block_on
in a static context is with the driver. I'd recommend instead awaiting the futures from within the context of a tokio runtime instead.
from mongo-rust-driver.
No problem, happy to help. Also, the Client
type internally manages connection pools to each server in the deployment, so sharing one will indeed achieve the pooling behavior you're looking for (no need to pool the clients).
Going to go ahead and close this ticket, but please let us know if you have any further questions!
from mongo-rust-driver.
Related Issues (20)
- No way to support OpenAPI data converstion HOT 2
- SOCKS5 support HOT 1
- Can we remove the "deprecated" status from `human_readable_serialization` in `CollectionOptions`? HOT 5
- Failure to parse hello response from server HOT 3
- Feature Request : need serializer, deserializer for Option<Datetime> HOT 1
- stack overflow when working with big structs HOT 4
- Modify a Validator HOT 2
- RUST-1908 `find_one_and_update` / `find_one_and_update_with_session` use human-readable BSON deserialization HOT 2
- Find() with filter works but find({}) to get all documents fails HOT 1
- The solution for balancing the load of read operations. HOT 1
- Infinite loop while parsing results from find({}, None) HOT 2
- RUST-1913 Compilation error when handling ErrorKind::GridFs HOT 1
- Find one options, projection method not working for inclusions. HOT 6
- How to serialize a hashmap into BSON? HOT 5
- `tokio-runtime` feature flags. HOT 1
- Connection for too long HOT 2
- Memory leak in mongodb driver version 2.7 HOT 7
- Handle WriteError while insert_one HOT 3
- Is there any way we can pass `tlsCertificateKeyFilePassword ` for x.509 authentication? HOT 3
- Add `Server` module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongo-rust-driver.