use of com.couchbase.client.core.msg.kv.DurabilityLevel in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method testFluentApi.
@Test
void testFluentApi() {
User user1 = new User(UUID.randomUUID().toString(), "user1", "user1");
DurabilityLevel dl = DurabilityLevel.NONE;
User result;
RemoveResult rr;
result = couchbaseTemplate.insertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1);
assertEquals(user1, result);
result = couchbaseTemplate.upsertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1);
assertEquals(user1, result);
result = couchbaseTemplate.replaceById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1);
assertEquals(user1, result);
rr = couchbaseTemplate.removeById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1.getId());
assertEquals(rr.getId(), user1.getId());
assertEquals(user1, result);
result = reactiveCouchbaseTemplate.insertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1).block();
assertEquals(user1, result);
result = reactiveCouchbaseTemplate.upsertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1).block();
assertEquals(user1, result);
result = reactiveCouchbaseTemplate.replaceById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1).block();
assertEquals(user1, result);
rr = reactiveCouchbaseTemplate.removeById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName).one(user1.getId()).block();
assertEquals(rr.getId(), user1.getId());
}
use of com.couchbase.client.core.msg.kv.DurabilityLevel in project kafka-connect-couchbase by couchbase.
the class DurabilitySetter method create.
static DurabilitySetter create(DurabilityConfig config) {
DurabilityLevel durabilityLevel = config.durability();
if (durabilityLevel != DurabilityLevel.NONE) {
if (config.persistTo() != PersistTo.NONE || config.replicateTo() != ReplicateTo.NONE) {
String durabilityKey = keyName(DurabilityConfig.class, DurabilityConfig::durability);
String replicateToKey = keyName(DurabilityConfig.class, DurabilityConfig::replicateTo);
String persistToKey = keyName(DurabilityConfig.class, DurabilityConfig::persistTo);
throw new ConnectException("Invalid durability config. When '" + durabilityKey + "' is set," + " you must not set '" + replicateToKey + "' or '" + persistToKey + "'.");
}
return options -> options.durability(durabilityLevel);
}
PersistTo persistTo = config.persistTo();
ReplicateTo replicateTo = config.replicateTo();
return options -> options.durability(persistTo, replicateTo);
}
Aggregations