Skip to content

Commit

Permalink
chore: address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed Mar 20, 2024
1 parent 0bd677b commit ad3d3d1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ def force_connect(self, target_driver_func: Callable, driver_dialect: DriverDial
return self._connect_internal(host_info, props, is_initial_connection, force_connect_func)

def _connect_internal(self, host_info: HostInfo, props: Properties, is_initial_connection: bool, connect_func: Callable) -> Connection:
urlType: RdsUrlType = self._rds_utils.identify_rds_type(host_info.host)
if not urlType.is_rds_cluster:
url_type: RdsUrlType = self._rds_utils.identify_rds_type(host_info.host)
if not url_type.is_rds_cluster:
return connect_func()

if urlType == RdsUrlType.RDS_WRITER_CLUSTER:
if url_type == RdsUrlType.RDS_WRITER_CLUSTER:
writer_candidate_conn = self._get_verified_writer_connection(props, is_initial_connection, connect_func)
if writer_candidate_conn is None:
return connect_func()
return writer_candidate_conn

if urlType == RdsUrlType.RDS_READER_CLUSTER:
if url_type == RdsUrlType.RDS_READER_CLUSTER:
reader_candidate_conn = self._get_verified_reader_connection(props, is_initial_connection, connect_func)
if reader_candidate_conn is None:
return connect_func()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class DriverConfigurationProfiles:
plugin_factories=[HostMonitoringPluginFactory()],
properties=Properties({WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
WrapperProperties.SOCKET_TIMEOUT_SEC.name: 0,
WrapperProperties.FAILURE_DETECTION_COUNT: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS: 60000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS: 15000,
WrapperProperties.FAILURE_DETECTION_COUNT.name: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS.name: 60000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS.name: 15000,
WrapperProperties.TCP_KEEPALIVE.name: False,
"autocommit": True})
),
Expand All @@ -78,11 +78,11 @@ class DriverConfigurationProfiles:
plugin_factories=[HostMonitoringPluginFactory()],
properties=Properties({WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
WrapperProperties.SOCKET_TIMEOUT_SEC.name: 0,
WrapperProperties.FAILURE_DETECTION_COUNT: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS: 30000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS: 5000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC: 3,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC: 3,
WrapperProperties.FAILURE_DETECTION_COUNT.name: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS.name: 30000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS.name: 5000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC.name: 3,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC.name: 3,
WrapperProperties.TCP_KEEPALIVE.name: False,
"autocommit": True})
),
Expand Down Expand Up @@ -128,11 +128,11 @@ class DriverConfigurationProfiles:
ReadWriteSplittingPluginFactory(), FailoverPluginFactory(), HostMonitoringPluginFactory()],
properties=Properties({WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
WrapperProperties.SOCKET_TIMEOUT_SEC.name: 0,
WrapperProperties.FAILURE_DETECTION_COUNT: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS: 60000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS: 15000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC: 10,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC: 5,
WrapperProperties.FAILURE_DETECTION_COUNT.name: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS.name: 60000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS.name: 15000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC.name: 5,
WrapperProperties.TCP_KEEPALIVE.name: False,
"autocommit": True}),
connection_provider=SqlAlchemyPooledConnectionProvider(lambda _, __: {"pool_size": 30,
Expand All @@ -145,11 +145,11 @@ class DriverConfigurationProfiles:
ReadWriteSplittingPluginFactory(), FailoverPluginFactory(), HostMonitoringPluginFactory()],
properties=Properties({WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
WrapperProperties.SOCKET_TIMEOUT_SEC.name: 0,
WrapperProperties.FAILURE_DETECTION_COUNT: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS: 30000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS: 5000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC: 3,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC: 3,
WrapperProperties.FAILURE_DETECTION_COUNT.name: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS.name: 30000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS.name: 5000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC.name: 3,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC.name: 3,
WrapperProperties.TCP_KEEPALIVE.name: False,
"autocommit": True}),
connection_provider=SqlAlchemyPooledConnectionProvider(lambda _, __: {"pool_size": 30,
Expand Down Expand Up @@ -188,11 +188,11 @@ class DriverConfigurationProfiles:
HostMonitoringPluginFactory()],
properties=Properties({WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
WrapperProperties.SOCKET_TIMEOUT_SEC.name: 0,
WrapperProperties.FAILURE_DETECTION_COUNT: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS: 60000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS: 15000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC: 10,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC: 3,
WrapperProperties.FAILURE_DETECTION_COUNT.name: 5,
WrapperProperties.FAILURE_DETECTION_TIME_MS.name: 60000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS.name: 15000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC.name: 3,
WrapperProperties.TCP_KEEPALIVE.name: False,
"autocommit": True})
),
Expand All @@ -204,11 +204,11 @@ class DriverConfigurationProfiles:
HostMonitoringPluginFactory()],
properties=Properties({WrapperProperties.CONNECT_TIMEOUT_SEC.name: 10,
WrapperProperties.SOCKET_TIMEOUT_SEC.name: 0,
WrapperProperties.FAILURE_DETECTION_COUNT: 3,
WrapperProperties.FAILURE_DETECTION_TIME_MS: 30000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS: 5000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC: 3,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC: 3,
WrapperProperties.FAILURE_DETECTION_COUNT.name: 3,
WrapperProperties.FAILURE_DETECTION_TIME_MS.name: 30000,
WrapperProperties.FAILURE_DETECTION_INTERVAL_MS.name: 5000,
"monitoring-" + WrapperProperties.CONNECT_TIMEOUT_SEC.name: 3,
"monitoring-" + WrapperProperties.SOCKET_TIMEOUT_SEC.name: 3,
WrapperProperties.TCP_KEEPALIVE.name: False,
"autocommit": True})
)
Expand Down
2 changes: 1 addition & 1 deletion aws_advanced_python_wrapper/utils/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class WrapperProperties:
"random")

OPEN_CONNECTION_RETRY_TIMEOUT_MS = WrapperProperty("open_connection_retry_timeout_ms",
"Maximum allowed time for the retries opening a connection.", 30_000)
"Maximum allowed time in milliseconds for the retries opening a connection.", 30_000)
OPEN_CONNECTION_RETRY_INTERVAL_MS = WrapperProperty("open_connection_retry_interval_ms", "Time between each retry of opening a connection.", 1000)


Expand Down

0 comments on commit ad3d3d1

Please sign in to comment.