Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 402b101

Browse filesBrowse files
feat: Set LAR True (#940)
* changes * tests * Update client.py * Update test_client.py * Update connection.py * setting feature false * changes * set LAR true * Update connection.py * Update client.py * changes * changes --------- Co-authored-by: surbhigarg92 <surbhigarg.92@gmail.com>
1 parent a973a3a commit 402b101
Copy full SHA for 402b101

File tree

Expand file treeCollapse file tree

4 files changed

+13
-16
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+13
-16
lines changed

‎google/cloud/spanner_dbapi/connection.py

Copy file name to clipboardExpand all lines: google/cloud/spanner_dbapi/connection.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def connect(
508508
pool=None,
509509
user_agent=None,
510510
client=None,
511-
route_to_leader_enabled=False,
511+
route_to_leader_enabled=True,
512512
):
513513
"""Creates a connection to a Google Cloud Spanner database.
514514
@@ -547,10 +547,9 @@ def connect(
547547
548548
:type route_to_leader_enabled: boolean
549549
:param route_to_leader_enabled:
550-
(Optional) Default False. Set route_to_leader_enabled as True to
551-
Enable leader aware routing. Enabling leader aware routing
552-
would route all requests in RW/PDML transactions to the
553-
leader region.
550+
(Optional) Default True. Set route_to_leader_enabled as False to
551+
disable leader aware routing. Disabling leader aware routing would
552+
route all requests in RW/PDML transactions to the closest region.
554553
555554
556555
:rtype: :class:`google.cloud.spanner_dbapi.connection.Connection`
@@ -568,14 +567,14 @@ def connect(
568567
credentials,
569568
project=project,
570569
client_info=client_info,
571-
route_to_leader_enabled=False,
570+
route_to_leader_enabled=True,
572571
)
573572
else:
574573
client = spanner.Client(
575574
project=project,
576575
credentials=credentials,
577576
client_info=client_info,
578-
route_to_leader_enabled=False,
577+
route_to_leader_enabled=True,
579578
)
580579
else:
581580
if project is not None and client.project != project:

‎google/cloud/spanner_v1/client.py

Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/client.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ class Client(ClientWithProject):
116116
117117
:type route_to_leader_enabled: boolean
118118
:param route_to_leader_enabled:
119-
(Optional) Default False. Set route_to_leader_enabled as True to
120-
Enable leader aware routing. Enabling leader aware routing
121-
would route all requests in RW/PDML transactions to the
122-
leader region.
119+
(Optional) Default True. Set route_to_leader_enabled as False to
120+
disable leader aware routing. Disabling leader aware routing would
121+
route all requests in RW/PDML transactions to the closest region.
123122
124123
:raises: :class:`ValueError <exceptions.ValueError>` if both ``read_only``
125124
and ``admin`` are :data:`True`
@@ -139,7 +138,7 @@ def __init__(
139138
client_info=_CLIENT_INFO,
140139
client_options=None,
141140
query_options=None,
142-
route_to_leader_enabled=False,
141+
route_to_leader_enabled=True,
143142
):
144143
self._emulator_host = _get_spanner_emulator_host()
145144

‎tests/unit/spanner_dbapi/test_connect.py

Copy file name to clipboardExpand all lines: tests/unit/spanner_dbapi/test_connect.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_w_explicit(self, mock_client):
8686
project=PROJECT,
8787
credentials=credentials,
8888
client_info=mock.ANY,
89-
route_to_leader_enabled=False,
89+
route_to_leader_enabled=True,
9090
)
9191
client_info = mock_client.call_args_list[0][1]["client_info"]
9292
self.assertEqual(client_info.user_agent, USER_AGENT)
@@ -120,7 +120,7 @@ def test_w_credential_file_path(self, mock_client):
120120
credentials_path,
121121
project=PROJECT,
122122
client_info=mock.ANY,
123-
route_to_leader_enabled=False,
123+
route_to_leader_enabled=True,
124124
)
125125
client_info = factory.call_args_list[0][1]["client_info"]
126126
self.assertEqual(client_info.user_agent, USER_AGENT)

‎tests/unit/test_client.py

Copy file name to clipboardExpand all lines: tests/unit/test_client.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _constructor_test_helper(
5959
client_options=None,
6060
query_options=None,
6161
expected_query_options=None,
62-
route_to_leader_enabled=None,
62+
route_to_leader_enabled=True,
6363
):
6464
import google.api_core.client_options
6565
from google.cloud.spanner_v1 import client as MUT
@@ -78,7 +78,6 @@ def _constructor_test_helper(
7878
)
7979
else:
8080
expected_client_options = client_options
81-
8281
if route_to_leader_enabled is not None:
8382
kwargs["route_to_leader_enabled"] = route_to_leader_enabled
8483

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.