ApiFuture runInTransaction()

in cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/v2/DatabaseClientTransactionManager.java [181:195]


  <T> ApiFuture<T> runInTransaction(Function<? super TransactionContext, ApiFuture<T>> operation) {

    // The first statement in a transaction has no input, hence Void input type.
    // The subsequent statements take the previous statements' return (affected row count)
    // as input.
    AsyncTransactionStep<? extends Object, T> updateStatementFuture =
        this.lastStep == null
            ? this.txnContextFuture.then(
                (ctx, unusedVoid) -> operation.apply(ctx), REACTOR_EXECUTOR)
            : this.lastStep.then(
                (ctx, unusedPreviousResult) -> operation.apply(ctx), REACTOR_EXECUTOR);

    this.lastStep = updateStatementFuture;
    return updateStatementFuture;
  }