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.SpannerCallContextTimeoutConfiguratormust be set as a value on theContextusing theSpannerOptions.CALL_CONTEXT_CONFIGURATOR_KEYkey.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 aApiCallContextfor a specific RPC call.static SpannerOptions.SpannerCallContextTimeoutConfiguratorcreate()org.threeten.bp.DurationgetBatchUpdateTimeout()org.threeten.bp.DurationgetCommitTimeout()org.threeten.bp.DurationgetExecuteQueryTimeout()org.threeten.bp.DurationgetExecuteUpdateTimeout()org.threeten.bp.DurationgetPartitionQueryTimeout()org.threeten.bp.DurationgetPartitionReadTimeout()org.threeten.bp.DurationgetReadTimeout()org.threeten.bp.DurationgetRollbackTimeout()SpannerOptions.SpannerCallContextTimeoutConfiguratorwithBatchUpdateTimeout(org.threeten.bp.Duration batchUpdateTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithCommitTimeout(org.threeten.bp.Duration commitTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithExecuteQueryTimeout(org.threeten.bp.Duration executeQueryTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithExecuteUpdateTimeout(org.threeten.bp.Duration executeUpdateTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithPartitionQueryTimeout(org.threeten.bp.Duration partitionQueryTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithPartitionReadTimeout(org.threeten.bp.Duration partitionReadTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithReadTimeout(org.threeten.bp.Duration readTimeout)SpannerOptions.SpannerCallContextTimeoutConfiguratorwithRollbackTimeout(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.CallContextConfiguratorConfigure aApiCallContextfor a specific RPC call.- Specified by:
configurein 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
ApiCallContextthat will be merged with the defaultApiCallContext. Ifnullis returned, no changes to the defaultApiCallContextwill 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)
-
-