use of com.couchbase.client.core.retry.RetryStrategy in project couchbase-jvm-clients by couchbase.
the class AsyncBinaryCollection method prependRequest.
PrependRequest prependRequest(final String id, final byte[] content, final PrependOptions.Built opts) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(content, "Content", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
Duration timeout = decideKvTimeout(opts, environment.timeoutConfig());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_PREPEND, opts.parentSpan().orElse(null));
PrependRequest request = new PrependRequest(timeout, coreContext, collectionIdentifier, retryStrategy, id, content, opts.cas(), opts.durabilityLevel(), span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.retry.RetryStrategy in project couchbase-jvm-clients by couchbase.
the class AsyncBinaryCollection method incrementRequest.
IncrementRequest incrementRequest(final String id, final IncrementOptions.Built opts) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
Duration timeout = decideKvTimeout(opts, environment.timeoutConfig());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_INCREMENT, opts.parentSpan().orElse(null));
long expiry = opts.expiry().encode();
IncrementRequest request = new IncrementRequest(timeout, coreContext, collectionIdentifier, retryStrategy, id, opts.delta(), opts.initial(), expiry, opts.durabilityLevel(), span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.retry.RetryStrategy in project couchbase-jvm-clients by couchbase.
the class AsyncCluster method queryRequest.
/**
* Helper method to construct the query request.
*
* @param statement the statement of the query.
* @param options the options.
* @return the constructed query request.
*/
QueryRequest queryRequest(final String statement, final QueryOptions.Built options) {
notNullOrEmpty(statement, "Statement", () -> new ReducedQueryErrorContext(statement));
Duration timeout = options.timeout().orElse(environment.get().timeoutConfig().queryTimeout());
RetryStrategy retryStrategy = options.retryStrategy().orElse(environment.get().retryStrategy());
final JsonObject query = JsonObject.create();
query.put("statement", statement);
query.put("timeout", encodeDurationToMs(timeout));
options.injectParams(query);
final byte[] queryBytes = query.toString().getBytes(StandardCharsets.UTF_8);
final String clientContextId = query.getString("client_context_id");
final RequestSpan span = environment().requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_QUERY, options.parentSpan().orElse(null));
QueryRequest request = new QueryRequest(timeout, core.context(), retryStrategy, authenticator, statement, queryBytes, options.readonly(), clientContextId, span, null, null, null);
request.context().clientContext(options.clientContext());
return request;
}
use of com.couchbase.client.core.retry.RetryStrategy in project couchbase-jvm-clients by couchbase.
the class AsyncCluster method analyticsRequest.
/**
* Helper method to craft an analytics request.
*
* @param statement the statement to use.
* @param opts the built analytics options.
* @return the created analytics request.
*/
AnalyticsRequest analyticsRequest(final String statement, final AnalyticsOptions.Built opts) {
notNullOrEmpty(statement, "Statement", () -> new ReducedAnalyticsErrorContext(statement));
Duration timeout = opts.timeout().orElse(environment.get().timeoutConfig().analyticsTimeout());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.get().retryStrategy());
JsonObject query = JsonObject.create();
query.put("statement", statement);
query.put("timeout", encodeDurationToMs(timeout));
opts.injectParams(query);
final byte[] queryBytes = query.toString().getBytes(StandardCharsets.UTF_8);
final String clientContextId = query.getString("client_context_id");
final RequestSpan span = environment().requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_ANALYTICS, opts.parentSpan().orElse(null));
AnalyticsRequest request = new AnalyticsRequest(timeout, core.context(), retryStrategy, authenticator, queryBytes, opts.priority(), opts.readonly(), clientContextId, statement, span, null, null);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.retry.RetryStrategy in project couchbase-jvm-clients by couchbase.
the class AsyncCluster method searchRequest.
SearchRequest searchRequest(final String indexName, final SearchQuery query, final SearchOptions.Built opts) {
notNullOrEmpty(indexName, "IndexName", () -> new ReducedSearchErrorContext(indexName, query.export().toMap()));
Duration timeout = opts.timeout().orElse(environment.get().timeoutConfig().searchTimeout());
JsonObject params = query.export();
opts.injectParams(indexName, params, timeout);
byte[] bytes = params.toString().getBytes(StandardCharsets.UTF_8);
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.get().retryStrategy());
final RequestSpan span = environment().requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_SEARCH, opts.parentSpan().orElse(null));
SearchRequest request = new SearchRequest(timeout, core.context(), retryStrategy, authenticator, indexName, bytes, span);
request.context().clientContext(opts.clientContext());
return request;
}
Aggregations