Skip to content

Commit 606bbda

Browse files
committed
fix: resolve comments.
1 parent cde93a3 commit 606bbda

File tree

6 files changed

+261
-228
lines changed

6 files changed

+261
-228
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,11 +1159,20 @@ public Builder setEmulatorHost(String emulatorHost) {
11591159
}
11601160

11611161
/**
1162-
* Enable or disable leader aware routing. Leader aware routing would route all requests in
1163-
* RW/PDML transactions to the leader region.
1162+
* Enable leader aware routing. Leader aware routing would route all requests in RW/PDML
1163+
* transactions to the leader region.
11641164
*/
1165-
public Builder setLeaderAwareRouting(boolean leaderAwareRoutingEnabled) {
1166-
this.leaderAwareRoutingEnabled = leaderAwareRoutingEnabled;
1165+
public Builder enableLeaderAwareRouting() {
1166+
this.leaderAwareRoutingEnabled = true;
1167+
return this;
1168+
}
1169+
1170+
/**
1171+
* Enable leader aware routing. Leader aware routing would route all requests in RW/PDML
1172+
* transactions to the leader region.
1173+
*/
1174+
public Builder disableLeaderAwareRouting() {
1175+
this.leaderAwareRoutingEnabled = false;
11671176
return this;
11681177
}
11691178

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ public void deleteSession(String sessionName, @Nullable Map<Option, ?> options)
16331633
public ApiFuture<Empty> asyncDeleteSession(String sessionName, @Nullable Map<Option, ?> options) {
16341634
DeleteSessionRequest request = DeleteSessionRequest.newBuilder().setName(sessionName).build();
16351635
GrpcCallContext context =
1636-
newCallContext(options, sessionName, request, SpannerGrpc.getDeleteSessionMethod(), false);
1636+
newCallContext(options, sessionName, request, SpannerGrpc.getDeleteSessionMethod());
16371637
return spannerStub.deleteSessionCallable().futureCall(request, context);
16381638
}
16391639

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,39 @@ Session createSession(
319319
ApiFuture<Empty> asyncDeleteSession(String sessionName, @Nullable Map<Option, ?> options)
320320
throws SpannerException;
321321

322+
/**
323+
* Performs a streaming read.
324+
*
325+
* @param routeToLeader Set to true to route the request to the leader region, and false to route
326+
* the request to any region. When leader aware routing is enabled, RW/PDML requests are
327+
* preferred to be routed to the leader region, and RO requests (except for
328+
* PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
329+
*/
322330
StreamingCall read(
323331
ReadRequest request,
324332
ResultStreamConsumer consumer,
325333
@Nullable Map<Option, ?> options,
326334
boolean routeToLeader);
327335

336+
/**
337+
* Executes a query.
338+
*
339+
* @param routeToLeader Set to true to route the request to the leader region, and false to route
340+
* the request to any region. When leader aware routing is enabled, RW/PDML requests are
341+
* preferred to be routed to the leader region, and RO requests (except for
342+
* PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
343+
*/
328344
ResultSet executeQuery(
329345
ExecuteSqlRequest request, @Nullable Map<Option, ?> options, boolean routeToLeader);
330346

347+
/**
348+
* Executes a query asynchronously.
349+
*
350+
* @param routeToLeader Set to true to route the request to the leader region, and false to route
351+
* the request to any region. When leader aware routing is enabled, RW/PDML requests are
352+
* preferred to be routed to the leader region, and RO requests (except for
353+
* PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
354+
*/
331355
ApiFuture<ResultSet> executeQueryAsync(
332356
ExecuteSqlRequest request, @Nullable Map<Option, ?> options, boolean routeToLeader);
333357

@@ -338,6 +362,14 @@ ApiFuture<ResultSet> executeQueryAsync(
338362
ServerStream<PartialResultSet> executeStreamingPartitionedDml(
339363
ExecuteSqlRequest request, @Nullable Map<Option, ?> options, Duration timeout);
340364

365+
/**
366+
* Executes a query with streaming result.
367+
*
368+
* @param routeToLeader Set to true to route the request to the leader region, and false to route
369+
* the request to any region. When leader aware routing is enabled, RW/PDML requests are
370+
* preferred to be routed to the leader region, and RO requests (except for
371+
* PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
372+
*/
341373
StreamingCall executeQuery(
342374
ExecuteSqlRequest request,
343375
ResultStreamConsumer consumer,
@@ -349,10 +381,26 @@ StreamingCall executeQuery(
349381
ApiFuture<ExecuteBatchDmlResponse> executeBatchDmlAsync(
350382
ExecuteBatchDmlRequest build, Map<Option, ?> options);
351383

384+
/**
385+
* Begins a transaction.
386+
*
387+
* @param routeToLeader Set to true to route the request to the leader region, and false to route
388+
* the request to any region. When leader aware routing is enabled, RW/PDML requests are
389+
* preferred to be routed to the leader region, and RO requests (except for
390+
* PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
391+
*/
352392
Transaction beginTransaction(
353393
BeginTransactionRequest request, @Nullable Map<Option, ?> options, boolean routeToLeader)
354394
throws SpannerException;
355395

396+
/**
397+
* Begins a transaction asynchronously.
398+
*
399+
* @param routeToLeader Set to true to route the request to the leader region, and false to route
400+
* the request to any region. When leader aware routing is enabled, RW/PDML requests are
401+
* preferred to be routed to the leader region, and RO requests (except for
402+
* PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.
403+
*/
356404
ApiFuture<Transaction> beginTransactionAsync(
357405
BeginTransactionRequest request, @Nullable Map<Option, ?> options, boolean routeToLeader);
358406

0 commit comments

Comments
 (0)