use of com.couchbase.client.java.kv.UnlockOptions in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method unlockRequest.
/**
* Helper method to create the unlock request.
*
* @param id the id of the document.
* @param cas the CAS value which is needed to unlock it.
* @param options the options to customize.
* @return the unlock request.
*/
UnlockRequest unlockRequest(final String id, final long cas, final UnlockOptions options) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(options, "UnlockOptions", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
if (cas == 0) {
throw new InvalidArgumentException("CAS cannot be 0", null, ReducedKeyValueErrorContext.create(id, collectionIdentifier));
}
UnlockOptions.Built opts = options.build();
Duration timeout = opts.timeout().orElse(environment.timeoutConfig().kvTimeout());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_UNLOCK, opts.parentSpan().orElse(null));
UnlockRequest request = new UnlockRequest(timeout, coreContext, collectionIdentifier, retryStrategy, id, cas, span);
request.context().clientContext(opts.clientContext());
return request;
}
Aggregations