use of com.couchbase.client.java.codec.Transcoder in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method get.
/**
* Fetches a Document from a collection with custom options.
*
* @param id the document id which is used to uniquely identify it.
* @param options custom options to change the default behavior.
* @return a {@link Mono} indicating once loaded or failed
*/
public Mono<GetResult> get(final String id, final GetOptions options) {
return Mono.defer(() -> {
GetOptions.Built opts = options.build();
final Transcoder transcoder = opts.transcoder() == null ? environment().transcoder() : opts.transcoder();
if (opts.projections().isEmpty() && !opts.withExpiry()) {
GetRequest request = asyncCollection.fullGetRequest(id, opts);
return Reactor.wrap(request, GetAccessor.get(core, request, transcoder), true);
} else {
SubdocGetRequest request = asyncCollection.subdocGetRequest(id, opts);
return Reactor.wrap(request, GetAccessor.subdocGet(core, request, transcoder), true);
}
});
}
use of com.couchbase.client.java.codec.Transcoder in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method getAndTouch.
/**
* Fetches a full document and resets its expiration time to the value provided with custom
* options.
*
* @param id the document id which is used to uniquely identify it.
* @param expiry the new expiration time for the document.
* @param options custom options to change the default behavior.
* @return a {@link Mono} completing once loaded or failed.
*/
public Mono<GetResult> getAndTouch(final String id, final Duration expiry, final GetAndTouchOptions options) {
return Mono.defer(() -> {
GetAndTouchOptions.Built opts = options.build();
final Transcoder transcoder = opts.transcoder() == null ? environment().transcoder() : opts.transcoder();
GetAndTouchRequest request = asyncCollection.getAndTouchRequest(id, Expiry.relative(expiry), opts);
return Reactor.wrap(request, GetAccessor.getAndTouch(core, request, transcoder), true);
});
}
use of com.couchbase.client.java.codec.Transcoder in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method getAnyReplica.
/**
* Reads all available replicas, and returns the first found.
* <p>
* If the read requests all fail, the mono emits nothing.
*
* @param id the document id.
* @param options the custom options.
* @return a mono containing the first available replica.
*/
public Mono<GetReplicaResult> getAnyReplica(final String id, final GetAnyReplicaOptions options) {
GetAnyReplicaOptions.Built opts = options.build();
final Transcoder transcoder = Optional.ofNullable(opts.transcoder()).orElse(environment().transcoder());
return ReplicaHelper.getAnyReplicaReactive(core, asyncCollection.collectionIdentifier(), id, opts.timeout().orElse(environment().timeoutConfig().kvTimeout()), opts.retryStrategy().orElse(environment().retryStrategy()), opts.clientContext(), opts.parentSpan().orElse(null)).map(response -> GetReplicaResult.from(response, transcoder));
}
Aggregations