Package com.google.cloud.spanner
Class SpannerOptions.SpannerCallContextTimeoutConfigurator
- java.lang.Object
-
- com.google.cloud.spanner.SpannerOptions.SpannerCallContextTimeoutConfigurator
-
- All Implemented Interfaces:
SpannerOptions.CallContextConfigurator
- Enclosing class:
- SpannerOptions
public static class SpannerOptions.SpannerCallContextTimeoutConfigurator extends Object implements SpannerOptions.CallContextConfigurator
Helper class to configure timeouts for specific Spanner RPCs. TheSpannerOptions.SpannerCallContextTimeoutConfigurator
must be set as a value on theContext
using theSpannerOptions.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( () -> { 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. } } }
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <ReqT,RespT>
com.google.api.gax.rpc.ApiCallContextconfigure(com.google.api.gax.rpc.ApiCallContext context, ReqT request, io.grpc.MethodDescriptor<ReqT,RespT> method)
Configure aApiCallContext
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)
-
-
-
Method Detail
-
create
public static SpannerOptions.SpannerCallContextTimeoutConfigurator create()
-
configure
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)
Description copied from interface:SpannerOptions.CallContextConfigurator
Configure aApiCallContext
for a specific RPC call.- Specified by:
configure
in interfaceSpannerOptions.CallContextConfigurator
- Parameters:
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.- Returns:
- An
ApiCallContext
that will be merged with the defaultApiCallContext
. Ifnull
is returned, no changes to the defaultApiCallContext
will be made.
-
getCommitTimeout
public org.threeten.bp.Duration getCommitTimeout()
-
withCommitTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withCommitTimeout(org.threeten.bp.Duration commitTimeout)
-
getRollbackTimeout
public org.threeten.bp.Duration getRollbackTimeout()
-
withRollbackTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withRollbackTimeout(org.threeten.bp.Duration rollbackTimeout)
-
getExecuteQueryTimeout
public org.threeten.bp.Duration getExecuteQueryTimeout()
-
withExecuteQueryTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withExecuteQueryTimeout(org.threeten.bp.Duration executeQueryTimeout)
-
getExecuteUpdateTimeout
public org.threeten.bp.Duration getExecuteUpdateTimeout()
-
withExecuteUpdateTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withExecuteUpdateTimeout(org.threeten.bp.Duration executeUpdateTimeout)
-
getBatchUpdateTimeout
public org.threeten.bp.Duration getBatchUpdateTimeout()
-
withBatchUpdateTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withBatchUpdateTimeout(org.threeten.bp.Duration batchUpdateTimeout)
-
getReadTimeout
public org.threeten.bp.Duration getReadTimeout()
-
withReadTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withReadTimeout(org.threeten.bp.Duration readTimeout)
-
getPartitionQueryTimeout
public org.threeten.bp.Duration getPartitionQueryTimeout()
-
withPartitionQueryTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withPartitionQueryTimeout(org.threeten.bp.Duration partitionQueryTimeout)
-
getPartitionReadTimeout
public org.threeten.bp.Duration getPartitionReadTimeout()
-
withPartitionReadTimeout
public SpannerOptions.SpannerCallContextTimeoutConfigurator withPartitionReadTimeout(org.threeten.bp.Duration partitionReadTimeout)
-
-