use of com.couchbase.client.core.msg.kv.AppendRequest in project couchbase-jvm-clients by couchbase.
the class ReactiveBinaryCollection method append.
/**
* Appends binary content to the document with custom options.
*
* @param id the document id which is used to uniquely identify it.
* @param content the binary content to append to the document.
* @param options custom options to customize the append behavior.
* @return a {@link MutationResult} once completed.
* @throws DocumentNotFoundException the given document id is not found in the collection.
* @throws CasMismatchException if the document has been concurrently modified on the server.
* @throws TimeoutException if the operation times out before getting a result.
* @throws CouchbaseException for all other error reasons (acts as a base type and catch-all).
*/
public Mono<MutationResult> append(final String id, final byte[] content, final AppendOptions options) {
return Mono.defer(() -> {
notNull(options, "AppendOptions", () -> ReducedKeyValueErrorContext.create(id, async.collectionIdentifier()));
AppendOptions.Built opts = options.build();
AppendRequest request = async.appendRequest(id, content, opts);
return Reactor.wrap(request, AppendAccessor.append(core, request, id, opts.persistTo(), opts.replicateTo()), true);
});
}
use of com.couchbase.client.core.msg.kv.AppendRequest in project couchbase-jvm-clients by couchbase.
the class AsyncBinaryCollection method appendRequest.
AppendRequest appendRequest(final String id, final byte[] content, final AppendOptions.Built opts) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(content, "Content", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
Duration timeout = decideKvTimeout(opts, environment.timeoutConfig());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_APPEND, opts.parentSpan().orElse(null));
AppendRequest request = new AppendRequest(timeout, coreContext, collectionIdentifier, retryStrategy, id, content, opts.cas(), opts.durabilityLevel(), span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.msg.kv.AppendRequest in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnAppend.
@Test
void tokenOnAppend() throws Exception {
String id = UUID.randomUUID().toString();
byte[] content = "hello".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());
AppendRequest appendRequest = new AppendRequest(kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), id, ", world".getBytes(UTF_8), upsertResponse.cas(), Optional.empty(), null);
core.send(appendRequest);
AppendResponse appendResponse = appendRequest.response().get();
assertTrue(appendResponse.status().success());
assertMutationToken(appendResponse.mutationToken());
}
Aggregations