public static class SpannerOptions.SpannerCallContextTimeoutConfigurator extends Object implements SpannerOptions.CallContextConfigurator
SpannerOptions.SpannerCallContextTimeoutConfigurator
must be set as a value on the Context
using the
SpannerOptions.CALL_CONTEXT_CONFIGURATOR_KEY
key.
Example usage:
// Create a context with a ExecuteQuery timeout of 10 seconds.
Context context =
Context.current()
.withValue(
SpannerOptions.CALL_CONTEXT_CONFIGURATOR_KEY,
SpannerCallContextTimeoutConfigurator.create()
.withExecuteQueryTimeout(Duration.ofSeconds(10L)));
context.run(
new Runnable() {
public void run() {
try (ResultSet rs =
client
.singleUse()
.executeQuery(
Statement.of(
"SELECT SingerId, FirstName, LastName FROM Singers ORDER BY LastName"))) {
while (rs.next()) {
System.out.printf("%d %s %s%n", rs.getLong(0), rs.getString(1), rs.getString(2));
}
} catch (SpannerException e) {
if (e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED) {
// Handle timeout.
}
}
}
});
Modifier and Type | Method and Description |
---|---|
<ReqT,RespT> |
configure(com.google.api.gax.rpc.ApiCallContext context,
ReqT request,
io.grpc.MethodDescriptor<ReqT,RespT> method)
Configure a
ApiCallContext for a specific RPC call. |
static SpannerOptions.SpannerCallContextTimeoutConfigurator |
create() |
org.threeten.bp.Duration |
getBatchUpdateTimeout() |
org.threeten.bp.Duration |
getCommitTimeout() |
org.threeten.bp.Duration |
getExecuteQueryTimeout() |
org.threeten.bp.Duration |
getExecuteUpdateTimeout() |
org.threeten.bp.Duration |
getPartitionQueryTimeout() |
org.threeten.bp.Duration |
getPartitionReadTimeout() |
org.threeten.bp.Duration |
getReadTimeout() |
org.threeten.bp.Duration |
getRollbackTimeout() |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withBatchUpdateTimeout(org.threeten.bp.Duration batchUpdateTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withCommitTimeout(org.threeten.bp.Duration commitTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withExecuteQueryTimeout(org.threeten.bp.Duration executeQueryTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withExecuteUpdateTimeout(org.threeten.bp.Duration executeUpdateTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withPartitionQueryTimeout(org.threeten.bp.Duration partitionQueryTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withPartitionReadTimeout(org.threeten.bp.Duration partitionReadTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withReadTimeout(org.threeten.bp.Duration readTimeout) |
SpannerOptions.SpannerCallContextTimeoutConfigurator |
withRollbackTimeout(org.threeten.bp.Duration rollbackTimeout) |
public static SpannerOptions.SpannerCallContextTimeoutConfigurator create()
public <ReqT,RespT> com.google.api.gax.rpc.ApiCallContext configure(com.google.api.gax.rpc.ApiCallContext context, ReqT request, io.grpc.MethodDescriptor<ReqT,RespT> method)
SpannerOptions.CallContextConfigurator
ApiCallContext
for a specific RPC call.configure
in interface SpannerOptions.CallContextConfigurator
context
- The default context. This can be used to inspect the current values.request
- The request that will be sent.method
- The method that is being called.ApiCallContext
that will be merged with the default ApiCallContext
. If null
is returned, no changes to the default ApiCallContext
will be made.public org.threeten.bp.Duration getCommitTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withCommitTimeout(org.threeten.bp.Duration commitTimeout)
public org.threeten.bp.Duration getRollbackTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withRollbackTimeout(org.threeten.bp.Duration rollbackTimeout)
public org.threeten.bp.Duration getExecuteQueryTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withExecuteQueryTimeout(org.threeten.bp.Duration executeQueryTimeout)
public org.threeten.bp.Duration getExecuteUpdateTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withExecuteUpdateTimeout(org.threeten.bp.Duration executeUpdateTimeout)
public org.threeten.bp.Duration getBatchUpdateTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withBatchUpdateTimeout(org.threeten.bp.Duration batchUpdateTimeout)
public org.threeten.bp.Duration getReadTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withReadTimeout(org.threeten.bp.Duration readTimeout)
public org.threeten.bp.Duration getPartitionQueryTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withPartitionQueryTimeout(org.threeten.bp.Duration partitionQueryTimeout)
public org.threeten.bp.Duration getPartitionReadTimeout()
public SpannerOptions.SpannerCallContextTimeoutConfigurator withPartitionReadTimeout(org.threeten.bp.Duration partitionReadTimeout)
Copyright © 2020 Google LLC. All rights reserved.