couchbase 4.4.2 → 4.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.
- package/BUILDING.md +182 -0
- package/CMakeLists.txt +13 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +4 -2
- package/deps/couchbase-cxx-cache/boringssl/e31ea00c1ea52052d2d78d44006cc88c80fa24a9/boringssl/src/BUILDING.md +206 -0
- package/deps/couchbase-cxx-client/CMakeLists.txt +18 -13
- package/deps/couchbase-cxx-client/README.md +2 -2
- package/deps/couchbase-cxx-client/cmake/APKBUILD.in +54 -0
- package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +0 -5
- package/deps/couchbase-cxx-client/cmake/Packaging.cmake +177 -10
- package/deps/couchbase-cxx-client/cmake/RPath.cmake +10 -0
- package/deps/couchbase-cxx-client/cmake/Testing.cmake +1 -1
- package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +28 -2
- package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
- package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +45 -6
- package/deps/couchbase-cxx-client/cmake/couchbase_cxx_client.pc.in +2 -2
- package/deps/couchbase-cxx-client/cmake/debian/changelog.in +5 -0
- package/deps/couchbase-cxx-client/cmake/debian/compat +1 -0
- package/deps/couchbase-cxx-client/cmake/debian/control +40 -0
- package/deps/couchbase-cxx-client/cmake/debian/rules +41 -0
- package/deps/couchbase-cxx-client/cmake/debian/source/format +1 -0
- package/deps/couchbase-cxx-client/core/agent_group.cxx +8 -0
- package/deps/couchbase-cxx-client/core/agent_group.hxx +4 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +16 -20
- package/deps/couchbase-cxx-client/core/bucket.hxx +12 -12
- package/deps/couchbase-cxx-client/core/cluster.cxx +44 -52
- package/deps/couchbase-cxx-client/core/cluster_agent.cxx +8 -0
- package/deps/couchbase-cxx-client/core/cluster_agent.hxx +4 -0
- package/deps/couchbase-cxx-client/core/collections_component.cxx +2 -2
- package/deps/couchbase-cxx-client/core/columnar/agent.cxx +2 -2
- package/deps/couchbase-cxx-client/core/columnar/agent.hxx +1 -1
- package/deps/couchbase-cxx-client/core/columnar/management_component.cxx +3 -3
- package/deps/couchbase-cxx-client/core/columnar/query_component.cxx +103 -45
- package/deps/couchbase-cxx-client/core/columnar/query_component.hxx +1 -0
- package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +8 -0
- package/deps/couchbase-cxx-client/core/http_component.cxx +55 -24
- package/deps/couchbase-cxx-client/core/http_component.hxx +4 -0
- package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +15 -15
- package/deps/couchbase-cxx-client/core/impl/bootstrap_error.hxx +10 -2
- package/deps/couchbase-cxx-client/core/impl/bucket.cxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +6 -6
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +36 -40
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +29 -5
- package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +5 -5
- package/deps/couchbase-cxx-client/core/impl/error.cxx +24 -3
- package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/observe_poll.cxx +13 -5
- package/deps/couchbase-cxx-client/core/impl/observe_poll.hxx +1 -3
- package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
- package/deps/couchbase-cxx-client/core/impl/scan_result.cxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/search.cxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +12 -12
- package/deps/couchbase-cxx-client/core/io/http_command.hxx +31 -20
- package/deps/couchbase-cxx-client/core/io/http_session.cxx +5 -0
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -4
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -49
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +15 -14
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
- package/deps/couchbase-cxx-client/core/io/streams.cxx +256 -0
- package/deps/couchbase-cxx-client/core/io/streams.hxx +31 -155
- package/deps/couchbase-cxx-client/core/logger/configuration.hxx +5 -0
- package/deps/couchbase-cxx-client/core/logger/custom_rotating_file_sink.cxx +2 -3
- package/deps/couchbase-cxx-client/core/logger/logger.cxx +39 -7
- package/deps/couchbase-cxx-client/core/logger/logger.hxx +7 -0
- package/deps/couchbase-cxx-client/core/meta/features.hxx +11 -0
- package/deps/couchbase-cxx-client/core/meta/version.cxx +47 -6
- package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +188 -0
- package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +73 -0
- package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +23 -17
- package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/document_append.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.cxx +23 -15
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +4 -3
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.cxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_update.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +5 -2
- package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +4 -2
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_upsert.cxx +3 -3
- package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +4 -1
- package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +5 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +5 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +4 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +5 -2
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_upsert.cxx +3 -3
- package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.cxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get.cxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.cxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +1 -0
- package/deps/couchbase-cxx-client/core/origin.cxx +37 -17
- package/deps/couchbase-cxx-client/core/platform/base64.cc +1 -1
- package/deps/couchbase-cxx-client/core/platform/random.cc +2 -0
- package/deps/couchbase-cxx-client/core/platform/uuid.h +6 -6
- package/deps/couchbase-cxx-client/core/row_streamer.cxx +1 -1
- package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.cc +1 -1
- package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.h +4 -4
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +2 -0
- package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +8 -0
- package/deps/couchbase-cxx-client/core/tracing/constants.hxx +3 -0
- package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +87 -0
- package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +57 -0
- package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +9 -21
- package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +6 -33
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +57 -56
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +17 -18
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +2 -2
- package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +2 -2
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +0 -20
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +2 -2
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +128 -52
- package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +4 -3
- package/deps/couchbase-cxx-client/couchbase/codec/tao_json_serializer.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/common_options.hxx +16 -1
- package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +16 -20
- package/deps/couchbase-cxx-client/couchbase/mutate_in_specs.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/query_options.hxx +4 -3
- package/deps/couchbase-cxx-client/couchbase/search_options.hxx +1 -1
- package/dist/analyticsindexmanager.d.ts +98 -14
- package/dist/analyticsindexmanager.js +452 -411
- package/dist/binding.d.ts +53 -4
- package/dist/bindingutilities.d.ts +26 -1
- package/dist/bindingutilities.js +108 -1
- package/dist/couchbase.d.ts +3 -1
- package/dist/couchbase.js +2 -0
- package/dist/rangeScan.d.ts +1 -1
- package/dist/rangeScan.js +1 -1
- package/dist/transactions.d.ts +34 -3
- package/dist/transactions.js +25 -18
- package/dist/transcoders.d.ts +68 -0
- package/dist/transcoders.js +194 -1
- package/dist/usermanager.d.ts +14 -14
- package/dist/usermanager.js +178 -228
- package/dist/utilities.js +4 -6
- package/dist/utilities_internal.js +1 -2
- package/package.json +9 -8
- package/src/binding.cpp +13 -13
- package/src/connection.cpp +22 -0
- package/src/connection.hpp +12 -0
- package/src/connection_autogen.cpp +100 -0
- package/src/jstocbpp_autogen.hpp +315 -8
- package/src/jstocbpp_transactions.hpp +1 -2
- package/tools/gen-bindings-js.js +38 -3
- package/tools/gen-bindings-json.py +575 -328
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
#pragma once
|
|
17
17
|
|
|
18
|
+
#include <couchbase/build_config.hxx>
|
|
19
|
+
|
|
20
|
+
#include "core/impl/bootstrap_error.hxx"
|
|
18
21
|
#include "service_type.hxx"
|
|
19
22
|
#include "utils/movable_function.hxx"
|
|
20
23
|
|
|
@@ -101,8 +104,13 @@ private:
|
|
|
101
104
|
std::shared_ptr<http_response_impl> impl_;
|
|
102
105
|
};
|
|
103
106
|
|
|
107
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
108
|
+
using free_form_http_request_callback =
|
|
109
|
+
utils::movable_function<void(http_response response, couchbase::core::error_union err)>;
|
|
110
|
+
#else
|
|
104
111
|
using free_form_http_request_callback =
|
|
105
112
|
utils::movable_function<void(http_response response, std::error_code ec)>;
|
|
113
|
+
#endif
|
|
106
114
|
|
|
107
115
|
class buffered_http_response_impl;
|
|
108
116
|
|
|
@@ -131,19 +131,22 @@ public:
|
|
|
131
131
|
invoke_response_handler(errc::common::request_canceled, {});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
void invoke_response_handler(std::error_code ec, io::http_streaming_response resp)
|
|
135
|
-
{
|
|
136
|
-
deadline_.cancel();
|
|
137
134
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
135
|
+
void invoke_response_handler(error_union err, io::http_streaming_response resp)
|
|
136
|
+
{
|
|
138
137
|
dispatch_deadline_.cancel();
|
|
138
|
+
#else
|
|
139
|
+
void invoke_response_handler(std::error_code err, io::http_streaming_response resp)
|
|
140
|
+
{
|
|
139
141
|
#endif
|
|
142
|
+
deadline_.cancel();
|
|
140
143
|
free_form_http_request_callback callback{};
|
|
141
144
|
{
|
|
142
145
|
const std::scoped_lock lock(callback_mutex_);
|
|
143
146
|
std::swap(callback, callback_);
|
|
144
147
|
}
|
|
145
148
|
if (callback) {
|
|
146
|
-
callback(http_response{ std::move(resp) },
|
|
149
|
+
callback(http_response{ std::move(resp) }, err);
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
|
|
@@ -157,12 +160,22 @@ public:
|
|
|
157
160
|
auto start_op = [self = shared_from_this()]() {
|
|
158
161
|
self->session_->write_and_stream(
|
|
159
162
|
self->encoded_,
|
|
163
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
164
|
+
[self](error_union err, io::http_streaming_response resp) {
|
|
165
|
+
if (std::holds_alternative<std::error_code>(err) &&
|
|
166
|
+
std::get<std::error_code>(err) == asio::error::operation_aborted) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
self->invoke_response_handler(err, std::move(resp));
|
|
170
|
+
},
|
|
171
|
+
#else
|
|
160
172
|
[self](std::error_code ec, io::http_streaming_response resp) {
|
|
161
173
|
if (ec == asio::error::operation_aborted) {
|
|
162
174
|
return;
|
|
163
175
|
}
|
|
164
176
|
self->invoke_response_handler(ec, std::move(resp));
|
|
165
177
|
},
|
|
178
|
+
#endif
|
|
166
179
|
[self]() {
|
|
167
180
|
self->stream_end_callback_();
|
|
168
181
|
});
|
|
@@ -409,8 +422,13 @@ public:
|
|
|
409
422
|
{
|
|
410
423
|
}
|
|
411
424
|
|
|
425
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
426
|
+
auto do_http_request(const http_request& request, free_form_http_request_callback&& callback)
|
|
427
|
+
-> tl::expected<std::shared_ptr<pending_operation>, error_union>
|
|
428
|
+
#else
|
|
412
429
|
auto do_http_request(const http_request& request, free_form_http_request_callback&& callback)
|
|
413
430
|
-> tl::expected<std::shared_ptr<pending_operation>, std::error_code>
|
|
431
|
+
#endif
|
|
414
432
|
{
|
|
415
433
|
std::shared_ptr<io::http_session_manager> session_manager;
|
|
416
434
|
{
|
|
@@ -436,9 +454,9 @@ public:
|
|
|
436
454
|
auto op =
|
|
437
455
|
std::make_shared<pending_http_operation>(io_, request, session_manager->dispatch_timeout());
|
|
438
456
|
if (!session_manager->is_configured()) {
|
|
439
|
-
auto
|
|
440
|
-
if (
|
|
441
|
-
return tl::unexpected{
|
|
457
|
+
auto err = defer_command(op, session_manager, credentials, std::move(callback));
|
|
458
|
+
if (!std::holds_alternative<std::monostate>(err)) {
|
|
459
|
+
return tl::unexpected{ err };
|
|
442
460
|
}
|
|
443
461
|
return op;
|
|
444
462
|
}
|
|
@@ -478,8 +496,11 @@ public:
|
|
|
478
496
|
auto op = std::make_shared<pending_buffered_http_operation>(
|
|
479
497
|
io_, request, session_manager->dispatch_timeout());
|
|
480
498
|
if (!session_manager->is_configured()) {
|
|
481
|
-
auto
|
|
482
|
-
if (
|
|
499
|
+
auto err = defer_command(op, session_manager, credentials, std::move(callback));
|
|
500
|
+
if (!std::holds_alternative<std::monostate>(err)) {
|
|
501
|
+
auto ec = std::holds_alternative<impl::bootstrap_error>(err)
|
|
502
|
+
? std::get<impl::bootstrap_error>(err).ec
|
|
503
|
+
: std::get<std::error_code>(err);
|
|
483
504
|
return tl::unexpected{ ec };
|
|
484
505
|
}
|
|
485
506
|
return op;
|
|
@@ -498,16 +519,19 @@ private:
|
|
|
498
519
|
const couchbase::core::cluster_credentials& credentials,
|
|
499
520
|
free_form_http_request_callback&& callback)
|
|
500
521
|
{
|
|
501
|
-
op->start([callback = std::move(callback)](auto resp, auto ec) mutable {
|
|
502
|
-
callback(std::move(resp), ec);
|
|
503
|
-
});
|
|
504
|
-
|
|
505
522
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
523
|
+
op->start([callback = std::move(callback)](auto resp, error_union err) mutable {
|
|
524
|
+
callback(std::move(resp), err);
|
|
525
|
+
});
|
|
506
526
|
// don't do anything if the op wasn't dispatched or has already timed out
|
|
507
527
|
auto now = std::chrono::steady_clock::now();
|
|
508
528
|
if (op->dispatch_deadline_expiry() < now || op->deadline_expiry() < now) {
|
|
509
529
|
return;
|
|
510
530
|
}
|
|
531
|
+
#else
|
|
532
|
+
op->start([callback = std::move(callback)](auto resp, auto ec) mutable {
|
|
533
|
+
callback(std::move(resp), ec);
|
|
534
|
+
});
|
|
511
535
|
#endif
|
|
512
536
|
std::shared_ptr<io::http_session> session;
|
|
513
537
|
{
|
|
@@ -592,10 +616,10 @@ private:
|
|
|
592
616
|
auto defer_command(std::shared_ptr<PendingHttpOp> pending_op,
|
|
593
617
|
const std::shared_ptr<io::http_session_manager>& session_manager,
|
|
594
618
|
const couchbase::core::cluster_credentials& credentials,
|
|
595
|
-
Callback&& callback) ->
|
|
619
|
+
Callback&& callback) -> error_union
|
|
596
620
|
{
|
|
597
621
|
if (auto last_error = session_manager->last_bootstrap_error(); last_error.has_value()) {
|
|
598
|
-
return last_error
|
|
622
|
+
return last_error.value();
|
|
599
623
|
}
|
|
600
624
|
CB_LOG_DEBUG(
|
|
601
625
|
R"(Adding pending HTTP operation to deferred queue: service={}, client_context_id={})",
|
|
@@ -605,26 +629,26 @@ private:
|
|
|
605
629
|
callback = std::forward<Callback>(callback),
|
|
606
630
|
op = std::move(pending_op),
|
|
607
631
|
session_manager,
|
|
608
|
-
credentials](
|
|
609
|
-
if (
|
|
632
|
+
credentials](error_union err) mutable {
|
|
633
|
+
if (!std::holds_alternative<std::monostate>(err)) {
|
|
610
634
|
// The deferred operation was cancelled - currently this can happen due to closing the
|
|
611
635
|
// cluster
|
|
612
|
-
return callback({},
|
|
636
|
+
return callback({}, err);
|
|
613
637
|
}
|
|
614
638
|
|
|
615
639
|
return send_http_operation(
|
|
616
640
|
op, session_manager, credentials, std::forward<Callback>(callback));
|
|
617
641
|
});
|
|
618
|
-
return {};
|
|
642
|
+
return std::monostate{};
|
|
619
643
|
}
|
|
620
644
|
|
|
621
645
|
auto defer_command(std::shared_ptr<pending_buffered_http_operation> pending_op,
|
|
622
646
|
const std::shared_ptr<io::http_session_manager>& session_manager,
|
|
623
647
|
const couchbase::core::cluster_credentials& credentials,
|
|
624
|
-
buffered_free_form_http_request_callback&& callback) ->
|
|
648
|
+
buffered_free_form_http_request_callback&& callback) -> error_union
|
|
625
649
|
{
|
|
626
650
|
if (auto last_error = session_manager->last_bootstrap_error(); last_error.has_value()) {
|
|
627
|
-
return last_error
|
|
651
|
+
return last_error.value();
|
|
628
652
|
}
|
|
629
653
|
CB_LOG_DEBUG(
|
|
630
654
|
R"(Adding pending HTTP operation to deferred queue: service={}, client_context_id={})",
|
|
@@ -634,8 +658,11 @@ private:
|
|
|
634
658
|
callback = std::move(callback),
|
|
635
659
|
op = std::move(pending_op),
|
|
636
660
|
session_manager,
|
|
637
|
-
credentials](
|
|
638
|
-
if (
|
|
661
|
+
credentials](error_union err) mutable {
|
|
662
|
+
if (!std::holds_alternative<std::monostate>(err)) {
|
|
663
|
+
auto ec = std::holds_alternative<impl::bootstrap_error>(err)
|
|
664
|
+
? std::get<impl::bootstrap_error>(err).ec
|
|
665
|
+
: std::get<std::error_code>(err);
|
|
639
666
|
// The deferred operation was cancelled - currently this can happen due to closing the
|
|
640
667
|
// cluster
|
|
641
668
|
return callback({}, ec);
|
|
@@ -643,7 +670,7 @@ private:
|
|
|
643
670
|
|
|
644
671
|
return send_http_operation(op, session_manager, credentials, std::move(callback));
|
|
645
672
|
});
|
|
646
|
-
return {};
|
|
673
|
+
return std::monostate{};
|
|
647
674
|
}
|
|
648
675
|
#endif
|
|
649
676
|
|
|
@@ -664,7 +691,11 @@ http_component::http_component(asio::io_context& io,
|
|
|
664
691
|
auto
|
|
665
692
|
http_component::do_http_request(const http_request& request,
|
|
666
693
|
free_form_http_request_callback&& callback)
|
|
694
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
695
|
+
-> tl::expected<std::shared_ptr<pending_operation>, error_union>
|
|
696
|
+
#else
|
|
667
697
|
-> tl::expected<std::shared_ptr<pending_operation>, std::error_code>
|
|
698
|
+
#endif
|
|
668
699
|
{
|
|
669
700
|
return impl_->do_http_request(request, std::move(callback));
|
|
670
701
|
}
|
|
@@ -49,7 +49,11 @@ public:
|
|
|
49
49
|
std::shared_ptr<retry_strategy> default_retry_strategy = {});
|
|
50
50
|
|
|
51
51
|
auto do_http_request(const http_request& request, free_form_http_request_callback&& callback)
|
|
52
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
53
|
+
-> tl::expected<std::shared_ptr<pending_operation>, error_union>;
|
|
54
|
+
#else
|
|
52
55
|
-> tl::expected<std::shared_ptr<pending_operation>, std::error_code>;
|
|
56
|
+
#endif
|
|
53
57
|
|
|
54
58
|
auto do_http_request_buffered(const http_request& request,
|
|
55
59
|
buffered_free_form_http_request_callback&& callback)
|
|
@@ -167,6 +167,7 @@ build_analytics_request(std::string statement,
|
|
|
167
167
|
std::move(options.client_context_id),
|
|
168
168
|
options.timeout,
|
|
169
169
|
};
|
|
170
|
+
request.parent_span = options.parent_span;
|
|
170
171
|
if (!options.raw.empty()) {
|
|
171
172
|
for (auto& [name, value] : options.raw) {
|
|
172
173
|
request.raw[name] = std::move(value);
|
|
@@ -159,7 +159,7 @@ public:
|
|
|
159
159
|
{},
|
|
160
160
|
options.timeout,
|
|
161
161
|
},
|
|
162
|
-
[dataverse_name, handler = std::move(handler)](auto resp) {
|
|
162
|
+
[dataverse_name, handler = std::move(handler)](const auto& resp) {
|
|
163
163
|
CB_LOG_DEBUG(
|
|
164
164
|
"Dataverse create for {} error code = {}", dataverse_name, resp.ctx.ec.value());
|
|
165
165
|
handler(core::impl::make_error(resp.ctx));
|
|
@@ -177,7 +177,7 @@ public:
|
|
|
177
177
|
{},
|
|
178
178
|
options.timeout,
|
|
179
179
|
},
|
|
180
|
-
[handler = std::move(handler)](auto resp) {
|
|
180
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
181
181
|
handler(core::impl::make_error(resp.ctx));
|
|
182
182
|
});
|
|
183
183
|
}
|
|
@@ -197,7 +197,7 @@ public:
|
|
|
197
197
|
options.timeout,
|
|
198
198
|
options.ignore_if_exists,
|
|
199
199
|
},
|
|
200
|
-
[handler = std::move(handler)](auto resp) {
|
|
200
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
201
201
|
handler(core::impl::make_error(resp.ctx));
|
|
202
202
|
});
|
|
203
203
|
}
|
|
@@ -214,7 +214,7 @@ public:
|
|
|
214
214
|
{},
|
|
215
215
|
options.timeout,
|
|
216
216
|
},
|
|
217
|
-
[handler = std::move(handler)](auto resp) {
|
|
217
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
218
218
|
handler(core::impl::make_error(resp.ctx));
|
|
219
219
|
});
|
|
220
220
|
}
|
|
@@ -262,7 +262,7 @@ public:
|
|
|
262
262
|
{},
|
|
263
263
|
options.timeout,
|
|
264
264
|
},
|
|
265
|
-
[handler = std::move(handler)](auto resp) {
|
|
265
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
266
266
|
handler(core::impl::make_error(resp.ctx));
|
|
267
267
|
});
|
|
268
268
|
}
|
|
@@ -281,7 +281,7 @@ public:
|
|
|
281
281
|
{},
|
|
282
282
|
options.timeout,
|
|
283
283
|
},
|
|
284
|
-
[handler = std::move(handler)](auto resp) {
|
|
284
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
285
285
|
handler(core::impl::make_error(resp.ctx));
|
|
286
286
|
});
|
|
287
287
|
}
|
|
@@ -324,7 +324,7 @@ public:
|
|
|
324
324
|
{},
|
|
325
325
|
options.timeout,
|
|
326
326
|
},
|
|
327
|
-
[handler = std::move(handler)](auto resp) {
|
|
327
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
328
328
|
handler(core::impl::make_error(resp.ctx));
|
|
329
329
|
});
|
|
330
330
|
}
|
|
@@ -339,7 +339,7 @@ public:
|
|
|
339
339
|
{},
|
|
340
340
|
options.timeout,
|
|
341
341
|
},
|
|
342
|
-
[handler = std::move(handler)](auto resp) {
|
|
342
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
343
343
|
handler(core::impl::make_error(resp.ctx));
|
|
344
344
|
});
|
|
345
345
|
}
|
|
@@ -386,7 +386,7 @@ public:
|
|
|
386
386
|
{},
|
|
387
387
|
options.timeout,
|
|
388
388
|
},
|
|
389
|
-
[handler = std::move(handler)](auto resp) {
|
|
389
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
390
390
|
handler(core::impl::make_error(resp.ctx));
|
|
391
391
|
});
|
|
392
392
|
|
|
@@ -398,7 +398,7 @@ public:
|
|
|
398
398
|
{},
|
|
399
399
|
options.timeout,
|
|
400
400
|
},
|
|
401
|
-
[handler = std::move(handler)](auto resp) {
|
|
401
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
402
402
|
handler(core::impl::make_error(resp.ctx));
|
|
403
403
|
});
|
|
404
404
|
|
|
@@ -410,7 +410,7 @@ public:
|
|
|
410
410
|
{},
|
|
411
411
|
options.timeout,
|
|
412
412
|
},
|
|
413
|
-
[handler = std::move(handler)](auto resp) {
|
|
413
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
414
414
|
handler(core::impl::make_error(resp.ctx));
|
|
415
415
|
});
|
|
416
416
|
}
|
|
@@ -429,7 +429,7 @@ public:
|
|
|
429
429
|
{},
|
|
430
430
|
options.timeout,
|
|
431
431
|
},
|
|
432
|
-
[handler = std::move(handler)](auto resp) {
|
|
432
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
433
433
|
handler(core::impl::make_error(resp.ctx));
|
|
434
434
|
});
|
|
435
435
|
|
|
@@ -441,7 +441,7 @@ public:
|
|
|
441
441
|
{},
|
|
442
442
|
options.timeout,
|
|
443
443
|
},
|
|
444
|
-
[handler = std::move(handler)](auto resp) {
|
|
444
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
445
445
|
handler(core::impl::make_error(resp.ctx));
|
|
446
446
|
});
|
|
447
447
|
|
|
@@ -453,7 +453,7 @@ public:
|
|
|
453
453
|
{},
|
|
454
454
|
options.timeout,
|
|
455
455
|
},
|
|
456
|
-
[handler = std::move(handler)](auto resp) {
|
|
456
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
457
457
|
handler(core::impl::make_error(resp.ctx));
|
|
458
458
|
});
|
|
459
459
|
}
|
|
@@ -471,7 +471,7 @@ public:
|
|
|
471
471
|
{},
|
|
472
472
|
options.timeout,
|
|
473
473
|
},
|
|
474
|
-
[handler = std::move(handler)](auto resp) {
|
|
474
|
+
[handler = std::move(handler)](const auto& resp) {
|
|
475
475
|
handler(core::impl::make_error(resp.ctx));
|
|
476
476
|
});
|
|
477
477
|
}
|
|
@@ -20,8 +20,12 @@
|
|
|
20
20
|
#include <optional>
|
|
21
21
|
#include <string>
|
|
22
22
|
#include <system_error>
|
|
23
|
+
#include <variant>
|
|
23
24
|
|
|
24
|
-
namespace couchbase::core
|
|
25
|
+
namespace couchbase::core
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
namespace impl
|
|
25
29
|
{
|
|
26
30
|
|
|
27
31
|
struct bootstrap_error {
|
|
@@ -31,4 +35,8 @@ struct bootstrap_error {
|
|
|
31
35
|
std::optional<std::string> port;
|
|
32
36
|
};
|
|
33
37
|
|
|
34
|
-
} // namespace
|
|
38
|
+
} // namespace impl
|
|
39
|
+
|
|
40
|
+
using error_union = std::variant<std::monostate, std::error_code, impl::bootstrap_error>;
|
|
41
|
+
|
|
42
|
+
} // namespace couchbase::core
|
|
@@ -59,7 +59,7 @@ public:
|
|
|
59
59
|
name_,
|
|
60
60
|
core::impl::to_core_service_types(options.service_types),
|
|
61
61
|
options.timeout,
|
|
62
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
62
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
63
63
|
return handler({}, core::impl::build_result(resp));
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -269,7 +269,7 @@ public:
|
|
|
269
269
|
{},
|
|
270
270
|
options.timeout,
|
|
271
271
|
},
|
|
272
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
272
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
273
273
|
return handler(core::impl::make_error(resp.ctx), map_bucket_settings(resp.bucket));
|
|
274
274
|
});
|
|
275
275
|
}
|
|
@@ -282,7 +282,7 @@ public:
|
|
|
282
282
|
{},
|
|
283
283
|
options.timeout,
|
|
284
284
|
},
|
|
285
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
285
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
286
286
|
return handler(core::impl::make_error(resp.ctx), map_all_bucket_settings(resp.buckets));
|
|
287
287
|
});
|
|
288
288
|
}
|
|
@@ -297,7 +297,7 @@ public:
|
|
|
297
297
|
{},
|
|
298
298
|
options.timeout,
|
|
299
299
|
},
|
|
300
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
300
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
301
301
|
return handler(core::impl::make_error(resp.ctx));
|
|
302
302
|
});
|
|
303
303
|
}
|
|
@@ -312,7 +312,7 @@ public:
|
|
|
312
312
|
{},
|
|
313
313
|
options.timeout,
|
|
314
314
|
},
|
|
315
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
315
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
316
316
|
return handler(core::impl::make_error(resp.ctx));
|
|
317
317
|
});
|
|
318
318
|
}
|
|
@@ -327,7 +327,7 @@ public:
|
|
|
327
327
|
{},
|
|
328
328
|
options.timeout,
|
|
329
329
|
},
|
|
330
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
330
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
331
331
|
return handler(core::impl::make_error(resp.ctx));
|
|
332
332
|
});
|
|
333
333
|
}
|
|
@@ -342,7 +342,7 @@ public:
|
|
|
342
342
|
{},
|
|
343
343
|
options.timeout,
|
|
344
344
|
},
|
|
345
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
345
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
346
346
|
return handler(core::impl::make_error(resp.ctx));
|
|
347
347
|
});
|
|
348
348
|
}
|
|
@@ -230,21 +230,8 @@ public:
|
|
|
230
230
|
// We cannot use close() method here, as it is capturing self as a shared
|
|
231
231
|
// pointer to extend lifetime for the user's callback. Here the reference
|
|
232
232
|
// counter has reached zero already, so we can only capture `*this`.
|
|
233
|
-
std::thread([this,
|
|
234
|
-
|
|
235
|
-
// blocks until cleanup is finished
|
|
236
|
-
txns->close();
|
|
237
|
-
}
|
|
238
|
-
std::promise<void> core_stopped;
|
|
239
|
-
auto f = core_stopped.get_future();
|
|
240
|
-
core_.close([&core_stopped]() {
|
|
241
|
-
core_stopped.set_value();
|
|
242
|
-
});
|
|
243
|
-
f.get();
|
|
244
|
-
io_.stop();
|
|
245
|
-
if (io_thread_.joinable()) {
|
|
246
|
-
io_thread_.join();
|
|
247
|
-
}
|
|
233
|
+
std::thread([this, barrier = std::move(barrier)]() mutable {
|
|
234
|
+
do_close();
|
|
248
235
|
barrier.set_value();
|
|
249
236
|
}).detach();
|
|
250
237
|
|
|
@@ -291,7 +278,7 @@ public:
|
|
|
291
278
|
}));
|
|
292
279
|
return;
|
|
293
280
|
}
|
|
294
|
-
impl->transactions_ = txns;
|
|
281
|
+
impl->transactions_ = std::move(txns);
|
|
295
282
|
handler(ec, couchbase::cluster(std::move(impl)));
|
|
296
283
|
});
|
|
297
284
|
});
|
|
@@ -323,16 +310,17 @@ public:
|
|
|
323
310
|
{},
|
|
324
311
|
core::impl::to_core_service_types(options.service_types),
|
|
325
312
|
options.timeout,
|
|
326
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
313
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
327
314
|
return handler({}, core::impl::build_result(resp));
|
|
328
315
|
});
|
|
329
316
|
};
|
|
330
317
|
|
|
331
318
|
void diagnostics(const diagnostics_options::built& options, diagnostics_handler&& handler) const
|
|
332
319
|
{
|
|
333
|
-
return core_.diagnostics(options.report_id,
|
|
334
|
-
|
|
335
|
-
|
|
320
|
+
return core_.diagnostics(options.report_id,
|
|
321
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
322
|
+
return handler({}, core::impl::build_result(resp));
|
|
323
|
+
});
|
|
336
324
|
}
|
|
337
325
|
|
|
338
326
|
void search(std::string index_name,
|
|
@@ -342,7 +330,7 @@ public:
|
|
|
342
330
|
{
|
|
343
331
|
return core_.execute(
|
|
344
332
|
core::impl::build_search_request(std::move(index_name), std::move(request), options, {}, {}),
|
|
345
|
-
[handler = std::move(handler)](auto resp) mutable {
|
|
333
|
+
[handler = std::move(handler)](const auto& resp) mutable {
|
|
346
334
|
return handler(core::impl::make_error(resp.ctx),
|
|
347
335
|
search_result{ internal_search_result{ resp } });
|
|
348
336
|
});
|
|
@@ -371,20 +359,7 @@ public:
|
|
|
371
359
|
{
|
|
372
360
|
// Spawn new thread to avoid joining IO thread from the same thread
|
|
373
361
|
std::thread([self = shared_from_this(), handler = std::move(handler)]() mutable {
|
|
374
|
-
|
|
375
|
-
// blocks until cleanup is finished
|
|
376
|
-
txns->close();
|
|
377
|
-
}
|
|
378
|
-
std::promise<void> barrier;
|
|
379
|
-
auto future = barrier.get_future();
|
|
380
|
-
self->core_.close([&barrier]() {
|
|
381
|
-
barrier.set_value();
|
|
382
|
-
});
|
|
383
|
-
future.get();
|
|
384
|
-
self->io_.stop();
|
|
385
|
-
if (self->io_thread_.joinable()) {
|
|
386
|
-
self->io_thread_.join();
|
|
387
|
-
}
|
|
362
|
+
self->do_close();
|
|
388
363
|
handler();
|
|
389
364
|
}).detach();
|
|
390
365
|
}
|
|
@@ -400,7 +375,25 @@ public:
|
|
|
400
375
|
}
|
|
401
376
|
|
|
402
377
|
private:
|
|
403
|
-
|
|
378
|
+
void do_close()
|
|
379
|
+
{
|
|
380
|
+
if (auto txns = std::move(transactions_); txns != nullptr) {
|
|
381
|
+
// blocks until cleanup is finished
|
|
382
|
+
txns->close();
|
|
383
|
+
}
|
|
384
|
+
std::promise<void> core_stopped;
|
|
385
|
+
auto f = core_stopped.get_future();
|
|
386
|
+
core_.close([core_stopped = std::move(core_stopped)]() mutable {
|
|
387
|
+
core_stopped.set_value();
|
|
388
|
+
});
|
|
389
|
+
f.get();
|
|
390
|
+
io_.stop();
|
|
391
|
+
if (io_thread_.joinable()) {
|
|
392
|
+
io_thread_.join();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
asio::io_context io_{ ASIO_CONCURRENCY_HINT_SAFE };
|
|
404
397
|
core::cluster core_{ io_ };
|
|
405
398
|
std::shared_ptr<core::transactions::transactions> transactions_{ nullptr };
|
|
406
399
|
std::thread io_thread_{ [&io = io_] {
|
|
@@ -539,12 +532,15 @@ cluster::connect(const std::string& connection_string,
|
|
|
539
532
|
// Spawn new thread for connection to ensure that cluster_impl pointer will
|
|
540
533
|
// not be deallocated in IO thread in case of error.
|
|
541
534
|
std::thread([connection_string, options, handler = std::move(handler)]() {
|
|
542
|
-
auto impl = std::make_shared<cluster_impl>();
|
|
543
535
|
auto barrier = std::make_shared<std::promise<std::pair<error, cluster>>>();
|
|
544
536
|
auto future = barrier->get_future();
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
537
|
+
{
|
|
538
|
+
auto impl = std::make_shared<cluster_impl>();
|
|
539
|
+
impl->open(connection_string, options, [barrier](auto err, auto c) {
|
|
540
|
+
barrier->set_value({ std::move(err), std::move(c) });
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
|
|
548
544
|
auto [err, c] = future.get();
|
|
549
545
|
handler(std::move(err), std::move(c));
|
|
550
546
|
}).detach();
|