executeTransactionOperation<R> method

FutureOr<R> executeTransactionOperation<R>(
  1. TransactionOperation op,
  2. FutureOr<R> f(
    1. DBObjectGCSAdapterContext connection
    )
)

Implementation

FutureOr<R> executeTransactionOperation<R>(TransactionOperation op,
    FutureOr<R> Function(DBObjectGCSAdapterContext connection) f) {
  var transaction = op.transaction;

  if (isTransactionWithSingleOperation(op)) {
    return executeWithPool(f,
        onError: (e, s) => transaction.notifyExecutionError(
              e,
              s,
              errorResolver: resolveError,
              operation: op,
              debugInfo: () => op.toString(),
            ));
  }

  if (transaction.isOpen) {
    return transaction.addExecution<R, DBObjectGCSAdapterContext>(
      f,
      errorResolver: resolveError,
      operation: op,
      debugInfo: () => op.toString(),
    );
  }

  if (!transaction.isOpening) {
    transaction.open(
      () => openTransaction(transaction),
      callCloseTransactionRequired
          ? () => closeTransaction(
              transaction, transaction.context as DBObjectGCSAdapterContext?)
          : null,
    );
  }

  return transaction.onOpen<R>(() {
    return transaction.addExecution<R, DBObjectGCSAdapterContext>(
      f,
      errorResolver: resolveError,
      operation: op,
      debugInfo: () => op.toString(),
    );
  });
}