Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions google/cloud/alloydbconnector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from google.cloud.alloydbconnector.instance import RefreshAheadCache
from google.cloud.alloydbconnector.lazy import LazyRefreshCache
import google.cloud.alloydbconnector.pg8000 as pg8000
from google.cloud.alloydbconnector.static import StaticConnectionInfoCache
from google.cloud.alloydbconnector.types import CacheTypes
from google.cloud.alloydbconnector.utils import generate_keys
from google.cloud.alloydbconnector.utils import strip_http_prefix
Expand Down Expand Up @@ -188,6 +189,8 @@ async def connect_async(self, instance_uri: str, driver: str, **kwargs: Any) ->
# use existing connection info if possible
if instance_uri in self._cache:
cache = self._cache[instance_uri]
elif self._static_conn_info:
cache = StaticConnectionInfoCache(instance_uri, self._static_conn_info)
else:
if self._refresh_strategy == RefreshStrategy.LAZY:
logger.debug(
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ def test_Connector_static_connection_info(
)
# check connection is returned
assert connection is True
# check that cache is not set
assert fake_client.instance.uri() not in connector._cache


def test_connect_when_closed(credentials: FakeCredentials) -> None:
Expand Down
Loading