Interface AsyncRunner.AsyncWork<R> (6.53.0)

public static interface AsyncRunner.AsyncWork<R>

Functional interface for executing a read/write transaction asynchronously that returns a result of type R.

Type Parameter

NameDescription
R

Methods

doWorkAsync(TransactionContext txn)

public abstract 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 Code#ABORTED: these indicate that some reads may have returned inconsistent data and the transaction attempt must be aborted.

Parameter
NameDescription
txnTransactionContext

the transaction

Returns
TypeDescription
ApiFuture<R>

future over the result of the work