cloud-sql-python-connector
cloud-sql-python-connector copied to clipboard
Improve caching of `Instance()` configs
Currently we cache Instance()
configs by instance connection name. Which means we throw an error if users try to connect to the same instance with enable_iam_auth=False
and then with enable_iam_auth=True
or vice versa. Instead if we hash with the additional iam info we could support both without needing to throw an error.
Alternative: If IAM authn flag has been changed, we force a refresh to get a new cert to avoid duplicating admin API calls.
https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/blob/a8481e01ee12647743ec585c87e39580b252ef9b/google/cloud/sql/connector/connector.py#L222-L231
Also remove instance from cache on bad connections.