Search in sources :

Example 1 with TouchOptions

use of com.couchbase.client.java.kv.TouchOptions 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;
}
Also used : Duration(java.time.Duration) GetAndTouchOptions(com.couchbase.client.java.kv.GetAndTouchOptions) TouchOptions(com.couchbase.client.java.kv.TouchOptions) RetryStrategy(com.couchbase.client.core.retry.RetryStrategy) TouchRequest(com.couchbase.client.core.msg.kv.TouchRequest) GetAndTouchRequest(com.couchbase.client.core.msg.kv.GetAndTouchRequest) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Aggregations

RequestSpan (com.couchbase.client.core.cnc.RequestSpan)1 GetAndTouchRequest (com.couchbase.client.core.msg.kv.GetAndTouchRequest)1 TouchRequest (com.couchbase.client.core.msg.kv.TouchRequest)1 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)1 GetAndTouchOptions (com.couchbase.client.java.kv.GetAndTouchOptions)1 TouchOptions (com.couchbase.client.java.kv.TouchOptions)1 Duration (java.time.Duration)1