use of com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext in project couchbase-jvm-clients by couchbase.
the class ReactiveScope method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions} on a scope
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link ReactiveAnalyticsResult} once the response arrives successfully.
*/
public Mono<ReactiveAnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return AnalyticsAccessor.analyticsQueryReactive(asyncScope.core(), asyncScope.analyticsRequest(statement, opts), serializer);
});
}
use of com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext in project couchbase-jvm-clients by couchbase.
the class ReactiveCluster method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions}.
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link ReactiveAnalyticsResult} once the response arrives successfully.
*/
public Mono<ReactiveAnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return AnalyticsAccessor.analyticsQueryReactive(asyncCluster.core(), asyncCluster.analyticsRequest(statement, opts), serializer);
});
}
use of com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncScope method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions}.
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link AnalyticsResult} once the response arrives successfully.
*/
public CompletableFuture<AnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment.jsonSerializer() : opts.serializer();
return AnalyticsAccessor.analyticsQueryAsync(core, analyticsRequest(statement, opts), serializer);
}
use of com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncScope 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.timeoutConfig().analyticsTimeout());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
JsonObject query = JsonObject.create();
query.put("statement", statement);
query.put("timeout", encodeDurationToMs(timeout));
query.put("query_context", AnalyticsRequest.queryContext(bucketName, scopeName));
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, core.context().authenticator(), queryBytes, opts.priority(), opts.readonly(), clientContextId, statement, span, bucketName, scopeName);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncCluster method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions}.
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link AnalyticsResult} once the response arrives successfully.
*/
public CompletableFuture<AnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment.get().jsonSerializer() : opts.serializer();
return AnalyticsAccessor.analyticsQueryAsync(core, analyticsRequest(statement, opts), serializer);
}
Aggregations