Interface AsyncRunner.AsyncWork<R>

Enclosing interface:
AsyncRunner
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface AsyncRunner.AsyncWork<R>
Functional interface for executing a read/write transaction asynchronously that returns a result of type R.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.api.core.ApiFuture<R>
    Performs a single transaction attempt.
  • Method Details

    • doWorkAsync

      com.google.api.core.ApiFuture<R> doWorkAsync(TransactionContext txn)
      Performs a single transaction attempt. All reads/writes should be performed using txn.

      Implementations of this method should not attempt to commit the transaction directly: returning normally will result in the runner attempting to commit the transaction once the returned future completes, retrying on abort.

      In most cases, the implementation will not need to catch SpannerExceptions from Spanner operations, instead letting these propagate to the framework. The transaction runner will take appropriate action based on the type of exception. In particular, implementations should never catch an exception of type Status.Code.ABORTED: these indicate that some reads may have returned inconsistent data and the transaction attempt must be aborted.

      Parameters:
      txn - the transaction
      Returns:
      future over the result of the work