couchbase 3.4.2 → 3.4.4
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 +71 -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/build_config.hxx.in +3 -0
- data/ext/couchbase/core/bucket.cxx +183 -151
- data/ext/couchbase/core/bucket.hxx +23 -1
- data/ext/couchbase/core/cluster.hxx +51 -13
- data/ext/couchbase/core/cluster_options.cxx +2 -2
- data/ext/couchbase/core/cluster_options.hxx +7 -6
- data/ext/couchbase/core/cluster_options_fwd.hxx +26 -0
- data/ext/couchbase/core/config_profile.hxx +1 -54
- data/ext/couchbase/core/config_profiles.cxx +79 -0
- data/ext/couchbase/core/config_profiles.hxx +56 -0
- data/ext/couchbase/core/crud_component.cxx +51 -22
- data/ext/couchbase/core/error_context/key_value.cxx +2 -1
- data/ext/couchbase/core/error_context/key_value.hxx +10 -12
- data/ext/couchbase/core/error_context/search.hxx +1 -1
- data/ext/couchbase/core/impl/analytics.cxx +1 -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/build_deferred_query_indexes.cxx +115 -50
- data/ext/couchbase/core/impl/cluster.cxx +8 -0
- data/ext/couchbase/core/impl/conjunction_query.cxx +51 -0
- data/ext/couchbase/core/impl/create_bucket.cxx +155 -0
- data/ext/couchbase/core/impl/create_query_index.cxx +172 -59
- 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 +2 -1
- data/ext/couchbase/core/impl/drop_bucket.cxx +66 -0
- data/ext/couchbase/core/impl/drop_query_index.cxx +138 -59
- 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/flush_bucket.cxx +66 -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/get_all_buckets.cxx +163 -0
- data/ext/couchbase/core/impl/get_all_query_indexes.cxx +67 -37
- data/ext/couchbase/core/impl/get_bucket.cxx +153 -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_manager_error_context.cxx +113 -0
- data/ext/couchbase/core/impl/internal_manager_error_context.hxx +60 -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/key_value_error_category.cxx +2 -4
- data/ext/couchbase/core/impl/key_value_error_context.cxx +98 -0
- data/ext/couchbase/core/impl/lookup_in.cxx +1 -0
- data/ext/couchbase/core/impl/lookup_in_all_replicas.cxx +176 -0
- data/ext/couchbase/core/impl/lookup_in_all_replicas.hxx +80 -0
- data/ext/couchbase/core/impl/lookup_in_any_replica.cxx +167 -0
- data/ext/couchbase/core/impl/lookup_in_any_replica.hxx +75 -0
- data/ext/couchbase/core/impl/lookup_in_replica.cxx +97 -0
- data/ext/couchbase/core/impl/lookup_in_replica.hxx +67 -0
- data/ext/couchbase/core/impl/manager_error_context.cxx +100 -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 +1 -0
- data/ext/couchbase/core/impl/query_error_context.cxx +75 -0
- 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/update_bucket.cxx +130 -0
- data/ext/couchbase/core/impl/watch_query_indexes.cxx +53 -29
- data/ext/couchbase/core/impl/wildcard_query.cxx +40 -0
- data/ext/couchbase/core/io/dns_client.cxx +111 -40
- data/ext/couchbase/core/io/dns_config.cxx +5 -4
- data/ext/couchbase/core/io/http_context.hxx +1 -1
- data/ext/couchbase/core/io/http_session.hxx +34 -1
- data/ext/couchbase/core/io/http_session_manager.hxx +5 -3
- data/ext/couchbase/core/io/mcbp_command.hxx +9 -2
- data/ext/couchbase/core/io/mcbp_session.cxx +106 -42
- data/ext/couchbase/core/io/mcbp_session.hxx +4 -3
- data/ext/couchbase/core/io/retry_orchestrator.hxx +3 -2
- data/ext/couchbase/core/json_string.hxx +5 -0
- data/ext/couchbase/core/logger/custom_rotating_file_sink.cxx +1 -1
- data/ext/couchbase/core/logger/logger.cxx +80 -20
- data/ext/couchbase/core/logger/logger.hxx +31 -0
- data/ext/couchbase/core/meta/features.hxx +25 -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_lookup_in_all_replicas.hxx +192 -0
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +188 -0
- 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 +13 -0
- data/ext/couchbase/core/operations/document_query.hxx +7 -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/operations.hxx +2 -0
- data/ext/couchbase/core/origin.cxx +270 -0
- data/ext/couchbase/core/origin.hxx +2 -0
- data/ext/couchbase/core/protocol/client_request.hxx +11 -2
- data/ext/couchbase/core/protocol/client_response.hxx +1 -0
- data/ext/couchbase/core/protocol/cmd_hello.hxx +1 -0
- data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +107 -0
- data/ext/couchbase/core/protocol/cmd_lookup_in_replica.hxx +137 -0
- data/ext/couchbase/core/protocol/hello_feature.hxx +6 -0
- data/ext/couchbase/core/protocol/hello_feature_fmt.hxx +3 -0
- data/ext/couchbase/core/protocol/status.cxx +2 -2
- data/ext/couchbase/core/public_fwd.hxx +21 -0
- data/ext/couchbase/core/range_scan_options.cxx +3 -27
- data/ext/couchbase/core/range_scan_options.hxx +13 -17
- data/ext/couchbase/core/range_scan_orchestrator.cxx +388 -170
- data/ext/couchbase/core/range_scan_orchestrator.hxx +13 -2
- data/ext/couchbase/core/range_scan_orchestrator_options.hxx +5 -3
- data/ext/couchbase/core/scan_options.hxx +0 -19
- data/ext/couchbase/core/scan_result.cxx +19 -5
- data/ext/couchbase/core/scan_result.hxx +5 -2
- data/ext/couchbase/core/timeout_defaults.hxx +2 -3
- data/ext/couchbase/core/tls_verify_mode.hxx +26 -0
- data/ext/couchbase/core/topology/capabilities.hxx +3 -0
- data/ext/couchbase/core/topology/capabilities_fmt.hxx +8 -0
- data/ext/couchbase/core/topology/collections_manifest_fmt.hxx +1 -1
- data/ext/couchbase/core/topology/configuration.cxx +15 -2
- data/ext/couchbase/core/topology/configuration.hxx +20 -1
- data/ext/couchbase/core/topology/configuration_json.hxx +6 -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/utils/connection_string.cxx +75 -43
- data/ext/couchbase/core/utils/connection_string.hxx +1 -0
- data/ext/couchbase/core/utils/json.cxx +4 -1
- data/ext/couchbase/couchbase/analytics_error_context.hxx +1 -1
- data/ext/couchbase/couchbase/behavior_options.hxx +27 -1
- data/ext/couchbase/couchbase/boolean_field_query.hxx +77 -0
- data/ext/couchbase/couchbase/boolean_query.hxx +223 -0
- data/ext/couchbase/couchbase/bucket_manager.hxx +135 -0
- data/ext/couchbase/couchbase/build_query_index_options.hxx +0 -30
- data/ext/couchbase/couchbase/cluster.hxx +56 -1
- data/ext/couchbase/couchbase/collection.hxx +111 -0
- data/ext/couchbase/couchbase/collection_query_index_manager.hxx +7 -48
- data/ext/couchbase/couchbase/conjunction_query.hxx +88 -0
- data/ext/couchbase/couchbase/create_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/create_primary_query_index_options.hxx +0 -29
- data/ext/couchbase/couchbase/create_query_index_options.hxx +0 -33
- 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/drop_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/drop_primary_query_index_options.hxx +0 -30
- data/ext/couchbase/couchbase/drop_query_index_options.hxx +0 -31
- data/ext/couchbase/couchbase/error_codes.hxx +1 -2
- data/ext/couchbase/couchbase/error_context.hxx +17 -8
- data/ext/couchbase/couchbase/flush_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
- data/ext/couchbase/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
- 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/get_all_buckets_options.hxx +44 -0
- data/ext/couchbase/couchbase/get_all_query_indexes_options.hxx +0 -30
- data/ext/couchbase/couchbase/get_and_lock_options.hxx +2 -2
- data/ext/couchbase/couchbase/get_and_touch_options.hxx +2 -2
- data/ext/couchbase/couchbase/get_bucket_options.hxx +43 -0
- data/ext/couchbase/couchbase/get_options.hxx +2 -2
- data/ext/couchbase/couchbase/highlight_style.hxx +45 -0
- data/ext/couchbase/couchbase/insert_options.hxx +3 -3
- data/ext/couchbase/couchbase/key_value_error_context.hxx +7 -2
- data/ext/couchbase/couchbase/lookup_in_all_replicas_options.hxx +109 -0
- data/ext/couchbase/couchbase/lookup_in_any_replica_options.hxx +101 -0
- data/ext/couchbase/couchbase/lookup_in_options.hxx +2 -2
- data/ext/couchbase/couchbase/lookup_in_replica_result.hxx +74 -0
- data/ext/couchbase/couchbase/lookup_in_result.hxx +26 -0
- data/ext/couchbase/couchbase/management/bucket_settings.hxx +116 -0
- data/ext/couchbase/couchbase/manager_error_context.hxx +29 -53
- 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/mutate_in_options.hxx +2 -2
- 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_error_context.hxx +3 -1
- data/ext/couchbase/couchbase/query_index_manager.hxx +16 -83
- data/ext/couchbase/couchbase/query_options.hxx +18 -0
- data/ext/couchbase/couchbase/query_string_query.hxx +72 -0
- data/ext/couchbase/couchbase/regexp_query.hxx +82 -0
- data/ext/couchbase/couchbase/remove_options.hxx +2 -2
- data/ext/couchbase/couchbase/replace_options.hxx +3 -3
- data/ext/couchbase/couchbase/scope.hxx +40 -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 +18 -0
- data/ext/couchbase/couchbase/subdocument_error_context.hxx +4 -2
- 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/touch_options.hxx +2 -2
- 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 +67 -0
- 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/unlock_options.hxx +2 -2
- data/ext/couchbase/couchbase/update_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/upsert_options.hxx +3 -3
- data/ext/couchbase/couchbase/watch_query_indexes_options.hxx +0 -31
- data/ext/couchbase/couchbase/wildcard_query.hxx +83 -0
- data/ext/couchbase/test/CMakeLists.txt +8 -5
- data/ext/couchbase/test/benchmark_helper_integration.hxx +2 -2
- data/ext/couchbase/test/test_helper.hxx +5 -5
- data/ext/couchbase/test/test_integration_analytics.cxx +28 -6
- data/ext/couchbase/test/test_integration_collections.cxx +13 -3
- data/ext/couchbase/test/test_integration_connect.cxx +7 -3
- data/ext/couchbase/test/test_integration_crud.cxx +18 -3
- 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 +419 -11
- data/ext/couchbase/test/test_integration_management.cxx +867 -368
- data/ext/couchbase/test/test_integration_query.cxx +87 -17
- data/ext/couchbase/test/test_integration_range_scan.cxx +363 -124
- data/ext/couchbase/test/test_integration_read_replica.cxx +48 -11
- data/ext/couchbase/test/test_integration_search.cxx +32 -3
- data/ext/couchbase/test/test_integration_subdoc.cxx +717 -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_public_async_api.cxx → test_transaction_public_async_api.cxx} +13 -12
- data/ext/couchbase/test/{test_transaction_transaction_public_blocking_api.cxx → test_transaction_public_blocking_api.cxx} +27 -21
- data/ext/couchbase/test/{test_transaction_transaction_simple.cxx → test_transaction_simple.cxx} +17 -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 +1 -1
- data/ext/couchbase/test/test_unit_connection_string.cxx +29 -0
- data/ext/couchbase/test/test_unit_json_transcoder.cxx +4 -0
- data/ext/couchbase/test/test_unit_query.cxx +75 -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.cxx +641 -45
- data/ext/revisions.rb +3 -3
- data/lib/couchbase/authenticator.rb +0 -1
- data/lib/couchbase/cluster.rb +1 -5
- data/lib/couchbase/collection.rb +108 -0
- data/lib/couchbase/collection_options.rb +100 -0
- data/lib/couchbase/config_profiles.rb +1 -1
- data/lib/couchbase/errors.rb +5 -0
- data/lib/couchbase/json_transcoder.rb +12 -5
- data/lib/couchbase/key_value_scan.rb +125 -0
- 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 +151 -0
- 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/scope.rb +1 -1
- data/lib/couchbase/search_options.rb +5 -0
- data/lib/couchbase/transcoder_flags.rb +62 -0
- data/lib/couchbase/utils/time.rb +14 -1
- data/lib/couchbase/version.rb +1 -1
- metadata +175 -13
- data/ext/couchbase/core/config_profile.cxx +0 -47
- data/ext/couchbase/core/impl/collection_query_index_manager.cxx +0 -93
|
@@ -17,10 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
#include "version.hxx"
|
|
19
19
|
|
|
20
|
+
#include "core/mozilla_ca_bundle.hxx"
|
|
20
21
|
#include "core/transactions/forward_compat.hxx"
|
|
21
22
|
#include "core/utils/join_strings.hxx"
|
|
22
23
|
#include "core/utils/json.hxx"
|
|
23
24
|
|
|
25
|
+
#include <couchbase/build_config.hxx>
|
|
24
26
|
#include <couchbase/build_info.hxx>
|
|
25
27
|
#include <couchbase/build_version.hxx>
|
|
26
28
|
|
|
@@ -76,7 +78,7 @@ sdk_build_info()
|
|
|
76
78
|
info["link_libraries"] = COUCHBASE_CXX_CLIENT_LINK_LIBRARIES;
|
|
77
79
|
info["link_options"] = COUCHBASE_CXX_CLIENT_LINK_OPTIONS;
|
|
78
80
|
info["static_stdlib"] =
|
|
79
|
-
#if defined(
|
|
81
|
+
#if defined(COUCHBASE_CXX_CLIENT_STATIC_STDLIB)
|
|
80
82
|
"true"
|
|
81
83
|
#else
|
|
82
84
|
"false"
|
|
@@ -84,7 +86,7 @@ sdk_build_info()
|
|
|
84
86
|
;
|
|
85
87
|
info["post_linked_openssl"] = COUCHBASE_CXX_CLIENT_POST_LINKED_OPENSSL;
|
|
86
88
|
info["static_openssl"] =
|
|
87
|
-
#if defined(
|
|
89
|
+
#if defined(COUCHBASE_CXX_CLIENT_STATIC_OPENSSL)
|
|
88
90
|
"true"
|
|
89
91
|
#else
|
|
90
92
|
"false"
|
|
@@ -112,8 +114,19 @@ sdk_build_info()
|
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
#endif
|
|
117
|
+
|
|
118
|
+
#if defined(COUCHBASE_CXX_CLIENT_EMBED_MOZILLA_CA_BUNDLE)
|
|
119
|
+
info["mozilla_ca_bundle_embedded"] = "true";
|
|
120
|
+
info["mozilla_ca_bundle_sha256"] = COUCHBASE_CXX_CLIENT_MOZILLA_CA_BUNDLE_SHA256;
|
|
121
|
+
info["mozilla_ca_bundle_date"] = COUCHBASE_CXX_CLIENT_MOZILLA_CA_BUNDLE_DATE;
|
|
122
|
+
#else
|
|
123
|
+
info["mozilla_ca_bundle_embedded"] = "false";
|
|
124
|
+
#endif
|
|
125
|
+
info["mozilla_ca_bundle_size"] = std::to_string(default_ca::mozilla_ca_certs().size());
|
|
115
126
|
info["openssl_default_cert_dir"] = X509_get_default_cert_dir();
|
|
116
127
|
info["openssl_default_cert_file"] = X509_get_default_cert_file();
|
|
128
|
+
info["openssl_default_cert_dir_env"] = X509_get_default_cert_dir_env();
|
|
129
|
+
info["openssl_default_cert_file_env"] = X509_get_default_cert_file_env();
|
|
117
130
|
info["openssl_ssl_interface_include_directories"] = OPENSSL_SSL_INTERFACE_INCLUDE_DIRECTORIES;
|
|
118
131
|
info["openssl_ssl_interface_link_libraries"] = OPENSSL_SSL_INTERFACE_LINK_LIBRARIES;
|
|
119
132
|
info["openssl_ssl_imported_location"] = OPENSSL_SSL_IMPORTED_LOCATION;
|
|
@@ -138,9 +151,10 @@ sdk_build_info_json()
|
|
|
138
151
|
{
|
|
139
152
|
tao::json::value info;
|
|
140
153
|
for (const auto& [name, value] : sdk_build_info()) {
|
|
141
|
-
if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build"
|
|
154
|
+
if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build" ||
|
|
155
|
+
name == "mozilla_ca_bundle_size") {
|
|
142
156
|
info[name] = std::stoi(value);
|
|
143
|
-
} else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl") {
|
|
157
|
+
} else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl" || name == "mozilla_ca_bundle_embedded") {
|
|
144
158
|
info[name] = value == "true";
|
|
145
159
|
} else {
|
|
146
160
|
info[name] = value;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include <array>
|
|
21
|
+
#include <gsl/span>
|
|
22
|
+
#include <string_view>
|
|
23
|
+
|
|
24
|
+
namespace couchbase::core::default_ca
|
|
25
|
+
{
|
|
26
|
+
struct certificate {
|
|
27
|
+
std::string_view authority;
|
|
28
|
+
std::string_view body;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
auto
|
|
32
|
+
mozilla_ca_certs() -> gsl::span<const certificate>;
|
|
33
|
+
|
|
34
|
+
auto
|
|
35
|
+
mozilla_ca_certs_date() -> std::string_view;
|
|
36
|
+
|
|
37
|
+
auto
|
|
38
|
+
mozilla_ca_certs_sha256() -> std::string_view;
|
|
39
|
+
} // namespace couchbase::core::default_ca
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
#include "core/operations/operation_traits.hxx"
|
|
26
26
|
#include "core/protocol/client_request.hxx"
|
|
27
27
|
#include "core/protocol/cmd_append.hxx"
|
|
28
|
+
#include "core/public_fwd.hxx"
|
|
28
29
|
#include "core/timeout_defaults.hxx"
|
|
29
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
30
30
|
|
|
31
31
|
#include <couchbase/durability_level.hxx>
|
|
32
32
|
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
#include "core/operations/operation_traits.hxx"
|
|
26
26
|
#include "core/protocol/client_request.hxx"
|
|
27
27
|
#include "core/protocol/cmd_decrement.hxx"
|
|
28
|
+
#include "core/public_fwd.hxx"
|
|
28
29
|
#include "core/timeout_defaults.hxx"
|
|
29
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
30
30
|
|
|
31
31
|
#include <couchbase/durability_level.hxx>
|
|
32
32
|
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
#include "core/io/retry_context.hxx"
|
|
24
24
|
#include "core/protocol/client_request.hxx"
|
|
25
25
|
#include "core/protocol/cmd_get_meta.hxx"
|
|
26
|
+
#include "core/public_fwd.hxx"
|
|
26
27
|
#include "core/timeout_defaults.hxx"
|
|
27
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
28
28
|
|
|
29
29
|
namespace couchbase::core::operations
|
|
30
30
|
{
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
#include "core/io/retry_context.hxx"
|
|
24
24
|
#include "core/protocol/client_request.hxx"
|
|
25
25
|
#include "core/protocol/cmd_get.hxx"
|
|
26
|
+
#include "core/public_fwd.hxx"
|
|
26
27
|
#include "core/timeout_defaults.hxx"
|
|
27
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
28
28
|
|
|
29
29
|
namespace couchbase::core::operations
|
|
30
30
|
{
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
#include "core/io/retry_context.hxx"
|
|
24
24
|
#include "core/protocol/client_request.hxx"
|
|
25
25
|
#include "core/protocol/cmd_get_and_lock.hxx"
|
|
26
|
+
#include "core/public_fwd.hxx"
|
|
26
27
|
#include "core/timeout_defaults.hxx"
|
|
27
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
28
28
|
|
|
29
29
|
namespace couchbase::core::operations
|
|
30
30
|
{
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
#include "core/io/retry_context.hxx"
|
|
25
25
|
#include "core/protocol/client_request.hxx"
|
|
26
26
|
#include "core/protocol/cmd_get_and_touch.hxx"
|
|
27
|
+
#include "core/public_fwd.hxx"
|
|
27
28
|
#include "core/timeout_defaults.hxx"
|
|
28
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
29
29
|
|
|
30
30
|
namespace couchbase::core::operations
|
|
31
31
|
{
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
#include "core/io/retry_context.hxx"
|
|
24
24
|
#include "core/protocol/client_request.hxx"
|
|
25
25
|
#include "core/protocol/cmd_lookup_in.hxx"
|
|
26
|
+
#include "core/public_fwd.hxx"
|
|
26
27
|
#include "core/timeout_defaults.hxx"
|
|
27
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
28
28
|
|
|
29
29
|
namespace couchbase::core::operations
|
|
30
30
|
{
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
#include "core/operations/operation_traits.hxx"
|
|
26
26
|
#include "core/protocol/client_request.hxx"
|
|
27
27
|
#include "core/protocol/cmd_increment.hxx"
|
|
28
|
+
#include "core/public_fwd.hxx"
|
|
28
29
|
#include "core/timeout_defaults.hxx"
|
|
29
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
30
30
|
|
|
31
31
|
#include <couchbase/durability_level.hxx>
|
|
32
32
|
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
#include "core/operations/operation_traits.hxx"
|
|
26
26
|
#include "core/protocol/client_request.hxx"
|
|
27
27
|
#include "core/protocol/cmd_insert.hxx"
|
|
28
|
+
#include "core/public_fwd.hxx"
|
|
28
29
|
#include "core/timeout_defaults.hxx"
|
|
29
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
30
30
|
|
|
31
31
|
#include <couchbase/durability_level.hxx>
|
|
32
32
|
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
#include "core/io/retry_context.hxx"
|
|
25
25
|
#include "core/protocol/client_request.hxx"
|
|
26
26
|
#include "core/protocol/cmd_lookup_in.hxx"
|
|
27
|
+
#include "core/public_fwd.hxx"
|
|
27
28
|
#include "core/timeout_defaults.hxx"
|
|
28
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
29
29
|
|
|
30
30
|
#include <couchbase/lookup_in_result.hxx>
|
|
31
31
|
|
|
@@ -0,0 +1,192 @@
|
|
|
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
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "core/error_context/key_value.hxx"
|
|
21
|
+
#include "core/impl/lookup_in_replica.hxx"
|
|
22
|
+
#include "core/impl/subdoc/command.hxx"
|
|
23
|
+
#include "core/operations/document_lookup_in.hxx"
|
|
24
|
+
#include "core/operations/operation_traits.hxx"
|
|
25
|
+
#include "core/utils/movable_function.hxx"
|
|
26
|
+
#include "couchbase/codec/encoded_value.hxx"
|
|
27
|
+
#include "couchbase/error_codes.hxx"
|
|
28
|
+
|
|
29
|
+
#include <functional>
|
|
30
|
+
#include <memory>
|
|
31
|
+
#include <mutex>
|
|
32
|
+
|
|
33
|
+
namespace couchbase::core::operations
|
|
34
|
+
{
|
|
35
|
+
struct lookup_in_all_replicas_response {
|
|
36
|
+
struct entry {
|
|
37
|
+
struct lookup_in_entry {
|
|
38
|
+
std::string path;
|
|
39
|
+
codec::binary value;
|
|
40
|
+
std::size_t original_index;
|
|
41
|
+
bool exists;
|
|
42
|
+
protocol::subdoc_opcode opcode;
|
|
43
|
+
key_value_status_code status;
|
|
44
|
+
std::error_code ec{};
|
|
45
|
+
};
|
|
46
|
+
std::vector<lookup_in_entry> fields{};
|
|
47
|
+
couchbase::cas cas{};
|
|
48
|
+
bool deleted{ false };
|
|
49
|
+
bool is_replica{ true };
|
|
50
|
+
};
|
|
51
|
+
subdocument_error_context ctx{};
|
|
52
|
+
std::vector<entry> entries{};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
struct lookup_in_all_replicas_request {
|
|
56
|
+
using response_type = lookup_in_all_replicas_response;
|
|
57
|
+
using encoded_request_type = core::protocol::client_request<core::protocol::lookup_in_replica_request_body>;
|
|
58
|
+
using encoded_response_type = core::protocol::client_response<core::protocol::lookup_in_replica_response_body>;
|
|
59
|
+
|
|
60
|
+
core::document_id id;
|
|
61
|
+
std::vector<couchbase::core::impl::subdoc::command> specs{};
|
|
62
|
+
std::optional<std::chrono::milliseconds> timeout{};
|
|
63
|
+
std::shared_ptr<couchbase::tracing::request_span> parent_span{ nullptr };
|
|
64
|
+
|
|
65
|
+
template<typename Core, typename Handler>
|
|
66
|
+
void execute(Core core, Handler handler)
|
|
67
|
+
{
|
|
68
|
+
core->with_bucket_configuration(
|
|
69
|
+
id.bucket(),
|
|
70
|
+
[core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward<Handler>(handler)](
|
|
71
|
+
std::error_code ec, const topology::configuration& config) mutable {
|
|
72
|
+
if (!config.supports_subdoc_read_replica()) {
|
|
73
|
+
ec = errc::common::feature_not_available;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (ec) {
|
|
77
|
+
std::optional<std::string> first_error_path{};
|
|
78
|
+
std::optional<std::size_t> first_error_index{};
|
|
79
|
+
return h(response_type{
|
|
80
|
+
make_subdocument_error_context(make_key_value_error_context(ec, id), ec, first_error_path, first_error_index, false) });
|
|
81
|
+
}
|
|
82
|
+
using handler_type = utils::movable_function<void(response_type)>;
|
|
83
|
+
|
|
84
|
+
struct replica_context {
|
|
85
|
+
replica_context(handler_type handler, std::uint32_t expected_responses)
|
|
86
|
+
: handler_(std::move(handler))
|
|
87
|
+
, expected_responses_(expected_responses)
|
|
88
|
+
{
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
handler_type handler_;
|
|
92
|
+
std::uint32_t expected_responses_;
|
|
93
|
+
bool done_{ false };
|
|
94
|
+
std::mutex mutex_{};
|
|
95
|
+
std::vector<lookup_in_all_replicas_response::entry> result_{};
|
|
96
|
+
};
|
|
97
|
+
auto ctx = std::make_shared<replica_context>(std::move(h), config.num_replicas.value_or(0U) + 1U);
|
|
98
|
+
|
|
99
|
+
for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
|
|
100
|
+
document_id replica_id{ id };
|
|
101
|
+
replica_id.node_index(idx);
|
|
102
|
+
core->execute(impl::lookup_in_replica_request{ std::move(replica_id), specs, timeout, parent_span },
|
|
103
|
+
[ctx](impl::lookup_in_replica_response&& resp) {
|
|
104
|
+
handler_type local_handler{};
|
|
105
|
+
{
|
|
106
|
+
std::scoped_lock lock(ctx->mutex_);
|
|
107
|
+
if (ctx->done_) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
--ctx->expected_responses_;
|
|
111
|
+
if (resp.ctx.ec()) {
|
|
112
|
+
if (ctx->expected_responses_ > 0) {
|
|
113
|
+
// just ignore the response
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
lookup_in_all_replicas_response::entry top_entry{};
|
|
118
|
+
top_entry.cas = resp.cas;
|
|
119
|
+
top_entry.deleted = resp.deleted;
|
|
120
|
+
top_entry.is_replica = true;
|
|
121
|
+
for (auto& field : resp.fields) {
|
|
122
|
+
lookup_in_all_replicas_response::entry::lookup_in_entry lookup_in_entry{};
|
|
123
|
+
lookup_in_entry.path = field.path;
|
|
124
|
+
lookup_in_entry.value = field.value;
|
|
125
|
+
lookup_in_entry.status = field.status;
|
|
126
|
+
lookup_in_entry.ec = field.ec;
|
|
127
|
+
lookup_in_entry.exists = field.exists;
|
|
128
|
+
lookup_in_entry.original_index = field.original_index;
|
|
129
|
+
lookup_in_entry.opcode = field.opcode;
|
|
130
|
+
top_entry.fields.emplace_back(lookup_in_entry);
|
|
131
|
+
}
|
|
132
|
+
ctx->result_.emplace_back(lookup_in_all_replicas_response::entry{ top_entry });
|
|
133
|
+
}
|
|
134
|
+
if (ctx->expected_responses_ == 0) {
|
|
135
|
+
ctx->done_ = true;
|
|
136
|
+
std::swap(local_handler, ctx->handler_);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (local_handler) {
|
|
140
|
+
return local_handler({ std::move(resp.ctx), std::move(ctx->result_) });
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
core->execute(lookup_in_request{ document_id{ id }, {}, {}, false, specs, timeout }, [ctx](lookup_in_response&& resp) {
|
|
146
|
+
handler_type local_handler{};
|
|
147
|
+
{
|
|
148
|
+
std::scoped_lock lock(ctx->mutex_);
|
|
149
|
+
if (ctx->done_) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
--ctx->expected_responses_;
|
|
153
|
+
if (resp.ctx.ec()) {
|
|
154
|
+
if (ctx->expected_responses_ > 0) {
|
|
155
|
+
// just ignore the response
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
lookup_in_all_replicas_response::entry top_entry{};
|
|
160
|
+
top_entry.cas = resp.cas;
|
|
161
|
+
top_entry.deleted = resp.deleted;
|
|
162
|
+
top_entry.is_replica = false;
|
|
163
|
+
for (auto& field : resp.fields) {
|
|
164
|
+
lookup_in_all_replicas_response::entry::lookup_in_entry lookup_in_entry{};
|
|
165
|
+
lookup_in_entry.path = field.path;
|
|
166
|
+
lookup_in_entry.value = field.value;
|
|
167
|
+
lookup_in_entry.status = field.status;
|
|
168
|
+
lookup_in_entry.ec = field.ec;
|
|
169
|
+
lookup_in_entry.exists = field.exists;
|
|
170
|
+
lookup_in_entry.original_index = field.original_index;
|
|
171
|
+
lookup_in_entry.opcode = field.opcode;
|
|
172
|
+
top_entry.fields.emplace_back(lookup_in_entry);
|
|
173
|
+
}
|
|
174
|
+
ctx->result_.emplace_back(lookup_in_all_replicas_response::entry{ top_entry });
|
|
175
|
+
}
|
|
176
|
+
if (ctx->expected_responses_ == 0) {
|
|
177
|
+
ctx->done_ = true;
|
|
178
|
+
std::swap(local_handler, ctx->handler_);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (local_handler) {
|
|
182
|
+
return local_handler({ std::move(resp.ctx), std::move(ctx->result_) });
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
template<>
|
|
190
|
+
struct is_compound_operation<lookup_in_all_replicas_request> : public std::true_type {
|
|
191
|
+
};
|
|
192
|
+
} // namespace couchbase::core::operations
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "core/error_context/key_value.hxx"
|
|
21
|
+
#include "core/impl/lookup_in_replica.hxx"
|
|
22
|
+
#include "core/impl/subdoc/command.hxx"
|
|
23
|
+
#include "core/operations/document_lookup_in.hxx"
|
|
24
|
+
#include "core/operations/operation_traits.hxx"
|
|
25
|
+
#include "core/utils/movable_function.hxx"
|
|
26
|
+
#include "couchbase/codec/encoded_value.hxx"
|
|
27
|
+
#include "couchbase/error_codes.hxx"
|
|
28
|
+
|
|
29
|
+
#include <functional>
|
|
30
|
+
#include <memory>
|
|
31
|
+
#include <mutex>
|
|
32
|
+
|
|
33
|
+
namespace couchbase::core::operations
|
|
34
|
+
{
|
|
35
|
+
struct lookup_in_any_replica_response {
|
|
36
|
+
struct entry {
|
|
37
|
+
std::string path;
|
|
38
|
+
codec::binary value;
|
|
39
|
+
std::size_t original_index;
|
|
40
|
+
bool exists;
|
|
41
|
+
protocol::subdoc_opcode opcode;
|
|
42
|
+
key_value_status_code status;
|
|
43
|
+
std::error_code ec{};
|
|
44
|
+
};
|
|
45
|
+
subdocument_error_context ctx{};
|
|
46
|
+
couchbase::cas cas{};
|
|
47
|
+
std::vector<entry> fields{};
|
|
48
|
+
bool deleted{ false };
|
|
49
|
+
bool is_replica{ true };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
struct lookup_in_any_replica_request {
|
|
53
|
+
using response_type = lookup_in_any_replica_response;
|
|
54
|
+
using encoded_request_type = core::protocol::client_request<core::protocol::lookup_in_replica_request_body>;
|
|
55
|
+
using encoded_response_type = core::protocol::client_response<core::protocol::lookup_in_replica_response_body>;
|
|
56
|
+
|
|
57
|
+
core::document_id id;
|
|
58
|
+
std::vector<couchbase::core::impl::subdoc::command> specs{};
|
|
59
|
+
std::optional<std::chrono::milliseconds> timeout{};
|
|
60
|
+
std::shared_ptr<couchbase::tracing::request_span> parent_span{ nullptr };
|
|
61
|
+
|
|
62
|
+
template<typename Core, typename Handler>
|
|
63
|
+
void execute(Core core, Handler handler)
|
|
64
|
+
{
|
|
65
|
+
core->with_bucket_configuration(
|
|
66
|
+
id.bucket(),
|
|
67
|
+
[core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward<Handler>(handler)](
|
|
68
|
+
std::error_code ec, const topology::configuration& config) mutable {
|
|
69
|
+
if (!config.supports_subdoc_read_replica()) {
|
|
70
|
+
ec = errc::common::feature_not_available;
|
|
71
|
+
}
|
|
72
|
+
if (specs.size() > 16) {
|
|
73
|
+
ec = errc::common::invalid_argument;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (ec) {
|
|
77
|
+
std::optional<std::string> first_error_path{};
|
|
78
|
+
std::optional<std::size_t> first_error_index{};
|
|
79
|
+
return h(response_type{
|
|
80
|
+
make_subdocument_error_context(make_key_value_error_context(ec, id), ec, first_error_path, first_error_index, false) });
|
|
81
|
+
}
|
|
82
|
+
using handler_type = utils::movable_function<void(response_type)>;
|
|
83
|
+
|
|
84
|
+
struct replica_context {
|
|
85
|
+
replica_context(handler_type&& handler, std::uint32_t expected_responses)
|
|
86
|
+
: handler_(std::move(handler))
|
|
87
|
+
, expected_responses_(expected_responses)
|
|
88
|
+
{
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
handler_type handler_;
|
|
92
|
+
std::uint32_t expected_responses_;
|
|
93
|
+
bool done_{ false };
|
|
94
|
+
std::mutex mutex_{};
|
|
95
|
+
};
|
|
96
|
+
auto ctx = std::make_shared<replica_context>(std::move(h), config.num_replicas.value_or(0U) + 1U);
|
|
97
|
+
|
|
98
|
+
for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
|
|
99
|
+
document_id replica_id{ id };
|
|
100
|
+
replica_id.node_index(idx);
|
|
101
|
+
core->execute(impl::lookup_in_replica_request{ std::move(replica_id), specs, timeout, parent_span },
|
|
102
|
+
[ctx](impl::lookup_in_replica_response&& resp) {
|
|
103
|
+
handler_type local_handler;
|
|
104
|
+
{
|
|
105
|
+
std::scoped_lock lock(ctx->mutex_);
|
|
106
|
+
if (ctx->done_) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
--ctx->expected_responses_;
|
|
110
|
+
if (resp.ctx.ec()) {
|
|
111
|
+
if (ctx->expected_responses_ > 0) {
|
|
112
|
+
// just ignore the response
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// consider document irretrievable and give up
|
|
116
|
+
resp.ctx.override_ec(errc::key_value::document_irretrievable);
|
|
117
|
+
}
|
|
118
|
+
ctx->done_ = true;
|
|
119
|
+
std::swap(local_handler, ctx->handler_);
|
|
120
|
+
}
|
|
121
|
+
if (local_handler) {
|
|
122
|
+
response_type res{};
|
|
123
|
+
res.ctx = resp.ctx;
|
|
124
|
+
res.cas = resp.cas;
|
|
125
|
+
res.deleted = resp.deleted;
|
|
126
|
+
res.is_replica = true;
|
|
127
|
+
for (auto& field : resp.fields) {
|
|
128
|
+
auto lookup_in_entry = lookup_in_any_replica_response::entry{};
|
|
129
|
+
lookup_in_entry.path = field.path;
|
|
130
|
+
lookup_in_entry.value = field.value;
|
|
131
|
+
lookup_in_entry.status = field.status;
|
|
132
|
+
lookup_in_entry.ec = field.ec;
|
|
133
|
+
lookup_in_entry.exists = field.exists;
|
|
134
|
+
lookup_in_entry.original_index = field.original_index;
|
|
135
|
+
lookup_in_entry.opcode = field.opcode;
|
|
136
|
+
res.fields.emplace_back(lookup_in_entry);
|
|
137
|
+
}
|
|
138
|
+
return local_handler(res);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
core->execute(lookup_in_request{ id, {}, {}, false, specs, timeout }, [ctx](lookup_in_response&& resp) {
|
|
143
|
+
handler_type local_handler{};
|
|
144
|
+
{
|
|
145
|
+
std::scoped_lock lock(ctx->mutex_);
|
|
146
|
+
if (ctx->done_) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
--ctx->expected_responses_;
|
|
150
|
+
if (resp.ctx.ec()) {
|
|
151
|
+
if (ctx->expected_responses_ > 0) {
|
|
152
|
+
// just ignore the response
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// consider document irretrievable and give up
|
|
156
|
+
resp.ctx.override_ec(errc::key_value::document_irretrievable);
|
|
157
|
+
}
|
|
158
|
+
ctx->done_ = true;
|
|
159
|
+
std::swap(local_handler, ctx->handler_);
|
|
160
|
+
}
|
|
161
|
+
if (local_handler) {
|
|
162
|
+
auto res = response_type{};
|
|
163
|
+
res.ctx = resp.ctx;
|
|
164
|
+
res.cas = resp.cas;
|
|
165
|
+
res.deleted = resp.deleted;
|
|
166
|
+
res.is_replica = false;
|
|
167
|
+
for (auto& field : resp.fields) {
|
|
168
|
+
auto lookup_in_entry = lookup_in_any_replica_response::entry{};
|
|
169
|
+
lookup_in_entry.path = field.path;
|
|
170
|
+
lookup_in_entry.value = field.value;
|
|
171
|
+
lookup_in_entry.status = field.status;
|
|
172
|
+
lookup_in_entry.ec = field.ec;
|
|
173
|
+
lookup_in_entry.exists = field.exists;
|
|
174
|
+
lookup_in_entry.original_index = field.original_index;
|
|
175
|
+
lookup_in_entry.opcode = field.opcode;
|
|
176
|
+
res.fields.emplace_back(lookup_in_entry);
|
|
177
|
+
}
|
|
178
|
+
return local_handler(res);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
template<>
|
|
186
|
+
struct is_compound_operation<lookup_in_any_replica_request> : public std::true_type {
|
|
187
|
+
};
|
|
188
|
+
} // namespace couchbase::core::operations
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
#include "core/operations/operation_traits.hxx"
|
|
27
27
|
#include "core/protocol/client_request.hxx"
|
|
28
28
|
#include "core/protocol/cmd_mutate_in.hxx"
|
|
29
|
+
#include "core/public_fwd.hxx"
|
|
29
30
|
#include "core/timeout_defaults.hxx"
|
|
30
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
31
31
|
|
|
32
32
|
#include <couchbase/durability_level.hxx>
|
|
33
33
|
#include <couchbase/mutate_in_result.hxx>
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
#include "core/operations/operation_traits.hxx"
|
|
26
26
|
#include "core/protocol/client_request.hxx"
|
|
27
27
|
#include "core/protocol/cmd_prepend.hxx"
|
|
28
|
+
#include "core/public_fwd.hxx"
|
|
28
29
|
#include "core/timeout_defaults.hxx"
|
|
29
|
-
#include "couchbase/tracing/request_tracer.hxx"
|
|
30
30
|
|
|
31
31
|
#include <couchbase/durability_level.hxx>
|
|
32
32
|
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
#include "document_query.hxx"
|
|
19
|
+
|
|
20
|
+
#include "core/cluster_options.hxx"
|
|
19
21
|
#include "core/logger/logger.hxx"
|
|
20
22
|
#include "core/operations/management/error_utils.hxx"
|
|
21
23
|
#include "core/utils/duration_parser.hxx"
|
|
@@ -83,6 +85,17 @@ query_request::encode_to(query_request::encoded_request_type& encoded, http_cont
|
|
|
83
85
|
case couchbase::query_profile::off:
|
|
84
86
|
break;
|
|
85
87
|
}
|
|
88
|
+
if (use_replica.has_value()) {
|
|
89
|
+
if (context.config.supports_read_from_replica()) {
|
|
90
|
+
if (use_replica.value()) {
|
|
91
|
+
body["use_replica"] = "on";
|
|
92
|
+
} else {
|
|
93
|
+
body["use_replica"] = "off";
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
return errc::common::feature_not_available;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
86
99
|
if (max_parallelism) {
|
|
87
100
|
body["max_parallelism"] = std::to_string(max_parallelism.value());
|
|
88
101
|
}
|