Skip to content

Derive Clone for DatabaseOptions #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2019
Merged

Derive Clone for DatabaseOptions #109

merged 1 commit into from
Dec 30, 2019

Conversation

petoknm
Copy link
Contributor

@petoknm petoknm commented Dec 28, 2019

I am trying to port r2d2-mongodb to use this new mongodb driver and it would be very nice if DatabaseOptions could be cloned.

@saghm saghm self-requested a review December 30, 2019 18:02
@saghm
Copy link
Contributor

saghm commented Dec 30, 2019

It definitely makes sense to make DatabaseOptions implement Clone; I've authorized our CI to run for this patch, and will merge it once it passes.

Note that wrapping this driver with r2d2 is probably not a good idea; it implements connection pooling under the hood, following the MongoDB CMAP spec. This means that making an r2d2 pool of Client (and by extension, of Database or Collection) will create a connection pool for each one, as well as all of the background threads that the driver needs for not only the pools but also to monitor the topology. The Client type implements Clone and Send, meaning that the best way to use it is to create one and then make a copy for each thread you spawn.

@petoknm
Copy link
Contributor Author

petoknm commented Dec 30, 2019

Thanks @saghm. Yea, I was wondering that that might be the case when i saw the max_pool_size/min_pool_size options.

@saghm
Copy link
Contributor

saghm commented Dec 30, 2019

The old version of the driver actually had connection pooling too; it was written before the CMAP spec existed though, and we never got around to implementing the options that are now part of the spec.

@saghm
Copy link
Contributor

saghm commented Dec 30, 2019

The MacOS failures are due to a bug in our CI (not due to anything in the driver), so I'll merge this now. Thanks for the contribution!

@saghm saghm merged commit 4ba2cfe into mongodb:master Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants