use of com.couchbase.client.core.msg.kv.RemoveRequest in project couchbase-jvm-clients by couchbase.
the class ObserveIntegrationTest method performRemove.
/**
* Helper method to perform a remove operation that can then be observed.
*
* @param id the document id.
* @return returns the response to use for observe.
*/
private RemoveResponse performRemove(final String id) {
RemoveRequest removeRequest = new RemoveRequest(id, 0, env.timeoutConfig().kvTimeout(), core.context(), cid, env.retryStrategy(), Optional.empty(), null);
core.send(removeRequest);
RemoveResponse removeResponse;
try {
removeResponse = removeRequest.response().get();
} catch (Exception e) {
throw new RuntimeException(e);
}
assertTrue(removeResponse.status().success());
assertTrue(removeResponse.cas() != 0);
return removeResponse;
}
use of com.couchbase.client.core.msg.kv.RemoveRequest in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnRemove.
@Test
void tokenOnRemove() throws Exception {
String id = UUID.randomUUID().toString();
byte[] content = "hello, world".getBytes(UTF_8);
UpsertRequest upsertRequest = new UpsertRequest(id, content, 0, false, 0, kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), Optional.empty(), null);
core.send(upsertRequest);
UpsertResponse upsertResponse = upsertRequest.response().get();
assertTrue(upsertResponse.status().success());
assertMutationToken(upsertResponse.mutationToken());
RemoveRequest removeRequest = new RemoveRequest(id, upsertResponse.cas(), kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), Optional.empty(), null);
core.send(removeRequest);
RemoveResponse removeResponse = removeRequest.response().get();
assertTrue(removeResponse.status().success());
assertMutationToken(removeResponse.mutationToken());
}
use of com.couchbase.client.core.msg.kv.RemoveRequest in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method removeRequest.
/**
* Helper method to create the remove request.
*
* @param id the id of the document to remove.
* @param opts custom options to change the default behavior.
* @return the remove request.
*/
RemoveRequest removeRequest(final String id, final RemoveOptions.Built opts) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
Duration timeout = decideKvTimeout(opts, environment.timeoutConfig());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
final RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_REMOVE, opts.parentSpan().orElse(null));
RemoveRequest request = new RemoveRequest(id, opts.cas(), timeout, coreContext, collectionIdentifier, retryStrategy, opts.durabilityLevel(), span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.msg.kv.RemoveRequest in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method remove.
/**
* Removes a Document from a collection with custom options.
*
* @param id the id of the document to remove.
* @param options custom options to change the default behavior.
* @return a {@link Mono} completing once removed or failed.
*/
public Mono<MutationResult> remove(final String id, final RemoveOptions options) {
return Mono.defer(() -> {
notNull(options, "RemoveOptions", () -> ReducedKeyValueErrorContext.create(id, asyncCollection.collectionIdentifier()));
RemoveOptions.Built opts = options.build();
RemoveRequest request = asyncCollection.removeRequest(id, opts);
return Reactor.wrap(request, RemoveAccessor.remove(core, request, id, opts.persistTo(), opts.replicateTo()), true);
});
}
Aggregations