beanie
beanie copied to clipboard
Using beanie in with rotating/dynamic credentials
I'm interested in using beanie for a project with API that is backed by Atlas. One of the constraints I have is the use of rotating credentials that get updated hourly.
Are there any examples or recommendations for using beanie in this situation? How would one update the existing beanie initialization with new credentials and close the previously created motor client? I'm hoping the update would be seamless/transparent to end-users of the API: any in-process requests would be fulfilled and there would be no interruption in the Mongo connection as API requests continue to come in.
Oh. This is interesting. Could you pls tell me, how do you handle this without Beanie? I can include this to the init function, if it will fit
To add to this atlas requires pymongo[srv]
. How are you getting past with a default install of beanie:
pymongo.errors.ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs. To fix this error install pymongo with the srv extra:
/workspaces/OS-CFDB/.venv/bin/python -m pip install "pymongo[srv]"
We just installed dnspython as another requirement. For the original post thought: When using just Motor, we setup a wrapper when calling atlas and when we received an auth error, we just grabbed the new credentials from the secrets file and setup a a new connection. When using Beanie, we've explored a couple options, but it looks like where we are landing is watching a file that is populated with a vault side car and assigning a new client to beanie. We debated rerunning the full init, but I'm hesitant because of the overhead with validating the collections/indexes, so I was wondering if we could get a helper function to tell the Document classes to use a new connection/collection and skip all the initial startup processes. We can post some of our existing ideas, but I don't love them and think a beanie helper function would be super helpful.
Hey. I have to check, which steps of init could be skipped (using relative argument explicitly) to not break things. I'll come back here soon and tell, what are the plans about this.
This issue is stale because it has been open 30 days with no activity.
This issue was closed because it has been stalled for 14 days with no activity.