use of com.couchbase.client.core.msg.kv.TouchRequest in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method touchRequest.
/**
* Helper method to create the touch request.
*
* @param id the id of the document to update.
* @param expiry the new expiry for the document.
* @param options the custom options.
* @return the touch request.
*/
TouchRequest touchRequest(final String id, final Expiry expiry, final TouchOptions options) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(expiry, "Expiry", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(options, "TouchOptions", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
TouchOptions.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_TOUCH, opts.parentSpan().orElse(null));
long encodedExpiry = expiry.encode();
TouchRequest request = new TouchRequest(timeout, coreContext, collectionIdentifier, retryStrategy, id, encodedExpiry, span);
request.context().clientContext(opts.clientContext());
return request;
}
Aggregations