use of com.couchbase.client.java.kv.GetAllReplicasOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method getAllReplicas.
/**
* Reads all available replicas, including the active, and returns the results as a flux.
* <p>
* Note that individual errors are ignored, so you can think of this API as a best effort
* approach which explicitly emphasises availability over consistency.
* <p>
* If the read requests all fail, the flux emits nothing.
*
* @param id the document id.
* @param options the custom options.
* @return a flux of results from all replicas
*/
public Flux<GetReplicaResult> getAllReplicas(final String id, final GetAllReplicasOptions options) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, asyncCollection.collectionIdentifier()));
notNull(options, "GetAllReplicasOptions", () -> ReducedKeyValueErrorContext.create(id, asyncCollection.collectionIdentifier()));
GetAllReplicasOptions.Built opts = options.build();
final Transcoder transcoder = Optional.ofNullable(opts.transcoder()).orElse(environment().transcoder());
return ReplicaHelper.getAllReplicasReactive(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));
}
use of com.couchbase.client.java.kv.GetAllReplicasOptions in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method getAllReplicas.
/**
* Reads from replicas or the active node based on the options and returns the results as a list
* of futures that might complete or fail.
*
* @param id the document id.
* @return a list of results from the active and the replica.
*/
public CompletableFuture<List<CompletableFuture<GetReplicaResult>>> getAllReplicas(final String id, final GetAllReplicasOptions options) {
notNull(options, "GetAllReplicasOptions");
GetAllReplicasOptions.Built opts = options.build();
Transcoder transcoder = opts.transcoder() == null ? environment.transcoder() : opts.transcoder();
return ReplicaHelper.getAllReplicasAsync(core, collectionIdentifier, id, opts.timeout().orElse(environment.timeoutConfig().kvTimeout()), opts.retryStrategy().orElse(environment().retryStrategy()), opts.clientContext(), opts.parentSpan().orElse(null), response -> GetReplicaResult.from(response, transcoder));
}
Aggregations