use of com.couchbase.client.core.error.context.ReducedQueryErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncScope method query.
/**
* Performs a N1QL query with custom {@link QueryOptions} in a Scope.
*
* @param statement the N1QL query statement as a raw string.
* @param options the custom options for this query.
* @return the {@link QueryResult} once the response arrives successfully.
*/
public CompletableFuture<QueryResult> query(final String statement, final QueryOptions options) {
notNull(options, "QueryOptions", () -> new ReducedQueryErrorContext(statement));
final QueryOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment.jsonSerializer() : opts.serializer();
return queryAccessor.queryAsync(queryRequest(bucketName(), scopeName, statement, opts, core, environment()), opts, serializer);
}
use of com.couchbase.client.core.error.context.ReducedQueryErrorContext in project couchbase-jvm-clients by couchbase.
the class ReactiveScope method query.
/**
* Performs a N1QL query with custom {@link QueryOptions} in a Scope
*
* @param statement the N1QL query statement as a raw string.
* @param options the custom options for this query.
* @return the {@link ReactiveQueryResult} once the response arrives successfully.
*/
public Mono<ReactiveQueryResult> query(final String statement, final QueryOptions options) {
notNull(options, "QueryOptions", () -> new ReducedQueryErrorContext(statement));
final QueryOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return async().queryAccessor().queryReactive(async().queryRequest(bucketName(), name(), statement, opts, core(), environment()), opts, serializer);
});
}
use of com.couchbase.client.core.error.context.ReducedQueryErrorContext in project couchbase-jvm-clients by couchbase.
the class ReactiveCluster method query.
/**
* Performs a N1QL query with custom {@link QueryOptions}.
*
* @param statement the N1QL query statement as a raw string.
* @param options the custom options for this query.
* @return the {@link ReactiveQueryResult} once the response arrives successfully.
*/
public Mono<ReactiveQueryResult> query(final String statement, final QueryOptions options) {
notNull(options, "QueryOptions", () -> new ReducedQueryErrorContext(statement));
final QueryOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return asyncCluster.queryAccessor().queryReactive(asyncCluster.queryRequest(statement, opts), opts, serializer);
});
}
use of com.couchbase.client.core.error.context.ReducedQueryErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncScope method queryRequest.
/**
* Helper method to construct the query request. ( copied from Cluster )
*
* @param statement the statement of the query.
* @param options the options.
* @return the constructed query request.
*/
static QueryRequest queryRequest(final String bucketName, final String scopeName, final String statement, final QueryOptions.Built options, final Core core, final ClusterEnvironment environment) {
notNullOrEmpty(statement, "Statement", () -> new ReducedQueryErrorContext(statement));
Duration timeout = options.timeout().orElse(environment.timeoutConfig().queryTimeout());
RetryStrategy retryStrategy = options.retryStrategy().orElse(environment.retryStrategy());
final JsonObject query = JsonObject.create();
query.put("statement", statement);
query.put("timeout", encodeDurationToMs(timeout));
String queryContext = QueryRequest.queryContext(bucketName, scopeName);
query.put("query_context", queryContext);
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, core.context().authenticator(), statement, queryBytes, options.readonly(), clientContextId, span, bucketName, scopeName, null);
request.context().clientContext(options.clientContext());
return request;
}
use of com.couchbase.client.core.error.context.ReducedQueryErrorContext 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;
}
Aggregations