1717import concurrent
1818import logging
1919from types import TracebackType
20- from google .cloud .sql .connector .instance_connection_manager import (
21- InstanceConnectionManager ,
20+ from google .cloud .sql .connector .instance import (
21+ Instance ,
2222 IPTypes ,
2323)
2424import google .cloud .sql .connector .pymysql as pymysql
@@ -70,7 +70,7 @@ def __init__(
7070 self ._keys : concurrent .futures .Future = asyncio .run_coroutine_threadsafe (
7171 generate_keys (), self ._loop
7272 )
73- self ._instances : Dict [str , InstanceConnectionManager ] = {}
73+ self ._instances : Dict [str , Instance ] = {}
7474
7575 # set default params for connections
7676 self ._timeout = timeout
@@ -136,32 +136,32 @@ async def connect_async(
136136 A DB-API connection to the specified Cloud SQL instance.
137137 """
138138
139- # Create an InstanceConnectionManager object from the connection string.
140- # The InstanceConnectionManager should verify arguments.
139+ # Create an Instance object from the connection string.
140+ # The Instance should verify arguments.
141141 #
142- # Use the InstanceConnectionManager to establish an SSL Connection.
142+ # Use the Instance to establish an SSL Connection.
143143 #
144144 # Return a DBAPI connection
145145 enable_iam_auth = kwargs .pop ("enable_iam_auth" , self ._enable_iam_auth )
146146 if instance_connection_string in self ._instances :
147- icm = self ._instances [instance_connection_string ]
148- if enable_iam_auth != icm ._enable_iam_auth :
147+ instance = self ._instances [instance_connection_string ]
148+ if enable_iam_auth != instance ._enable_iam_auth :
149149 raise ValueError (
150150 f"connect() called with `enable_iam_auth={ enable_iam_auth } `, "
151- f"but previously used enable_iam_auth={ icm ._enable_iam_auth } `. "
151+ f"but previously used enable_iam_auth={ instance ._enable_iam_auth } `. "
152152 "If you require both for your use case, please use a new "
153153 "connector.Connector object."
154154 )
155155 else :
156- icm = InstanceConnectionManager (
156+ instance = Instance (
157157 instance_connection_string ,
158158 driver ,
159159 self ._keys ,
160160 self ._loop ,
161161 self ._credentials ,
162162 enable_iam_auth ,
163163 )
164- self ._instances [instance_connection_string ] = icm
164+ self ._instances [instance_connection_string ] = instance
165165
166166 connect_func = {
167167 "pymysql" : pymysql .connect ,
@@ -195,7 +195,7 @@ async def connect_async(
195195
196196 # helper function to wrap in timeout
197197 async def get_connection () -> Any :
198- instance_data , ip_address = await icm .connect_info (ip_type )
198+ instance_data , ip_address = await instance .connect_info (ip_type )
199199 connect_partial = partial (
200200 connector , ip_address , instance_data .context , ** kwargs
201201 )
@@ -208,7 +208,7 @@ async def get_connection() -> Any:
208208 raise TimeoutError (f"Connection timed out after { timeout } s" )
209209 except Exception as e :
210210 # with any other exception, we attempt a force refresh, then throw the error
211- icm .force_refresh ()
211+ instance .force_refresh ()
212212 raise (e )
213213
214214 def __enter__ (self ) -> Any :
@@ -231,9 +231,11 @@ def close(self) -> None:
231231 close_future .result (timeout = 5 )
232232
233233 async def _close (self ) -> None :
234- """Helper function to cancel InstanceConnectionManagers ' tasks
234+ """Helper function to cancel Instances ' tasks
235235 and close aiohttp.ClientSession."""
236- await asyncio .gather (* [icm .close () for icm in self ._instances .values ()])
236+ await asyncio .gather (
237+ * [instance .close () for instance in self ._instances .values ()]
238+ )
237239
238240
239241def connect (instance_connection_string : str , driver : str , ** kwargs : Any ) -> Any :
0 commit comments