Skip to content

Commit ed510e8

Browse files
authored
feat: Set LAR as False (#1883)
1 parent 74a54b0 commit ed510e8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export type GetInstanceConfigOperationsCallback = PagedCallback<
108108

109109
/**
110110
* Session pool configuration options.
111-
* @property {boolean} [routeToLeaderEnabled=True] If set to false leader aware routing will be disabled.
112-
* Disabling leader aware routing would route all requests in RW/PDML transactions to any region.
111+
* @property {boolean} [routeToLeaderEnabled=False] If set to true leader aware routing will be enabled.
112+
* Enabling leader aware routing would route all requests in RW/PDML transactions to leader region.
113113
*/
114114
export interface SpannerOptions extends GrpcClientOptions {
115115
apiEndpoint?: string;
@@ -216,7 +216,7 @@ class Spanner extends GrpcService {
216216
projectIdReplaced_: boolean;
217217
projectFormattedName_: string;
218218
resourceHeader_: {[k: string]: string};
219-
routeToLeaderEnabled = true;
219+
routeToLeaderEnabled = false;
220220

221221
/**
222222
* Placeholder used to auto populate a column with the commit timestamp.
@@ -318,8 +318,8 @@ class Spanner extends GrpcService {
318318
} as {} as GrpcServiceConfig;
319319
super(config, options);
320320

321-
if (options.routeToLeaderEnabled === false) {
322-
this.routeToLeaderEnabled = false;
321+
if (options.routeToLeaderEnabled === true) {
322+
this.routeToLeaderEnabled = true;
323323
}
324324

325325
this.options = options;

test/spanner.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1491,33 +1491,33 @@ describe('Spanner with mock server', () => {
14911491
});
14921492

14931493
describe('LeaderAwareRouting', () => {
1494-
let spannerWithLARDisabled: Spanner;
1495-
let instanceWithLARDisabled: Instance;
1494+
let spannerWithLAREnabled: Spanner;
1495+
let instanceWithLAREnabled: Instance;
14961496

1497-
function newTestDatabaseWithLARDisabled(
1497+
function newTestDatabaseWithLAREnabled(
14981498
options?: SessionPoolOptions,
14991499
queryOptions?: IQueryOptions
15001500
): Database {
1501-
return instanceWithLARDisabled.database(
1501+
return instanceWithLAREnabled.database(
15021502
`database-${dbCounter++}`,
15031503
options,
15041504
queryOptions
15051505
);
15061506
}
15071507

15081508
before(() => {
1509-
spannerWithLARDisabled = new Spanner({
1509+
spannerWithLAREnabled = new Spanner({
15101510
servicePath: 'localhost',
15111511
port,
15121512
sslCreds: grpc.credentials.createInsecure(),
1513-
routeToLeaderEnabled: false,
1513+
routeToLeaderEnabled: true,
15141514
});
15151515
// Gets a reference to a Cloud Spanner instance and database
1516-
instanceWithLARDisabled = spannerWithLARDisabled.instance('instance');
1516+
instanceWithLAREnabled = spannerWithLAREnabled.instance('instance');
15171517
});
15181518

15191519
it('should execute with leader aware routing enabled in a read/write transaction', async () => {
1520-
const database = newTestDatabase();
1520+
const database = newTestDatabaseWithLAREnabled();
15211521
await database.runTransactionAsync(async tx => {
15221522
await tx!.runUpdate({
15231523
sql: insertSql,
@@ -1539,7 +1539,7 @@ describe('Spanner with mock server', () => {
15391539
});
15401540

15411541
it('should execute with leader aware routing disabled in a read/write transaction', async () => {
1542-
const database = newTestDatabaseWithLARDisabled();
1542+
const database = newTestDatabase();
15431543
await database.runTransactionAsync(async tx => {
15441544
await tx!.runUpdate({
15451545
sql: insertSql,

0 commit comments

Comments
 (0)