Search in sources :

Example 31 with RetryStrategy

use of com.couchbase.client.core.retry.RetryStrategy in project couchbase-jvm-clients by couchbase.

the class AsyncCollection method getAndLockRequest.

/**
 * Helper method to create the get and lock request.
 *
 * @param id the document id which is used to uniquely identify it.
 * @param lockTime how long to lock the document for.  Any values above 30 seconds will be
 *                 treated as 30 seconds.
 * @param opts custom options to change the default behavior.
 * @return the get and lock request.
 */
@Stability.Internal
GetAndLockRequest getAndLockRequest(final String id, final Duration lockTime, final GetAndLockOptions.Built opts) {
    notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
    notNull(lockTime, "LockTime", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
    Duration timeout = opts.timeout().orElse(environment.timeoutConfig().kvTimeout());
    RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
    RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_GET_AND_LOCK, opts.parentSpan().orElse(null));
    GetAndLockRequest request = new GetAndLockRequest(id, timeout, coreContext, collectionIdentifier, retryStrategy, lockTime, span);
    request.context().clientContext(opts.clientContext());
    return request;
}
Also used : GetAndLockRequest(com.couchbase.client.core.msg.kv.GetAndLockRequest) Duration(java.time.Duration) RetryStrategy(com.couchbase.client.core.retry.RetryStrategy) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Aggregations

RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)31 Duration (java.time.Duration)31 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)28 ArrayList (java.util.ArrayList)8 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)7 BucketConfig (com.couchbase.client.core.config.BucketConfig)7 GetRequest (com.couchbase.client.core.msg.kv.GetRequest)7 List (java.util.List)7 Core (com.couchbase.client.core.Core)6 CoreContext (com.couchbase.client.core.CoreContext)6 Stability (com.couchbase.client.core.annotation.Stability)6 ReducedKeyValueErrorContext (com.couchbase.client.core.error.context.ReducedKeyValueErrorContext)6 CollectionIdentifier (com.couchbase.client.core.io.CollectionIdentifier)6 Validators.notNullOrEmpty (com.couchbase.client.core.util.Validators.notNullOrEmpty)6 JsonObject (com.couchbase.client.java.json.JsonObject)6 CompletableFuture (java.util.concurrent.CompletableFuture)6 Reactor (com.couchbase.client.core.Reactor)5 CouchbaseBucketConfig (com.couchbase.client.core.config.CouchbaseBucketConfig)5 Map (java.util.Map)5 Flux (reactor.core.publisher.Flux)5