Class CoreTransactionsReactive
java.lang.Object
com.couchbase.client.core.transaction.CoreTransactionsReactive
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconfig()
core()
createAttemptContext
(CoreTransactionContext overall, CoreMergedTransactionConfig config, String attemptId) executeTransaction
(Mono<CoreTransactionAttemptContext> createAttempt, CoreMergedTransactionConfig config, CoreTransactionContext overall, Function<CoreTransactionAttemptContext, Mono<Void>> transactionLogic, boolean singleQueryTransactionMode) The main transactions 'engine', responsible for attempting the transaction logic as many times as required, until the transaction commits, is explicitly rolled back, or expires.query
(String statement, CoreQueryContext queryContext, CoreQueryOptions queryOptions, Optional<RequestSpan> parentSpan, Function<Throwable, RuntimeException> errorConverter) Performs a single query transaction, with a scope context and custom configuration.queryBlocking
(String statement, CoreQueryContext qc, CoreQueryOptions queryOptions, Optional<RequestSpan> parentSpan) run
(Function<CoreTransactionAttemptContext, Mono<?>> transactionLogic, CoreTransactionOptions perConfig) Runs the supplied transactional logic until success or failure.
-
Constructor Details
-
CoreTransactionsReactive
-
-
Method Details
-
executeTransaction
public Mono<CoreTransactionResult> executeTransaction(Mono<CoreTransactionAttemptContext> createAttempt, CoreMergedTransactionConfig config, CoreTransactionContext overall, Function<CoreTransactionAttemptContext, Mono<Void>> transactionLogic, boolean singleQueryTransactionMode) The main transactions 'engine', responsible for attempting the transaction logic as many times as required, until the transaction commits, is explicitly rolled back, or expires. -
createAttemptContext
public CoreTransactionAttemptContext createAttemptContext(CoreTransactionContext overall, CoreMergedTransactionConfig config, String attemptId) -
run
public Mono<CoreTransactionResult> run(Function<CoreTransactionAttemptContext, Mono<?>> transactionLogic, @Nullable CoreTransactionOptions perConfig) Runs the supplied transactional logic until success or failure.- The transaction logic is supplied with a
CoreTransactionAttemptContext
, which contains asynchronous methods to allow it to read, mutate, insert and delete documents, as well as commit or rollback the transactions. - The transaction logic should run these methods as a Reactor chain.
- The transaction logic should return a
Mono<Void>
. AnyFlux
orMono
can be converted to aMono<Void>
by calling.then()
on it. - This method returns a
Mono<TransactionResult>
, which should be handled as a normal Reactor Mono.
- Parameters:
transactionLogic
- the application's transaction logicperConfig
- the configuration to use for this transaction- Returns:
- there is no need to check the returned
CoreTransactionResult
, as success is implied by the lack of a thrown exception. It contains information useful only for debugging and logging. - Throws:
CoreTransactionFailedException
- or a derived exception if the transaction fails to commit for any reason, possibly after multiple retries. The exception contains further details of the error. Not
- The transaction logic is supplied with a
-
config
-
core
-
query
public Mono<CoreReactiveQueryResult> query(String statement, @Nullable CoreQueryContext queryContext, CoreQueryOptions queryOptions, Optional<RequestSpan> parentSpan, Function<Throwable, RuntimeException> errorConverter) Performs a single query transaction, with a scope context and custom configuration. Results are streaming, hence `errorConverter` is required to handle any errors during streaming. -
queryBlocking
public Mono<CoreQueryResult> queryBlocking(String statement, @Nullable CoreQueryContext qc, CoreQueryOptions queryOptions, Optional<RequestSpan> parentSpan)
-