couchbase 3.4.1 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/couchbase/CMakeLists.txt +59 -7
- data/ext/couchbase/cmake/Documentation.cmake +0 -1
- data/ext/couchbase/cmake/OpenSSL.cmake +98 -3
- data/ext/couchbase/cmake/Testing.cmake +12 -4
- data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +4 -0
- data/ext/couchbase/cmake/build_config.hxx.in +3 -0
- data/ext/couchbase/core/bucket.cxx +3 -2
- data/ext/couchbase/core/bucket.hxx +9 -0
- data/ext/couchbase/core/cluster.hxx +17 -0
- data/ext/couchbase/core/cluster_options.cxx +2 -2
- data/ext/couchbase/core/cluster_options.hxx +4 -7
- data/ext/couchbase/core/{config_profile.cxx → cluster_options_fwd.hxx} +7 -6
- data/ext/couchbase/core/config_profile.hxx +2 -65
- data/ext/couchbase/core/config_profiles.cxx +79 -0
- data/ext/couchbase/core/config_profiles.hxx +56 -0
- data/ext/couchbase/core/error_context/search.hxx +1 -1
- data/ext/couchbase/core/impl/analytics.cxx +237 -0
- data/ext/couchbase/core/impl/boolean_field_query.cxx +40 -0
- data/ext/couchbase/core/impl/boolean_query.cxx +62 -0
- data/ext/couchbase/core/impl/cluster.cxx +2 -1
- data/ext/couchbase/core/impl/conjunction_query.cxx +51 -0
- data/ext/couchbase/core/impl/date_range.cxx +89 -0
- data/ext/couchbase/core/impl/date_range_facet.cxx +54 -0
- data/ext/couchbase/core/impl/date_range_facet_result.cxx +64 -0
- data/ext/couchbase/core/impl/date_range_query.cxx +125 -0
- data/ext/couchbase/core/impl/disjunction_query.cxx +51 -0
- data/ext/couchbase/core/impl/dns_srv_tracker.cxx +5 -3
- data/ext/couchbase/core/impl/encoded_search_facet.hxx +29 -0
- data/ext/couchbase/core/impl/encoded_search_query.hxx +29 -0
- data/ext/couchbase/core/impl/encoded_search_sort.hxx +29 -0
- data/ext/couchbase/core/impl/geo_bounding_box_query.cxx +46 -0
- data/ext/couchbase/core/impl/geo_distance_query.cxx +43 -0
- data/ext/couchbase/core/impl/geo_polygon_query.cxx +46 -0
- data/ext/couchbase/core/impl/internal_date_range_facet_result.cxx +80 -0
- data/ext/couchbase/core/impl/internal_date_range_facet_result.hxx +48 -0
- data/ext/couchbase/core/impl/internal_numeric_range_facet_result.cxx +80 -0
- data/ext/couchbase/core/impl/internal_numeric_range_facet_result.hxx +48 -0
- data/ext/couchbase/core/impl/internal_search_error_context.cxx +141 -0
- data/ext/couchbase/core/impl/internal_search_error_context.hxx +61 -0
- data/ext/couchbase/core/impl/internal_search_meta_data.cxx +60 -0
- data/ext/couchbase/core/impl/internal_search_meta_data.hxx +41 -0
- data/ext/couchbase/core/impl/internal_search_result.cxx +84 -0
- data/ext/couchbase/core/impl/internal_search_result.hxx +43 -0
- data/ext/couchbase/core/impl/internal_search_row.cxx +82 -0
- data/ext/couchbase/core/impl/internal_search_row.hxx +56 -0
- data/ext/couchbase/core/impl/internal_search_row_location.hxx +32 -0
- data/ext/couchbase/core/impl/internal_search_row_locations.cxx +137 -0
- data/ext/couchbase/core/impl/internal_search_row_locations.hxx +45 -0
- data/ext/couchbase/core/impl/internal_term_facet_result.cxx +80 -0
- data/ext/couchbase/core/impl/internal_term_facet_result.hxx +48 -0
- data/ext/couchbase/core/impl/match_all_query.cxx +35 -0
- data/ext/couchbase/core/impl/match_none_query.cxx +35 -0
- data/ext/couchbase/core/impl/match_phrase_query.cxx +43 -0
- data/ext/couchbase/core/impl/match_query.cxx +59 -0
- data/ext/couchbase/core/impl/numeric_range.cxx +49 -0
- data/ext/couchbase/core/impl/numeric_range_facet.cxx +54 -0
- data/ext/couchbase/core/impl/numeric_range_facet_result.cxx +64 -0
- data/ext/couchbase/core/impl/numeric_range_query.cxx +56 -0
- data/ext/couchbase/core/impl/phrase_query.cxx +42 -0
- data/ext/couchbase/core/impl/prefix_query.cxx +40 -0
- data/ext/couchbase/core/impl/query.cxx +5 -5
- data/ext/couchbase/core/impl/query_string_query.cxx +37 -0
- data/ext/couchbase/core/impl/regexp_query.cxx +40 -0
- data/ext/couchbase/core/impl/search.cxx +191 -0
- data/ext/couchbase/core/impl/search_error_context.cxx +147 -0
- data/ext/couchbase/core/impl/search_meta_data.cxx +46 -0
- data/ext/couchbase/core/impl/search_result.cxx +66 -0
- data/ext/couchbase/core/impl/search_row.cxx +74 -0
- data/ext/couchbase/core/impl/search_row_location.cxx +64 -0
- data/ext/couchbase/core/impl/search_row_locations.cxx +66 -0
- data/ext/couchbase/core/impl/search_sort_field.cxx +104 -0
- data/ext/couchbase/core/impl/search_sort_id.cxx +43 -0
- data/ext/couchbase/core/impl/search_sort_score.cxx +43 -0
- data/ext/couchbase/core/impl/term_facet.cxx +36 -0
- data/ext/couchbase/core/impl/term_facet_result.cxx +64 -0
- data/ext/couchbase/core/impl/term_query.cxx +56 -0
- data/ext/couchbase/core/impl/term_range_query.cxx +57 -0
- data/ext/couchbase/core/impl/wildcard_query.cxx +40 -0
- data/ext/couchbase/core/io/dns_client.cxx +225 -0
- data/ext/couchbase/core/io/dns_client.hxx +19 -188
- data/ext/couchbase/core/io/http_context.hxx +1 -1
- data/ext/couchbase/core/io/http_session.hxx +10 -0
- data/ext/couchbase/core/io/http_session_manager.hxx +5 -3
- data/ext/couchbase/core/io/mcbp_session.cxx +28 -1
- data/ext/couchbase/core/io/retry_orchestrator.hxx +3 -2
- data/ext/couchbase/core/json_string.hxx +5 -0
- data/ext/couchbase/core/meta/version.cxx +18 -4
- data/ext/couchbase/core/mozilla_ca_bundle.hxx +39 -0
- data/ext/couchbase/core/operations/document_analytics.cxx +1 -0
- data/ext/couchbase/core/operations/document_analytics.hxx +1 -0
- data/ext/couchbase/core/operations/document_append.hxx +1 -1
- data/ext/couchbase/core/operations/document_decrement.hxx +1 -1
- data/ext/couchbase/core/operations/document_exists.hxx +1 -1
- data/ext/couchbase/core/operations/document_get.hxx +1 -1
- data/ext/couchbase/core/operations/document_get_and_lock.hxx +1 -1
- data/ext/couchbase/core/operations/document_get_and_touch.hxx +1 -1
- data/ext/couchbase/core/operations/document_get_projected.hxx +1 -1
- data/ext/couchbase/core/operations/document_increment.hxx +1 -1
- data/ext/couchbase/core/operations/document_insert.hxx +1 -1
- data/ext/couchbase/core/operations/document_lookup_in.hxx +1 -1
- data/ext/couchbase/core/operations/document_mutate_in.hxx +1 -1
- data/ext/couchbase/core/operations/document_prepend.hxx +1 -1
- data/ext/couchbase/core/operations/document_query.cxx +2 -0
- data/ext/couchbase/core/operations/document_query.hxx +6 -0
- data/ext/couchbase/core/operations/document_remove.hxx +1 -1
- data/ext/couchbase/core/operations/document_replace.hxx +1 -1
- data/ext/couchbase/core/operations/document_search.cxx +4 -1
- data/ext/couchbase/core/operations/document_search.hxx +2 -1
- data/ext/couchbase/core/operations/document_touch.hxx +1 -1
- data/ext/couchbase/core/operations/document_unlock.hxx +1 -1
- data/ext/couchbase/core/operations/document_upsert.hxx +1 -1
- data/ext/couchbase/core/operations/document_view.hxx +1 -0
- data/ext/couchbase/core/protocol/client_request.hxx +11 -2
- data/ext/couchbase/core/public_fwd.hxx +21 -0
- data/ext/couchbase/core/tls_verify_mode.hxx +26 -0
- data/ext/couchbase/core/topology/configuration.cxx +15 -2
- data/ext/couchbase/core/topology/configuration.hxx +5 -1
- data/ext/couchbase/core/transactions/active_transaction_record.hxx +2 -2
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +3 -0
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +1 -1
- data/ext/couchbase/core/transactions/attempt_context_testing_hooks.cxx +93 -0
- data/ext/couchbase/core/transactions/attempt_context_testing_hooks.hxx +48 -75
- data/ext/couchbase/core/transactions/cleanup_testing_hooks.cxx +52 -0
- data/ext/couchbase/core/transactions/cleanup_testing_hooks.hxx +17 -31
- data/ext/couchbase/core/transactions/exceptions.hxx +12 -9
- data/ext/couchbase/core/transactions/internal/transaction_context.hxx +12 -12
- data/ext/couchbase/core/transactions/internal/transactions_cleanup.hxx +7 -1
- data/ext/couchbase/core/transactions/transaction_context.cxx +1 -0
- data/ext/couchbase/core/transactions/transactions_cleanup.cxx +144 -155
- data/ext/couchbase/core/utils/connection_string.cxx +27 -3
- data/ext/couchbase/core/utils/connection_string.hxx +3 -3
- data/ext/couchbase/core/utils/json.cxx +4 -1
- data/ext/couchbase/couchbase/analytics_error_context.hxx +143 -0
- data/ext/couchbase/couchbase/analytics_meta_data.hxx +155 -0
- data/ext/couchbase/couchbase/analytics_metrics.hxx +163 -0
- data/ext/couchbase/couchbase/analytics_options.hxx +359 -0
- data/ext/couchbase/couchbase/analytics_result.hxx +102 -0
- data/ext/couchbase/couchbase/analytics_scan_consistency.hxx +46 -0
- data/ext/couchbase/couchbase/analytics_status.hxx +41 -0
- data/ext/couchbase/couchbase/analytics_warning.hxx +85 -0
- data/ext/couchbase/couchbase/behavior_options.hxx +10 -1
- data/ext/couchbase/couchbase/boolean_field_query.hxx +77 -0
- data/ext/couchbase/couchbase/boolean_query.hxx +223 -0
- data/ext/couchbase/couchbase/cluster.hxx +75 -1
- data/ext/couchbase/couchbase/conjunction_query.hxx +88 -0
- data/ext/couchbase/couchbase/date_range.hxx +69 -0
- data/ext/couchbase/couchbase/date_range_facet.hxx +56 -0
- data/ext/couchbase/couchbase/date_range_facet_result.hxx +55 -0
- data/ext/couchbase/couchbase/date_range_query.hxx +265 -0
- data/ext/couchbase/couchbase/disjunction_query.hxx +109 -0
- data/ext/couchbase/couchbase/doc_id_query.hxx +111 -0
- data/ext/couchbase/couchbase/error_context.hxx +7 -6
- data/ext/couchbase/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
- data/ext/couchbase/couchbase/fmt/analytics_status.hxx +76 -0
- data/ext/couchbase/couchbase/fmt/search_scan_consistency.hxx +49 -0
- data/ext/couchbase/couchbase/geo_bounding_box_query.hxx +107 -0
- data/ext/couchbase/couchbase/geo_distance_query.hxx +109 -0
- data/ext/couchbase/couchbase/geo_point.hxx +32 -0
- data/ext/couchbase/couchbase/geo_polygon_query.hxx +85 -0
- data/ext/couchbase/couchbase/highlight_style.hxx +45 -0
- data/ext/couchbase/couchbase/match_all_query.hxx +43 -0
- data/ext/couchbase/couchbase/match_none_query.hxx +43 -0
- data/ext/couchbase/couchbase/match_operator.hxx +45 -0
- data/ext/couchbase/couchbase/match_phrase_query.hxx +108 -0
- data/ext/couchbase/couchbase/match_query.hxx +163 -0
- data/ext/couchbase/couchbase/numeric_range.hxx +58 -0
- data/ext/couchbase/couchbase/numeric_range_facet.hxx +56 -0
- data/ext/couchbase/couchbase/numeric_range_facet_result.hxx +55 -0
- data/ext/couchbase/couchbase/numeric_range_query.hxx +143 -0
- data/ext/couchbase/couchbase/phrase_query.hxx +93 -0
- data/ext/couchbase/couchbase/prefix_query.hxx +82 -0
- data/ext/couchbase/couchbase/query_options.hxx +0 -1
- data/ext/couchbase/couchbase/query_string_query.hxx +72 -0
- data/ext/couchbase/couchbase/regexp_query.hxx +82 -0
- data/ext/couchbase/couchbase/scope.hxx +73 -0
- data/ext/couchbase/couchbase/search_date_range.hxx +68 -0
- data/ext/couchbase/couchbase/search_error_context.hxx +138 -0
- data/ext/couchbase/couchbase/search_facet.hxx +60 -0
- data/ext/couchbase/couchbase/search_facet_result.hxx +50 -0
- data/ext/couchbase/couchbase/search_meta_data.hxx +85 -0
- data/ext/couchbase/couchbase/search_metrics.hxx +127 -0
- data/ext/couchbase/couchbase/search_numeric_range.hxx +69 -0
- data/ext/couchbase/couchbase/search_options.hxx +509 -0
- data/ext/couchbase/couchbase/search_query.hxx +69 -0
- data/ext/couchbase/couchbase/search_result.hxx +77 -0
- data/ext/couchbase/couchbase/search_row.hxx +104 -0
- data/ext/couchbase/couchbase/search_row_location.hxx +55 -0
- data/ext/couchbase/couchbase/search_row_locations.hxx +86 -0
- data/ext/couchbase/couchbase/search_scan_consistency.hxx +34 -0
- data/ext/couchbase/couchbase/search_sort.hxx +58 -0
- data/ext/couchbase/couchbase/search_sort_field.hxx +117 -0
- data/ext/couchbase/couchbase/search_sort_field_missing.hxx +26 -0
- data/ext/couchbase/couchbase/search_sort_field_mode.hxx +27 -0
- data/ext/couchbase/couchbase/search_sort_field_type.hxx +28 -0
- data/ext/couchbase/couchbase/search_sort_id.hxx +60 -0
- data/ext/couchbase/couchbase/search_sort_score.hxx +60 -0
- data/ext/couchbase/couchbase/search_term_range.hxx +51 -0
- data/ext/couchbase/couchbase/security_options.hxx +3 -0
- data/ext/couchbase/couchbase/term_facet.hxx +48 -0
- data/ext/couchbase/couchbase/term_facet_result.hxx +55 -0
- data/ext/couchbase/couchbase/term_query.hxx +151 -0
- data/ext/couchbase/couchbase/term_range_query.hxx +142 -0
- data/ext/couchbase/couchbase/tracing/request_span.hxx +63 -0
- data/ext/couchbase/couchbase/tracing/request_tracer.hxx +2 -40
- data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +83 -4
- data/ext/couchbase/couchbase/transactions/attempt_context.hxx +68 -1
- data/ext/couchbase/couchbase/transactions/transaction_get_result.hxx +2 -0
- data/ext/couchbase/couchbase/transactions/transaction_keyspace.hxx +11 -1
- data/ext/couchbase/couchbase/transactions/transaction_options.hxx +79 -8
- data/ext/couchbase/couchbase/transactions/transaction_query_options.hxx +128 -15
- data/ext/couchbase/couchbase/transactions/transaction_query_result.hxx +4 -0
- data/ext/couchbase/couchbase/transactions/transaction_result.hxx +1 -1
- data/ext/couchbase/couchbase/transactions/transactions_cleanup_config.hxx +5 -3
- data/ext/couchbase/couchbase/transactions/transactions_config.hxx +9 -5
- data/ext/couchbase/couchbase/transactions/transactions_query_config.hxx +6 -3
- data/ext/couchbase/couchbase/transactions.hxx +34 -1
- data/ext/couchbase/couchbase/wildcard_query.hxx +83 -0
- data/ext/couchbase/test/CMakeLists.txt +8 -7
- data/ext/couchbase/test/benchmark_helper_integration.hxx +2 -2
- data/ext/couchbase/test/test_helper.hxx +6 -6
- data/ext/couchbase/test/test_integration_analytics.cxx +314 -16
- data/ext/couchbase/test/test_integration_collections.cxx +7 -3
- data/ext/couchbase/test/test_integration_connect.cxx +7 -3
- data/ext/couchbase/test/test_integration_crud.cxx +19 -2
- data/ext/couchbase/test/test_integration_diagnostics.cxx +11 -5
- data/ext/couchbase/test/test_integration_durability.cxx +12 -7
- data/ext/couchbase/test/test_integration_examples.cxx +324 -11
- data/ext/couchbase/test/test_integration_management.cxx +162 -94
- data/ext/couchbase/test/test_integration_query.cxx +68 -10
- data/ext/couchbase/test/test_integration_range_scan.cxx +12 -12
- data/ext/couchbase/test/test_integration_read_replica.cxx +48 -11
- data/ext/couchbase/test/test_integration_search.cxx +621 -0
- data/ext/couchbase/test/test_integration_subdoc.cxx +62 -11
- data/ext/couchbase/test/test_integration_tracer.cxx +5 -0
- data/ext/couchbase/test/test_integration_transcoders.cxx +13 -5
- data/ext/couchbase/test/{test_transaction_transaction_context.cxx → test_transaction_context.cxx} +1 -1
- data/ext/couchbase/test/test_transaction_examples.cxx +195 -0
- data/ext/couchbase/test/{test_transaction_transaction_simple.cxx → test_transaction_simple.cxx} +90 -5
- data/ext/couchbase/test/{test_transaction_transaction_simple_async.cxx → test_transaction_simple_async.cxx} +19 -21
- data/ext/couchbase/test/test_unit_config_profiles.cxx +13 -13
- data/ext/couchbase/test/test_unit_connection_string.cxx +35 -0
- data/ext/couchbase/test/test_unit_json_transcoder.cxx +4 -0
- data/ext/couchbase/test/test_unit_search.cxx +427 -0
- data/ext/couchbase/test/test_unit_transaction_utils.cxx +10 -1
- data/ext/couchbase/test/test_unit_utils.cxx +8 -4
- data/ext/couchbase/third_party/snappy/CMakeLists.txt +150 -27
- data/ext/couchbase/third_party/snappy/cmake/config.h.in +28 -24
- data/ext/couchbase/third_party/snappy/snappy-internal.h +189 -25
- data/ext/couchbase/third_party/snappy/snappy-sinksource.cc +26 -9
- data/ext/couchbase/third_party/snappy/snappy-sinksource.h +11 -11
- data/ext/couchbase/third_party/snappy/snappy-stubs-internal.cc +1 -1
- data/ext/couchbase/third_party/snappy/snappy-stubs-internal.h +227 -308
- data/ext/couchbase/third_party/snappy/snappy-stubs-public.h.in +0 -11
- data/ext/couchbase/third_party/snappy/snappy.cc +1176 -410
- data/ext/couchbase/third_party/snappy/snappy.h +19 -4
- data/ext/couchbase.cxx +85 -22
- data/ext/revisions.rb +3 -3
- data/lib/couchbase/authenticator.rb +0 -1
- data/lib/couchbase/cluster.rb +13 -13
- data/lib/couchbase/cluster_registry.rb +7 -2
- data/lib/couchbase/config_profiles.rb +1 -1
- data/lib/couchbase/configuration.rb +3 -4
- data/lib/couchbase/json_transcoder.rb +12 -5
- data/lib/couchbase/management/collection_query_index_manager.rb +54 -15
- data/lib/couchbase/management/query_index_manager.rb +70 -5
- data/lib/couchbase/options.rb +85 -2
- data/lib/couchbase/raw_binary_transcoder.rb +37 -0
- data/lib/couchbase/raw_json_transcoder.rb +38 -0
- data/lib/couchbase/raw_string_transcoder.rb +40 -0
- data/lib/couchbase/search_options.rb +163 -240
- data/lib/couchbase/transcoder_flags.rb +62 -0
- data/lib/couchbase/version.rb +1 -1
- metadata +151 -12
- data/ext/couchbase/core/CMakeLists.txt +0 -0
- /data/ext/couchbase/test/{test_transaction_transaction_public_async_api.cxx → test_transaction_public_async_api.cxx} +0 -0
- /data/ext/couchbase/test/{test_transaction_transaction_public_blocking_api.cxx → test_transaction_public_blocking_api.cxx} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "config_profiles.hxx"
|
|
19
|
+
|
|
20
|
+
#include "cluster_options.hxx"
|
|
21
|
+
|
|
22
|
+
#include <fmt/core.h>
|
|
23
|
+
|
|
24
|
+
#include <chrono>
|
|
25
|
+
#include <stdexcept>
|
|
26
|
+
|
|
27
|
+
namespace couchbase::core
|
|
28
|
+
{
|
|
29
|
+
class development_profile : public config_profile
|
|
30
|
+
{
|
|
31
|
+
public:
|
|
32
|
+
void apply(couchbase::core::cluster_options& opts) override
|
|
33
|
+
{
|
|
34
|
+
opts.key_value_timeout = std::chrono::seconds(20);
|
|
35
|
+
opts.key_value_durable_timeout = std::chrono::seconds(20);
|
|
36
|
+
opts.connect_timeout = std::chrono::seconds(20);
|
|
37
|
+
opts.view_timeout = std::chrono::minutes(2);
|
|
38
|
+
opts.query_timeout = std::chrono::minutes(2);
|
|
39
|
+
opts.analytics_timeout = std::chrono::minutes(2);
|
|
40
|
+
opts.search_timeout = std::chrono::minutes(2);
|
|
41
|
+
opts.management_timeout = std::chrono::minutes(2);
|
|
42
|
+
|
|
43
|
+
// C++SDK specific
|
|
44
|
+
opts.dns_config = couchbase::core::io::dns::dns_config{
|
|
45
|
+
opts.dns_config.nameserver(),
|
|
46
|
+
opts.dns_config.port(),
|
|
47
|
+
std::chrono::seconds(20), // timeout to make DNS-SRV query
|
|
48
|
+
};
|
|
49
|
+
opts.resolve_timeout = std::chrono::seconds(20); // timeout to resolve hostnames
|
|
50
|
+
opts.bootstrap_timeout = std::chrono::minutes(2); // overall timeout to bootstrap
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
config_profiles::config_profiles() noexcept
|
|
55
|
+
{
|
|
56
|
+
// add all known profiles (above) to the map
|
|
57
|
+
register_profile<development_profile>("wan_development");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void
|
|
61
|
+
config_profiles::apply(const std::string& profile_name, couchbase::core::cluster_options& opts)
|
|
62
|
+
{
|
|
63
|
+
std::lock_guard<std::mutex> lock(mut_);
|
|
64
|
+
auto it = profiles_.find(profile_name);
|
|
65
|
+
if (it != profiles_.end()) {
|
|
66
|
+
it->second->apply(opts);
|
|
67
|
+
} else {
|
|
68
|
+
throw std::invalid_argument(fmt::format("unknown profile '{}'", profile_name));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
config_profiles&
|
|
73
|
+
known_profiles()
|
|
74
|
+
{
|
|
75
|
+
static config_profiles profiles{};
|
|
76
|
+
return profiles;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
} // namespace couchbase::core
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "cluster_options_fwd.hxx"
|
|
20
|
+
#include "config_profile.hxx"
|
|
21
|
+
|
|
22
|
+
#include <map>
|
|
23
|
+
#include <memory>
|
|
24
|
+
#include <mutex>
|
|
25
|
+
#include <string>
|
|
26
|
+
|
|
27
|
+
namespace couchbase::core
|
|
28
|
+
{
|
|
29
|
+
// this class just registers the known profiles defined above, and allows access to them.
|
|
30
|
+
class config_profiles
|
|
31
|
+
{
|
|
32
|
+
private:
|
|
33
|
+
std::map<std::string, std::shared_ptr<config_profile>, std::less<>> profiles_;
|
|
34
|
+
mutable std::mutex mut_;
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
config_profiles() noexcept;
|
|
38
|
+
|
|
39
|
+
void apply(const std::string& profile_name, couchbase::core::cluster_options& opts);
|
|
40
|
+
|
|
41
|
+
template<typename T, typename... Args>
|
|
42
|
+
void register_profile(const std::string& name, Args... args)
|
|
43
|
+
{
|
|
44
|
+
// This will just add it, doesn't look to see if it is overwriting an existing profile.
|
|
45
|
+
// TODO: perhaps add a template Args param?
|
|
46
|
+
// TODO: should we make this thread-safe? Easy enough here, but we'd need to make the
|
|
47
|
+
// singleton thread-safe too.
|
|
48
|
+
const std::scoped_lock lock(mut_);
|
|
49
|
+
profiles_.emplace(std::make_pair(name, std::make_shared<T>(args...)));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
config_profiles&
|
|
54
|
+
known_profiles();
|
|
55
|
+
|
|
56
|
+
} // namespace couchbase::core
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020-Present Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <couchbase/cluster.hxx>
|
|
19
|
+
#include <couchbase/error_codes.hxx>
|
|
20
|
+
#include <couchbase/scope.hxx>
|
|
21
|
+
|
|
22
|
+
#include "core/cluster.hxx"
|
|
23
|
+
#include "core/operations/document_analytics.hxx"
|
|
24
|
+
|
|
25
|
+
namespace couchbase
|
|
26
|
+
{
|
|
27
|
+
static analytics_error_context
|
|
28
|
+
build_context(core::operations::analytics_response& resp)
|
|
29
|
+
{
|
|
30
|
+
return {
|
|
31
|
+
resp.ctx.ec,
|
|
32
|
+
resp.ctx.last_dispatched_to,
|
|
33
|
+
resp.ctx.last_dispatched_from,
|
|
34
|
+
resp.ctx.retry_attempts,
|
|
35
|
+
std::move(resp.ctx.retry_reasons),
|
|
36
|
+
resp.ctx.first_error_code,
|
|
37
|
+
std::move(resp.ctx.first_error_message),
|
|
38
|
+
std::move(resp.ctx.client_context_id),
|
|
39
|
+
std::move(resp.ctx.statement),
|
|
40
|
+
std::move(resp.ctx.parameters),
|
|
41
|
+
std::move(resp.ctx.method),
|
|
42
|
+
std::move(resp.ctx.path),
|
|
43
|
+
resp.ctx.http_status,
|
|
44
|
+
std::move(resp.ctx.http_body),
|
|
45
|
+
std::move(resp.ctx.hostname),
|
|
46
|
+
resp.ctx.port,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static analytics_status
|
|
51
|
+
map_status(core::operations::analytics_response::analytics_status status)
|
|
52
|
+
{
|
|
53
|
+
switch (status) {
|
|
54
|
+
case core::operations::analytics_response::running:
|
|
55
|
+
return analytics_status::running;
|
|
56
|
+
case core::operations::analytics_response::success:
|
|
57
|
+
return analytics_status::success;
|
|
58
|
+
case core::operations::analytics_response::errors:
|
|
59
|
+
return analytics_status::errors;
|
|
60
|
+
case core::operations::analytics_response::completed:
|
|
61
|
+
return analytics_status::completed;
|
|
62
|
+
case core::operations::analytics_response::stopped:
|
|
63
|
+
return analytics_status::stopped;
|
|
64
|
+
case core::operations::analytics_response::timedout:
|
|
65
|
+
return analytics_status::timeout;
|
|
66
|
+
case core::operations::analytics_response::closed:
|
|
67
|
+
return analytics_status::closed;
|
|
68
|
+
case core::operations::analytics_response::fatal:
|
|
69
|
+
return analytics_status::fatal;
|
|
70
|
+
case core::operations::analytics_response::aborted:
|
|
71
|
+
return analytics_status::aborted;
|
|
72
|
+
case core::operations::analytics_response::unknown:
|
|
73
|
+
return analytics_status::unknown;
|
|
74
|
+
}
|
|
75
|
+
return analytics_status::unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static std::optional<couchbase::core::analytics_scan_consistency>
|
|
79
|
+
map_scan_consistency(std::optional<couchbase::analytics_scan_consistency> consistency)
|
|
80
|
+
{
|
|
81
|
+
if (consistency.has_value()) {
|
|
82
|
+
switch (consistency.value()) {
|
|
83
|
+
case analytics_scan_consistency::not_bounded:
|
|
84
|
+
return couchbase::core::analytics_scan_consistency::not_bounded;
|
|
85
|
+
case analytics_scan_consistency::request_plus:
|
|
86
|
+
return couchbase::core::analytics_scan_consistency::request_plus;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static std::vector<codec::binary>
|
|
93
|
+
map_rows(const core::operations::analytics_response& resp)
|
|
94
|
+
{
|
|
95
|
+
std::vector<codec::binary> rows;
|
|
96
|
+
rows.reserve(resp.rows.size());
|
|
97
|
+
for (const auto& row : resp.rows) {
|
|
98
|
+
rows.emplace_back(core::utils::to_binary(row));
|
|
99
|
+
}
|
|
100
|
+
return rows;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static std::vector<analytics_warning>
|
|
104
|
+
map_warnings(core::operations::analytics_response& resp)
|
|
105
|
+
{
|
|
106
|
+
if (resp.meta.warnings.empty()) {
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
109
|
+
std::vector<analytics_warning> warnings;
|
|
110
|
+
warnings.reserve(resp.meta.warnings.size());
|
|
111
|
+
for (auto& warning : resp.meta.warnings) {
|
|
112
|
+
warnings.emplace_back(warning.code, std::move(warning.message));
|
|
113
|
+
}
|
|
114
|
+
return warnings;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static analytics_metrics
|
|
118
|
+
map_metrics(const core::operations::analytics_response& resp)
|
|
119
|
+
{
|
|
120
|
+
return analytics_metrics{
|
|
121
|
+
resp.meta.metrics.elapsed_time, resp.meta.metrics.execution_time, resp.meta.metrics.result_count,
|
|
122
|
+
resp.meta.metrics.result_size, resp.meta.metrics.processed_objects, resp.meta.metrics.error_count,
|
|
123
|
+
resp.meta.metrics.warning_count,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static std::optional<std::vector<std::byte>>
|
|
128
|
+
map_signature(core::operations::analytics_response& resp)
|
|
129
|
+
{
|
|
130
|
+
if (!resp.meta.signature) {
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
return core::utils::to_binary(resp.meta.signature.value());
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static analytics_result
|
|
137
|
+
build_result(core::operations::analytics_response& resp)
|
|
138
|
+
{
|
|
139
|
+
return {
|
|
140
|
+
analytics_meta_data{
|
|
141
|
+
std::move(resp.meta.request_id),
|
|
142
|
+
std::move(resp.meta.client_context_id),
|
|
143
|
+
map_status(resp.meta.status),
|
|
144
|
+
map_warnings(resp),
|
|
145
|
+
map_metrics(resp),
|
|
146
|
+
map_signature(resp),
|
|
147
|
+
},
|
|
148
|
+
map_rows(resp),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static core::operations::analytics_request
|
|
153
|
+
build_analytics_request(std::string statement,
|
|
154
|
+
analytics_options::built options,
|
|
155
|
+
std::optional<std::string> bucket_name,
|
|
156
|
+
std::optional<std::string> scope_name)
|
|
157
|
+
{
|
|
158
|
+
core::operations::analytics_request request{
|
|
159
|
+
std::move(statement),
|
|
160
|
+
options.readonly,
|
|
161
|
+
options.priority,
|
|
162
|
+
std::move(bucket_name),
|
|
163
|
+
std::move(scope_name),
|
|
164
|
+
{},
|
|
165
|
+
map_scan_consistency(options.scan_consistency),
|
|
166
|
+
{},
|
|
167
|
+
{},
|
|
168
|
+
{},
|
|
169
|
+
{},
|
|
170
|
+
std::move(options.client_context_id),
|
|
171
|
+
options.timeout,
|
|
172
|
+
};
|
|
173
|
+
if (!options.raw.empty()) {
|
|
174
|
+
for (auto& [name, value] : options.raw) {
|
|
175
|
+
request.raw[name] = std::move(value);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!options.positional_parameters.empty()) {
|
|
179
|
+
for (auto& value : options.positional_parameters) {
|
|
180
|
+
request.positional_parameters.emplace_back(std::move(value));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!options.named_parameters.empty()) {
|
|
184
|
+
for (auto& [name, value] : options.named_parameters) {
|
|
185
|
+
request.named_parameters[name] = std::move(value);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return request;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void
|
|
192
|
+
cluster::analytics_query(std::string statement, const analytics_options& options, analytics_handler&& handler) const
|
|
193
|
+
{
|
|
194
|
+
auto request = build_analytics_request(std::move(statement), options.build(), {}, {});
|
|
195
|
+
|
|
196
|
+
core_->execute(std::move(request), [handler = std::move(handler)](core::operations::analytics_response resp) mutable {
|
|
197
|
+
auto r = std::move(resp);
|
|
198
|
+
return handler(build_context(r), build_result(r));
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
auto
|
|
203
|
+
cluster::analytics_query(std::string statement, const analytics_options& options) const
|
|
204
|
+
-> std::future<std::pair<analytics_error_context, analytics_result>>
|
|
205
|
+
{
|
|
206
|
+
auto barrier = std::make_shared<std::promise<std::pair<analytics_error_context, analytics_result>>>();
|
|
207
|
+
auto future = barrier->get_future();
|
|
208
|
+
analytics_query(std::move(statement), options, [barrier](auto ctx, auto result) {
|
|
209
|
+
barrier->set_value({ std::move(ctx), std::move(result) });
|
|
210
|
+
});
|
|
211
|
+
return future;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void
|
|
215
|
+
scope::analytics_query(std::string statement, const analytics_options& options, analytics_handler&& handler) const
|
|
216
|
+
{
|
|
217
|
+
auto request = build_analytics_request(std::move(statement), options.build(), bucket_name_, name_);
|
|
218
|
+
|
|
219
|
+
core_->execute(std::move(request), [handler = std::move(handler)](core::operations::analytics_response resp) mutable {
|
|
220
|
+
auto r = std::move(resp);
|
|
221
|
+
return handler(build_context(r), build_result(r));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
auto
|
|
226
|
+
scope::analytics_query(std::string statement, const analytics_options& options) const
|
|
227
|
+
-> std::future<std::pair<analytics_error_context, analytics_result>>
|
|
228
|
+
{
|
|
229
|
+
auto barrier = std::make_shared<std::promise<std::pair<analytics_error_context, analytics_result>>>();
|
|
230
|
+
auto future = barrier->get_future();
|
|
231
|
+
analytics_query(std::move(statement), options, [barrier](auto ctx, auto result) {
|
|
232
|
+
barrier->set_value({ std::move(ctx), std::move(result) });
|
|
233
|
+
});
|
|
234
|
+
return future;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023-Present Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "encoded_search_query.hxx"
|
|
19
|
+
|
|
20
|
+
#include <couchbase/boolean_field_query.hxx>
|
|
21
|
+
|
|
22
|
+
namespace couchbase
|
|
23
|
+
{
|
|
24
|
+
auto
|
|
25
|
+
boolean_field_query::encode() const -> encoded_search_query
|
|
26
|
+
{
|
|
27
|
+
encoded_search_query built;
|
|
28
|
+
|
|
29
|
+
built.query = tao::json::empty_object;
|
|
30
|
+
if (boost_) {
|
|
31
|
+
built.query["boost"] = boost_.value();
|
|
32
|
+
}
|
|
33
|
+
built.query["bool"] = bool_;
|
|
34
|
+
if (field_) {
|
|
35
|
+
built.query["field"] = field_.value();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return built;
|
|
39
|
+
}
|
|
40
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023-Present Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "encoded_search_query.hxx"
|
|
19
|
+
|
|
20
|
+
#include <couchbase/boolean_query.hxx>
|
|
21
|
+
|
|
22
|
+
#include <couchbase/error_codes.hxx>
|
|
23
|
+
|
|
24
|
+
namespace couchbase
|
|
25
|
+
{
|
|
26
|
+
auto
|
|
27
|
+
boolean_query::encode() const -> encoded_search_query
|
|
28
|
+
{
|
|
29
|
+
if (!must_ && !should_ && !must_not_) {
|
|
30
|
+
return { errc::common::invalid_argument };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
encoded_search_query built;
|
|
34
|
+
built.query = tao::json::empty_object;
|
|
35
|
+
if (boost_) {
|
|
36
|
+
built.query["boost"] = boost_.value();
|
|
37
|
+
}
|
|
38
|
+
if (must_) {
|
|
39
|
+
auto encoded = must_->encode();
|
|
40
|
+
if (encoded.ec) {
|
|
41
|
+
return { encoded.ec };
|
|
42
|
+
}
|
|
43
|
+
built.query["must"] = encoded.query;
|
|
44
|
+
}
|
|
45
|
+
if (must_not_) {
|
|
46
|
+
auto encoded = must_not_->encode();
|
|
47
|
+
if (encoded.ec) {
|
|
48
|
+
return { encoded.ec };
|
|
49
|
+
}
|
|
50
|
+
built.query["must_not"] = encoded.query;
|
|
51
|
+
}
|
|
52
|
+
if (should_) {
|
|
53
|
+
auto encoded = should_->encode();
|
|
54
|
+
if (encoded.ec) {
|
|
55
|
+
return { encoded.ec };
|
|
56
|
+
}
|
|
57
|
+
built.query["should"] = encoded.query;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return built;
|
|
61
|
+
}
|
|
62
|
+
} // namespace couchbase
|
|
@@ -90,15 +90,16 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
|
|
|
90
90
|
user_options.tls_verify = core::tls_verify_mode::peer;
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
|
+
user_options.disable_mozilla_ca_certificates = opts.security.disable_mozilla_ca_certificates;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
if (opts.dns.nameserver) {
|
|
96
97
|
user_options.dns_config =
|
|
97
98
|
io::dns::dns_config(opts.dns.nameserver.value(), opts.dns.port.value_or(io::dns::dns_config::default_port), opts.dns.timeout);
|
|
98
|
-
user_options.dns_srv_timeout = opts.dns.timeout;
|
|
99
99
|
}
|
|
100
100
|
user_options.enable_clustermap_notification = opts.behavior.enable_clustermap_notification;
|
|
101
101
|
user_options.show_queries = opts.behavior.show_queries;
|
|
102
|
+
user_options.dump_configuration = opts.behavior.dump_configuration;
|
|
102
103
|
user_options.enable_mutation_tokens = opts.behavior.enable_mutation_tokens;
|
|
103
104
|
user_options.enable_unordered_execution = opts.behavior.enable_unordered_execution;
|
|
104
105
|
user_options.user_agent_extra = opts.behavior.user_agent_extra;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023-Present Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "encoded_search_query.hxx"
|
|
19
|
+
|
|
20
|
+
#include <couchbase/conjunction_query.hxx>
|
|
21
|
+
|
|
22
|
+
#include <couchbase/error_codes.hxx>
|
|
23
|
+
|
|
24
|
+
namespace couchbase
|
|
25
|
+
{
|
|
26
|
+
auto
|
|
27
|
+
conjunction_query::encode() const -> encoded_search_query
|
|
28
|
+
{
|
|
29
|
+
if (conjuncts_.empty()) {
|
|
30
|
+
return { errc::common::invalid_argument };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
encoded_search_query built;
|
|
34
|
+
built.query = tao::json::empty_object;
|
|
35
|
+
if (boost_) {
|
|
36
|
+
built.query["boost"] = boost_.value();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
tao::json::value conjuncts = tao::json::empty_array;
|
|
40
|
+
for (const auto& conjunct : conjuncts_) {
|
|
41
|
+
auto encoded = conjunct->encode();
|
|
42
|
+
if (encoded.ec) {
|
|
43
|
+
return { encoded.ec };
|
|
44
|
+
}
|
|
45
|
+
conjuncts.push_back(encoded.query);
|
|
46
|
+
}
|
|
47
|
+
built.query["conjuncts"] = conjuncts;
|
|
48
|
+
|
|
49
|
+
return built;
|
|
50
|
+
}
|
|
51
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020-Present Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <couchbase/date_range.hxx>
|
|
19
|
+
|
|
20
|
+
#include <fmt/chrono.h>
|
|
21
|
+
|
|
22
|
+
namespace couchbase
|
|
23
|
+
{
|
|
24
|
+
static constexpr const char* iso_8601_format = "{:%Y-%m-%dT%H:%M:%S%z}";
|
|
25
|
+
|
|
26
|
+
date_range::date_range(std::string name, std::string start, std::string end)
|
|
27
|
+
: name_{ std::move(name) }
|
|
28
|
+
, start_{ std::move(start) }
|
|
29
|
+
, end_{ std::move(end) }
|
|
30
|
+
{
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
date_range::date_range(std::string name, std::chrono::system_clock::time_point start, std::chrono::system_clock::time_point end)
|
|
34
|
+
: name_{ std::move(name) }
|
|
35
|
+
, start_{ fmt::format(iso_8601_format, start) }
|
|
36
|
+
, end_{ fmt::format(iso_8601_format, end) }
|
|
37
|
+
{
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
date_range::date_range(std::string name, std::tm start, std::tm end)
|
|
41
|
+
: name_{ std::move(name) }
|
|
42
|
+
, start_{ fmt::format(iso_8601_format, start) }
|
|
43
|
+
, end_{ fmt::format(iso_8601_format, end) }
|
|
44
|
+
{
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
date_range::date_range(std::string name, std::optional<std::string> start, std::optional<std::string> end)
|
|
48
|
+
: name_{ std::move(name) }
|
|
49
|
+
, start_{ std::move(start) }
|
|
50
|
+
, end_{ std::move(end) }
|
|
51
|
+
{
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
date_range
|
|
55
|
+
date_range::with_start(std::string name, std::string start)
|
|
56
|
+
{
|
|
57
|
+
return { std::move(name), std::move(start), {} };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
date_range
|
|
61
|
+
date_range::with_start(std::string name, std::chrono::system_clock::time_point start)
|
|
62
|
+
{
|
|
63
|
+
return { std::move(name), fmt::format(iso_8601_format, start), {} };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
date_range
|
|
67
|
+
date_range::with_start(std::string name, std::tm start)
|
|
68
|
+
{
|
|
69
|
+
return { std::move(name), fmt::format(iso_8601_format, start), {} };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
date_range
|
|
73
|
+
date_range::with_end(std::string name, std::string end)
|
|
74
|
+
{
|
|
75
|
+
return { std::move(name), {}, std::move(end) };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
date_range
|
|
79
|
+
date_range::with_end(std::string name, std::chrono::system_clock::time_point end)
|
|
80
|
+
{
|
|
81
|
+
return { std::move(name), {}, fmt::format(iso_8601_format, end) };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
date_range
|
|
85
|
+
date_range::with_end(std::string name, std::tm end)
|
|
86
|
+
{
|
|
87
|
+
return { std::move(name), {}, fmt::format(iso_8601_format, end) };
|
|
88
|
+
}
|
|
89
|
+
} // namespace couchbase
|