Skip to content

Commit b8a8904

Browse files
chore: allow using static connection info in Connector
#406 added support for static connection info. But 5d9c473 accidentally deleted actually using the static connection info to create the cache. So re-adding that change in this PR.
1 parent 86d38bb commit b8a8904

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

google/cloud/alloydbconnector/connector.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from google.cloud.alloydbconnector.instance import RefreshAheadCache
3838
from google.cloud.alloydbconnector.lazy import LazyRefreshCache
3939
import google.cloud.alloydbconnector.pg8000 as pg8000
40+
from google.cloud.alloydbconnector.static import StaticConnectionInfoCache
4041
from google.cloud.alloydbconnector.types import CacheTypes
4142
from google.cloud.alloydbconnector.utils import generate_keys
4243
from google.cloud.alloydbconnector.utils import strip_http_prefix
@@ -188,6 +189,8 @@ async def connect_async(self, instance_uri: str, driver: str, **kwargs: Any) ->
188189
# use existing connection info if possible
189190
if instance_uri in self._cache:
190191
cache = self._cache[instance_uri]
192+
elif self._static_conn_info:
193+
cache = StaticConnectionInfoCache(instance_uri, self._static_conn_info)
191194
else:
192195
if self._refresh_strategy == RefreshStrategy.LAZY:
193196
logger.debug(

0 commit comments

Comments
 (0)