Package com.google.cloud.spanner
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.google.api.core.ApiFuture<R>
doWorkAsync(TransactionContext txn)
Performs a single transaction attempt.
-
-
-
Method Detail
-
doWorkAsync
com.google.api.core.ApiFuture<R> doWorkAsync(TransactionContext txn)
Performs a single transaction attempt. All reads/writes should be performed usingtxn
.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
SpannerException
s 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 typeSpannerErrors#isAborted
: 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
-
-