Skip to content
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

Question regarding mongo connection. #2

Open
SachinMaharana opened this issue Apr 13, 2020 · 2 comments
Open

Question regarding mongo connection. #2

SachinMaharana opened this issue Apr 13, 2020 · 2 comments

Comments

@SachinMaharana
Copy link

Hi,
Thanks for writing this up. I just wanted to clarify few things. I see that a connection is being opened to mongo when every route handle gets called. Is it is how it is working or i am wrong? If i am not wrong, is it effiecent?

@emreyalvac
Copy link
Owner

Hi,

I'm using lazy_static macro. This will initialize it on first use, and only once but there is a lot of way to do this. You can use r2d2 connection pool manager or actix-web web::Data with Mutext and Arc. (but if you use actix-web)

Thanks for comment @SachinMaharana.

@SachinMaharana
Copy link
Author

oh Cool! I did saw that but just wanted to clarify. Infact, i looked at r2d2-mongodb repo
https://gitlab.com/petoknm/r2d2-mongodb and apparently it is deprecated, recommending to use mongdb crate as its handles connection pool intenrally. Thanks anyway.

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

No branches or pull requests

2 participants