Skip to content

Removing core transaction attempt context bound couchbase client factory rebased #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
589 changes: 0 additions & 589 deletions src/main/java/com/couchbase/client/java/Cluster.java

This file was deleted.

111 changes: 0 additions & 111 deletions src/main/java/com/couchbase/client/java/ClusterInterface.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.couchbase.client.java.transactions;

import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.time.Duration;
Expand All @@ -26,14 +27,20 @@
import java.util.logging.Logger;

import com.couchbase.client.core.annotation.Stability;
import com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNode;
import com.couchbase.client.core.error.EncodingFailureException;
import com.couchbase.client.core.json.Mapper;
import com.couchbase.client.core.msg.query.QueryRequest;
import com.couchbase.client.core.transaction.CoreTransactionAttemptContext;
import com.couchbase.client.core.transaction.CoreTransactionContext;
import com.couchbase.client.core.transaction.CoreTransactionsReactive;
import com.couchbase.client.core.transaction.config.CoreMergedTransactionConfig;
import com.couchbase.client.core.transaction.config.CoreTransactionOptions;
import com.couchbase.client.core.transaction.log.CoreTransactionLogger;
import com.couchbase.client.core.transaction.support.AttemptState;
import com.couchbase.client.java.ReactiveScope;
import com.couchbase.client.java.codec.JsonSerializer;
import com.couchbase.client.java.json.JsonObject;
import reactor.core.publisher.Mono;
import reactor.util.annotation.Nullable;

Expand Down Expand Up @@ -131,4 +138,24 @@ public static TransactionResult run(Transactions transactions, Consumer<Transact
return reactive(transactions).runBlocking(transactionLogic, coreTransactionOptions);
}

// todo gp have C&Ped this from SDK, needs to be exposed properly in SDK
public static ObjectNode createTransactionOptions(final ReactiveScope scope,
final String statement,
final TransactionQueryOptions options) {
JsonObject json = JsonObject.create()
.put("statement", statement);
if (scope != null) {
json.put("query_context", QueryRequest.queryContext(scope.bucketName(), scope.name()));
}
if (options != null) {
options.builder().build().injectParams(json);
}
try {
ObjectNode opts = Mapper.reader().readValue(json.toBytes(), ObjectNode.class);
return opts;
} catch (IOException e) {
throw new EncodingFailureException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.couchbase.client.core.transaction.CoreTransactionAttemptContext;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.ClusterInterface;
import com.couchbase.client.java.Collection;
import com.couchbase.client.java.Scope;
import com.couchbase.client.java.transactions.config.TransactionOptions;
Expand All @@ -42,7 +41,7 @@ public interface ReactiveCouchbaseClientFactory /*extends CodecRegistryProvider*
/**
* Provides access to the managed SDK {@link Cluster} reference.
*/
ClusterInterface getCluster();
Cluster getCluster();

/**
* Provides access to the managed SDK {@link Scope} reference
Expand Down Expand Up @@ -91,12 +90,6 @@ public interface ReactiveCouchbaseClientFactory /*extends CodecRegistryProvider*

ReactiveCouchbaseResourceHolder getResourceHolder(TransactionOptions options, CoreTransactionAttemptContext ctx);

/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.ReactiveMongoDatabaseFactory#withSession(com.mongodb.session.ClientSession)
*/
ReactiveCouchbaseClientFactory withCore(ReactiveCouchbaseResourceHolder core);

/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.ReactiveMongoDatabaseFactory#with(com.mongodb.session.ClientSession)
Expand Down
Loading