Class SpannerOptions.SpannerCallContextTimeoutConfigurator (6.49.0)

public static class SpannerOptions.SpannerCallContextTimeoutConfigurator implements SpannerOptions.CallContextConfigurator

Helper class to configure timeouts for specific Spanner RPCs. The 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(
     () -> {
       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.
         }
       }
     }
 

Inheritance

java.lang.Object > SpannerOptions.SpannerCallContextTimeoutConfigurator

Static Methods

create()

public static SpannerOptions.SpannerCallContextTimeoutConfigurator create()
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

Methods

<ReqT,RespT>configure(ApiCallContext context, ReqT request, MethodDescriptor<ReqT,RespT> method)

public ApiCallContext <ReqT,RespT>configure(ApiCallContext context, ReqT request, MethodDescriptor<ReqT,RespT> method)

Configure a ApiCallContext for a specific RPC call.

Parameters
NameDescription
contextApiCallContext
requestReqT
methodio.grpc.MethodDescriptor<ReqT,RespT>
Returns
TypeDescription
ApiCallContext

getBatchUpdateTimeout()

public Duration getBatchUpdateTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getCommitTimeout()

public Duration getCommitTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getExecuteQueryTimeout()

public Duration getExecuteQueryTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getExecuteUpdateTimeout()

public Duration getExecuteUpdateTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getPartitionQueryTimeout()

public Duration getPartitionQueryTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getPartitionReadTimeout()

public Duration getPartitionReadTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getReadTimeout()

public Duration getReadTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

getRollbackTimeout()

public Duration getRollbackTimeout()
Returns
TypeDescription
org.threeten.bp.Duration

withBatchUpdateTimeout(Duration batchUpdateTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withBatchUpdateTimeout(Duration batchUpdateTimeout)
Parameter
NameDescription
batchUpdateTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withCommitTimeout(Duration commitTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withCommitTimeout(Duration commitTimeout)
Parameter
NameDescription
commitTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withExecuteQueryTimeout(Duration executeQueryTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withExecuteQueryTimeout(Duration executeQueryTimeout)
Parameter
NameDescription
executeQueryTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withExecuteUpdateTimeout(Duration executeUpdateTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withExecuteUpdateTimeout(Duration executeUpdateTimeout)
Parameter
NameDescription
executeUpdateTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withPartitionQueryTimeout(Duration partitionQueryTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withPartitionQueryTimeout(Duration partitionQueryTimeout)
Parameter
NameDescription
partitionQueryTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withPartitionReadTimeout(Duration partitionReadTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withPartitionReadTimeout(Duration partitionReadTimeout)
Parameter
NameDescription
partitionReadTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withReadTimeout(Duration readTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withReadTimeout(Duration readTimeout)
Parameter
NameDescription
readTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator

withRollbackTimeout(Duration rollbackTimeout)

public SpannerOptions.SpannerCallContextTimeoutConfigurator withRollbackTimeout(Duration rollbackTimeout)
Parameter
NameDescription
rollbackTimeoutorg.threeten.bp.Duration
Returns
TypeDescription
SpannerOptions.SpannerCallContextTimeoutConfigurator