4
pom.xml
4
pom.xml
@@ -18,8 +18,8 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<couchbase>3.3.4</couchbase>
|
||||
<couchbase.osgi>3.3.4</couchbase.osgi>
|
||||
<couchbase>3.4.0</couchbase>
|
||||
<couchbase.osgi>3.4.0</couchbase.osgi>
|
||||
<springdata.commons>3.0.0-SNAPSHOT</springdata.commons>
|
||||
<java-module-name>spring.data.couchbase</java-module-name>
|
||||
<hibernate.validator>7.0.1.Final</hibernate.validator>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.core;
|
||||
|
||||
import static com.couchbase.client.core.cnc.TracingIdentifiers.TRANSACTION_OP_INSERT;
|
||||
import static com.couchbase.client.java.transactions.internal.ConverterUtil.makeCollectionIdentifier;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -30,7 +31,12 @@ import org.springframework.data.couchbase.core.query.OptionsBuilder;
|
||||
import org.springframework.data.couchbase.core.support.PseudoArgs;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.couchbase.client.core.cnc.CbTracing;
|
||||
import com.couchbase.client.core.cnc.RequestSpan;
|
||||
import com.couchbase.client.core.cnc.TracingIdentifiers;
|
||||
import com.couchbase.client.core.msg.kv.DurabilityLevel;
|
||||
import com.couchbase.client.core.transaction.CoreTransactionAttemptContext;
|
||||
import com.couchbase.client.core.transaction.support.SpanWrapper;
|
||||
import com.couchbase.client.java.kv.InsertOptions;
|
||||
import com.couchbase.client.java.kv.PersistTo;
|
||||
import com.couchbase.client.java.kv.ReplicateTo;
|
||||
@@ -97,15 +103,21 @@ public class ReactiveInsertByIdOperationSupport implements ReactiveInsertByIdOpe
|
||||
.flatMap(converted -> TransactionalSupport.checkForTransactionInThreadLocalStorage().flatMap(ctxOpt -> {
|
||||
if (!ctxOpt.isPresent()) {
|
||||
return collection.reactive()
|
||||
.insert(converted.getId().toString(), converted.export(), buildOptions(pArgs.getOptions(), converted))
|
||||
.insert(converted.getId().toString(), converted.export(),
|
||||
buildOptions(pArgs.getOptions(), converted))
|
||||
.flatMap(result -> this.support.applyResult(object, converted, converted.getId(), result.cas(),
|
||||
null, null));
|
||||
} else {
|
||||
rejectInvalidTransactionalOptions();
|
||||
return ctxOpt.get().getCore()
|
||||
CoreTransactionAttemptContext internal = ctxOpt.get().getCore();
|
||||
RequestSpan span = CbTracing.newSpan(internal.core().context(), TRANSACTION_OP_INSERT,
|
||||
internal.span());
|
||||
span.attribute(TracingIdentifiers.ATTR_OPERATION, TRANSACTION_OP_INSERT);
|
||||
return internal
|
||||
.insert(makeCollectionIdentifier(collection.async()), converted.getId().toString(),
|
||||
template.getCouchbaseClientFactory().getCluster().environment().transcoder()
|
||||
.encode(converted.export()).encoded())
|
||||
.encode(converted.export()).encoded(),
|
||||
new SpanWrapper(span))
|
||||
.flatMap(result -> this.support.applyResult(object, converted, converted.getId(), result.cas(),
|
||||
null, null));
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.core;
|
||||
|
||||
import static com.couchbase.client.core.cnc.TracingIdentifiers.TRANSACTION_OP_REMOVE;
|
||||
import static com.couchbase.client.java.transactions.internal.ConverterUtil.makeCollectionIdentifier;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -29,9 +30,13 @@ import org.springframework.data.couchbase.core.query.OptionsBuilder;
|
||||
import org.springframework.data.couchbase.core.support.PseudoArgs;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.couchbase.client.core.cnc.CbTracing;
|
||||
import com.couchbase.client.core.cnc.RequestSpan;
|
||||
import com.couchbase.client.core.cnc.TracingIdentifiers;
|
||||
import com.couchbase.client.core.msg.kv.DurabilityLevel;
|
||||
import com.couchbase.client.core.transaction.CoreTransactionAttemptContext;
|
||||
import com.couchbase.client.core.transaction.CoreTransactionGetResult;
|
||||
import com.couchbase.client.core.transaction.support.SpanWrapper;
|
||||
import com.couchbase.client.java.ReactiveCollection;
|
||||
import com.couchbase.client.java.kv.PersistTo;
|
||||
import com.couchbase.client.java.kv.RemoveOptions;
|
||||
@@ -101,7 +106,8 @@ public class ReactiveRemoveByIdOperationSupport implements ReactiveRemoveByIdOpe
|
||||
|
||||
return TransactionalSupport.checkForTransactionInThreadLocalStorage().flatMap(s -> {
|
||||
if (!s.isPresent()) {
|
||||
return rc.remove(id.toString(), buildRemoveOptions(pArgs.getOptions())).map(r -> RemoveResult.from(id.toString(), r));
|
||||
return rc.remove(id.toString(), buildRemoveOptions(pArgs.getOptions()))
|
||||
.map(r -> RemoveResult.from(id.toString(), r));
|
||||
} else {
|
||||
rejectInvalidTransactionalOptions();
|
||||
|
||||
@@ -115,7 +121,10 @@ public class ReactiveRemoveByIdOperationSupport implements ReactiveRemoveByIdOpe
|
||||
if (getResult.cas() != cas) {
|
||||
return Mono.error(TransactionalSupport.retryTransactionOnCasMismatch(ctx, getResult.cas(), cas));
|
||||
}
|
||||
return ctx.remove(getResult).map(r -> new RemoveResult(id.toString(), 0, null));
|
||||
CoreTransactionAttemptContext internal = ctx;
|
||||
RequestSpan span = CbTracing.newSpan(internal.core().context(), TRANSACTION_OP_REMOVE, internal.span());
|
||||
span.attribute(TracingIdentifiers.ATTR_OPERATION, TRANSACTION_OP_REMOVE);
|
||||
return ctx.remove(getResult, new SpanWrapper(span)).map(r -> new RemoveResult(id.toString(), 0, null));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.core;
|
||||
|
||||
import static com.couchbase.client.core.cnc.TracingIdentifiers.TRANSACTION_OP_REPLACE;
|
||||
import static com.couchbase.client.java.transactions.internal.ConverterUtil.makeCollectionIdentifier;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -30,10 +31,14 @@ import org.springframework.data.couchbase.core.query.OptionsBuilder;
|
||||
import org.springframework.data.couchbase.core.support.PseudoArgs;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.couchbase.client.core.cnc.CbTracing;
|
||||
import com.couchbase.client.core.cnc.RequestSpan;
|
||||
import com.couchbase.client.core.cnc.TracingIdentifiers;
|
||||
import com.couchbase.client.core.io.CollectionIdentifier;
|
||||
import com.couchbase.client.core.msg.kv.DurabilityLevel;
|
||||
import com.couchbase.client.core.transaction.CoreTransactionAttemptContext;
|
||||
import com.couchbase.client.core.transaction.CoreTransactionGetResult;
|
||||
import com.couchbase.client.core.transaction.support.SpanWrapper;
|
||||
import com.couchbase.client.core.transaction.util.DebugUtil;
|
||||
import com.couchbase.client.java.kv.PersistTo;
|
||||
import com.couchbase.client.java.kv.ReplaceOptions;
|
||||
@@ -124,9 +129,14 @@ public class ReactiveReplaceByIdOperationSupport implements ReactiveReplaceByIdO
|
||||
if (getResult.cas() != cas) {
|
||||
return Mono.error(TransactionalSupport.retryTransactionOnCasMismatch(ctx, getResult.cas(), cas));
|
||||
}
|
||||
CoreTransactionAttemptContext internal = ctxOpt.get().getCore();
|
||||
RequestSpan span = CbTracing.newSpan(internal.core().context(), TRANSACTION_OP_REPLACE,
|
||||
internal.span());
|
||||
span.attribute(TracingIdentifiers.ATTR_OPERATION, TRANSACTION_OP_REPLACE);
|
||||
return ctx.replace(getResult, template.getCouchbaseClientFactory().getCluster().environment()
|
||||
.transcoder().encode(converted.export()).encoded());
|
||||
}).flatMap(result -> support.applyResult(object, converted, converted.getId(), result.cas(), null, null));
|
||||
.transcoder().encode(converted.export()).encoded(), new SpanWrapper(span));
|
||||
}).flatMap(
|
||||
result -> support.applyResult(object, converted, converted.getId(), result.cas(), null, null));
|
||||
}
|
||||
})).onErrorMap(throwable -> {
|
||||
if (throwable instanceof RuntimeException) {
|
||||
|
||||
Reference in New Issue
Block a user