couchbase 3.7.0 → 3.8.0
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 +3 -3
- data/ext/CMakeLists.txt +4 -1
- data/ext/cache/extconf_include.rb +4 -3
- data/ext/cache/mozilla-ca-bundle.crt +66 -93
- data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
- data/ext/couchbase/CMakeLists.txt +24 -11
- data/ext/couchbase/cmake/APKBUILD.in +17 -1
- data/ext/couchbase/cmake/Bundler.cmake +9 -1
- data/ext/couchbase/cmake/Cache.cmake +48 -19
- data/ext/couchbase/cmake/CompilerOptions.cmake +3 -1
- data/ext/couchbase/cmake/OpenSSL.cmake +10 -2
- data/ext/couchbase/cmake/Packaging.cmake +48 -8
- data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +43 -1
- data/ext/couchbase/cmake/build_config.hxx.in +2 -0
- data/ext/couchbase/cmake/couchbase-cxx-client.spec.in +18 -0
- data/ext/couchbase/cmake/tarball_glob.txt +10 -0
- data/ext/couchbase/core/app_telemetry_meter.cxx +1 -0
- data/ext/couchbase/core/app_telemetry_reporter.cxx +45 -43
- data/ext/couchbase/core/app_telemetry_reporter.hxx +4 -3
- data/ext/couchbase/core/bucket.cxx +128 -13
- data/ext/couchbase/core/bucket.hxx +12 -2
- data/ext/couchbase/core/cluster.cxx +304 -152
- data/ext/couchbase/core/cluster.hxx +32 -0
- data/ext/couchbase/core/cluster_credentials.cxx +25 -0
- data/ext/couchbase/core/cluster_credentials.hxx +5 -0
- data/ext/couchbase/core/cluster_label_listener.cxx +72 -0
- data/ext/couchbase/core/cluster_label_listener.hxx +46 -0
- data/ext/couchbase/core/cluster_options.hxx +4 -0
- data/ext/couchbase/core/deprecation_utils.hxx +26 -0
- data/ext/couchbase/core/error.hxx +27 -0
- data/ext/couchbase/core/free_form_http_request.hxx +0 -2
- data/ext/couchbase/core/http_component.cxx +12 -48
- data/ext/couchbase/core/impl/analytics.cxx +3 -2
- data/ext/couchbase/core/impl/analytics.hxx +2 -1
- data/ext/couchbase/core/impl/analytics_index_manager.cxx +249 -137
- data/ext/couchbase/core/impl/binary_collection.cxx +134 -58
- data/ext/couchbase/core/impl/bucket_manager.cxx +87 -35
- data/ext/couchbase/core/impl/collection.cxx +560 -245
- data/ext/couchbase/core/impl/collection_manager.cxx +89 -49
- data/ext/couchbase/core/impl/dns_srv_tracker.cxx +4 -4
- data/ext/couchbase/core/impl/error.cxx +20 -13
- data/ext/couchbase/core/impl/error.hxx +15 -10
- data/ext/couchbase/core/impl/get_all_replicas.hxx +1 -1
- data/ext/couchbase/core/impl/get_any_replica.hxx +2 -1
- data/ext/couchbase/core/impl/get_replica.hxx +2 -0
- data/ext/couchbase/core/impl/lookup_in_replica.hxx +1 -1
- data/ext/couchbase/core/impl/observability_recorder.cxx +161 -0
- data/ext/couchbase/core/impl/observability_recorder.hxx +77 -0
- data/ext/couchbase/core/impl/observe_seqno.hxx +2 -0
- data/ext/couchbase/core/impl/public_bucket.cxx +31 -7
- data/ext/couchbase/core/impl/public_cluster.cxx +107 -19
- data/ext/couchbase/core/impl/query.cxx +6 -3
- data/ext/couchbase/core/impl/query.hxx +3 -1
- data/ext/couchbase/core/impl/query_index_manager.cxx +267 -102
- data/ext/couchbase/core/impl/scope.cxx +53 -11
- data/ext/couchbase/core/impl/search.cxx +8 -4
- data/ext/couchbase/core/impl/search.hxx +6 -2
- data/ext/couchbase/core/impl/search_index_manager.cxx +131 -41
- data/ext/couchbase/core/impl/with_cancellation.hxx +75 -0
- data/ext/couchbase/core/io/config_tracker.cxx +9 -9
- data/ext/couchbase/core/io/config_tracker.hxx +2 -1
- data/ext/couchbase/core/io/http_command.hxx +98 -49
- data/ext/couchbase/core/io/http_context.hxx +2 -0
- data/ext/couchbase/core/io/http_session.cxx +23 -10
- data/ext/couchbase/core/io/http_session.hxx +17 -9
- data/ext/couchbase/core/io/http_session_manager.hxx +163 -228
- data/ext/couchbase/core/io/http_traits.hxx +0 -7
- data/ext/couchbase/core/io/mcbp_command.hxx +123 -44
- data/ext/couchbase/core/io/mcbp_session.cxx +251 -26
- data/ext/couchbase/core/io/mcbp_session.hxx +9 -1
- data/ext/couchbase/core/io/mcbp_traits.hxx +0 -8
- data/ext/couchbase/core/io/streams.cxx +3 -3
- data/ext/couchbase/core/io/streams.hxx +3 -2
- data/ext/couchbase/core/meta/features.hxx +15 -0
- data/ext/couchbase/core/meta/version.cxx +13 -0
- data/ext/couchbase/core/meta/version.hxx +3 -0
- data/ext/couchbase/core/metrics/constants.hxx +23 -0
- data/ext/couchbase/core/metrics/logging_meter.cxx +5 -5
- data/ext/couchbase/core/metrics/meter_wrapper.cxx +65 -63
- data/ext/couchbase/core/metrics/meter_wrapper.hxx +12 -10
- data/ext/couchbase/core/operations/document_analytics.hxx +0 -5
- data/ext/couchbase/core/operations/document_append.hxx +0 -4
- data/ext/couchbase/core/operations/document_decrement.hxx +0 -5
- data/ext/couchbase/core/operations/document_exists.hxx +0 -7
- data/ext/couchbase/core/operations/document_get.hxx +0 -7
- data/ext/couchbase/core/operations/document_get_all_replicas.hxx +77 -27
- data/ext/couchbase/core/operations/document_get_and_lock.hxx +0 -9
- data/ext/couchbase/core/operations/document_get_and_touch.hxx +0 -9
- data/ext/couchbase/core/operations/document_get_any_replica.hxx +83 -2
- data/ext/couchbase/core/operations/document_get_projected.hxx +0 -9
- data/ext/couchbase/core/operations/document_increment.hxx +0 -5
- data/ext/couchbase/core/operations/document_insert.hxx +0 -4
- data/ext/couchbase/core/operations/document_lookup_in.hxx +0 -9
- data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +46 -4
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +121 -43
- data/ext/couchbase/core/operations/document_mutate_in.hxx +0 -5
- data/ext/couchbase/core/operations/document_prepend.hxx +0 -4
- data/ext/couchbase/core/operations/document_query.hxx +0 -4
- data/ext/couchbase/core/operations/document_remove.hxx +0 -4
- data/ext/couchbase/core/operations/document_replace.hxx +0 -4
- data/ext/couchbase/core/operations/document_search.hxx +0 -7
- data/ext/couchbase/core/operations/document_touch.hxx +0 -7
- data/ext/couchbase/core/operations/document_unlock.hxx +0 -6
- data/ext/couchbase/core/operations/document_upsert.hxx +0 -4
- data/ext/couchbase/core/operations/document_view.cxx +2 -0
- data/ext/couchbase/core/operations/document_view.hxx +10 -13
- data/ext/couchbase/core/operations/http_noop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataset_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataset_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataset_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataverse_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataverse_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_index_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_index_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_connect.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_disconnect.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_replace.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_describe.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_flush.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_update.hxx +2 -0
- data/ext/couchbase/core/operations/management/change_password.hxx +2 -0
- data/ext/couchbase/core/operations/management/cluster_describe.hxx +2 -0
- data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
- data/ext/couchbase/core/operations/management/collection_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/collection_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/collection_update.hxx +2 -0
- data/ext/couchbase/core/operations/management/collections_manifest_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/error_utils.cxx +4 -1
- data/ext/couchbase/core/operations/management/eventing_deploy_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_drop_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_get_all_functions.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_get_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_get_status.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_pause_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_resume_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_undeploy_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_upsert_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/freeform.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_build.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_build_deferred.hxx +68 -30
- data/ext/couchbase/core/operations/management/query_index_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_get_all.hxx +4 -3
- data/ext/couchbase/core/operations/management/query_index_get_all_deferred.hxx +2 -1
- data/ext/couchbase/core/operations/management/role_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/scope_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/scope_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/scope_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_get_stats.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_analyze_document.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_control_ingest.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_control_query.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get_documents_count.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get_stats.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/operation_traits.hxx +6 -0
- data/ext/couchbase/core/operations.hxx +0 -1
- data/ext/couchbase/core/operations_fwd.hxx +8 -0
- data/ext/couchbase/core/origin.cxx +67 -12
- data/ext/couchbase/core/origin.hxx +13 -8
- data/ext/couchbase/core/orphan_reporter.cxx +164 -0
- data/ext/couchbase/core/orphan_reporter.hxx +65 -0
- data/ext/couchbase/core/sasl/CMakeLists.txt +1 -0
- data/ext/couchbase/core/sasl/client.cc +6 -0
- data/ext/couchbase/core/sasl/mechanism.cc +2 -1
- data/ext/couchbase/core/sasl/mechanism.h +2 -1
- data/ext/couchbase/core/sasl/oauthbearer/oauthbearer.cc +41 -0
- data/ext/couchbase/core/sasl/oauthbearer/oauthbearer.h +47 -0
- data/ext/couchbase/core/tls_context_provider.cxx +44 -0
- data/ext/couchbase/core/tls_context_provider.hxx +44 -0
- data/ext/couchbase/core/tracing/attribute_helpers.hxx +45 -0
- data/ext/couchbase/core/tracing/constants.hxx +148 -68
- data/ext/couchbase/core/tracing/threshold_logging_options.hxx +0 -3
- data/ext/couchbase/core/tracing/threshold_logging_tracer.cxx +122 -170
- data/ext/couchbase/core/tracing/tracer_wrapper.cxx +17 -24
- data/ext/couchbase/core/tracing/tracer_wrapper.hxx +8 -10
- data/ext/couchbase/core/tracing/wrapper_sdk_tracer.cxx +114 -0
- data/ext/couchbase/core/tracing/wrapper_sdk_tracer.hxx +85 -0
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +16 -14
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +4 -4
- data/ext/couchbase/core/transactions/transactions.cxx +1 -1
- data/ext/couchbase/core/transactions/transactions_cleanup.cxx +1 -2
- data/ext/couchbase/core/utils/byteswap.hxx +12 -0
- data/ext/couchbase/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
- data/ext/couchbase/core/utils/connection_string.cxx +2 -0
- data/ext/couchbase/couchbase/certificate_authenticator.hxx +1 -0
- data/ext/couchbase/couchbase/cluster.hxx +47 -0
- data/ext/couchbase/couchbase/cluster_options.hxx +16 -0
- data/ext/couchbase/couchbase/collection.hxx +60 -15
- data/ext/couchbase/couchbase/error_codes.hxx +48 -48
- data/ext/couchbase/couchbase/jwt_authenticator.hxx +52 -0
- data/ext/couchbase/couchbase/metrics/meter.hxx +2 -1
- data/ext/couchbase/couchbase/metrics/otel_meter.hxx +75 -80
- data/ext/couchbase/couchbase/network_options.hxx +19 -0
- data/ext/couchbase/couchbase/password_authenticator.hxx +1 -0
- data/ext/couchbase/couchbase/tracing/otel_tracer.hxx +15 -17
- data/ext/couchbase/couchbase/tracing/request_span.hxx +2 -2
- data/ext/couchbase.cxx +4 -0
- data/ext/extconf.rb +1 -0
- data/ext/rcb_analytics.cxx +157 -47
- data/ext/rcb_backend.cxx +118 -71
- data/ext/rcb_buckets.cxx +39 -16
- data/ext/rcb_collections.cxx +36 -12
- data/ext/rcb_crud.cxx +587 -294
- data/ext/rcb_hdr_histogram.cxx +219 -0
- data/ext/rcb_hdr_histogram.hxx +28 -0
- data/ext/rcb_multi.cxx +142 -59
- data/ext/rcb_observability.cxx +132 -0
- data/ext/rcb_observability.hxx +49 -0
- data/ext/rcb_query.cxx +77 -27
- data/ext/rcb_search.cxx +92 -31
- data/ext/rcb_users.cxx +69 -26
- data/ext/rcb_utils.cxx +91 -0
- data/ext/rcb_utils.hxx +141 -168
- data/ext/rcb_views.cxx +36 -12
- data/lib/active_support/cache/couchbase_store.rb +6 -6
- data/lib/couchbase/authenticator.rb +14 -0
- data/lib/couchbase/binary_collection.rb +37 -22
- data/lib/couchbase/bucket.rb +46 -31
- data/lib/couchbase/cluster.rb +146 -61
- data/lib/couchbase/collection.rb +257 -186
- data/lib/couchbase/datastructures/couchbase_list.rb +81 -50
- data/lib/couchbase/datastructures/couchbase_map.rb +86 -50
- data/lib/couchbase/datastructures/couchbase_queue.rb +64 -38
- data/lib/couchbase/datastructures/couchbase_set.rb +57 -41
- data/lib/couchbase/deprecations.rb +1 -1
- data/lib/couchbase/diagnostics.rb +8 -8
- data/lib/couchbase/errors.rb +6 -0
- data/lib/couchbase/management/analytics_index_manager.rb +90 -59
- data/lib/couchbase/management/bucket_manager.rb +73 -45
- data/lib/couchbase/management/collection_manager.rb +86 -43
- data/lib/couchbase/management/collection_query_index_manager.rb +56 -33
- data/lib/couchbase/management/query_index_manager.rb +88 -36
- data/lib/couchbase/management/scope_search_index_manager.rb +119 -52
- data/lib/couchbase/management/search_index_manager.rb +401 -178
- data/lib/couchbase/management/user_manager.rb +343 -174
- data/lib/couchbase/management/view_index_manager.rb +166 -73
- data/lib/couchbase/metrics/logging_meter.rb +108 -0
- data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
- data/lib/couchbase/metrics/meter.rb +27 -0
- data/lib/couchbase/metrics/noop_meter.rb +30 -0
- data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
- data/lib/couchbase/metrics/value_recorder.rb +25 -0
- data/lib/couchbase/options.rb +69 -3
- data/lib/couchbase/protostellar/cluster.rb +3 -0
- data/lib/couchbase/scope.rb +62 -48
- data/lib/couchbase/search_options.rb +18 -18
- data/lib/couchbase/tracing/noop_span.rb +29 -0
- data/lib/couchbase/tracing/noop_tracer.rb +29 -0
- data/lib/couchbase/tracing/request_span.rb +34 -0
- data/lib/couchbase/tracing/request_tracer.rb +28 -0
- data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
- data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
- data/lib/couchbase/utils/hdr_histogram.rb +55 -0
- data/lib/couchbase/utils/observability.rb +257 -0
- data/lib/couchbase/utils/observability_constants.rb +200 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -3
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase.rb +2 -2
- metadata +58 -6
|
@@ -35,30 +35,28 @@
|
|
|
35
35
|
|
|
36
36
|
namespace couchbase::core::operations
|
|
37
37
|
{
|
|
38
|
-
|
|
39
|
-
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
40
|
-
using http_command_handler = utils::movable_function<void(error_union, io::http_response&&)>;
|
|
41
|
-
#else
|
|
42
|
-
using http_command_handler = utils::movable_function<void(std::error_code, io::http_response&&)>;
|
|
43
|
-
#endif
|
|
44
|
-
|
|
45
38
|
template<typename Request>
|
|
46
39
|
struct http_command : public std::enable_shared_from_this<http_command<Request>> {
|
|
47
40
|
using encoded_request_type = typename Request::encoded_request_type;
|
|
48
41
|
using encoded_response_type = typename Request::encoded_response_type;
|
|
49
42
|
using error_context_type = typename Request::error_context_type;
|
|
43
|
+
using response_type = typename Request::response_type;
|
|
44
|
+
using handler_type = utils::movable_function<void(response_type&&)>;
|
|
45
|
+
|
|
50
46
|
asio::steady_timer deadline;
|
|
51
47
|
Request request;
|
|
52
48
|
encoded_request_type encoded;
|
|
53
49
|
std::shared_ptr<tracing::tracer_wrapper> tracer_;
|
|
50
|
+
#ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
|
|
54
51
|
std::shared_ptr<couchbase::tracing::request_span> span_{ nullptr };
|
|
52
|
+
#endif
|
|
55
53
|
std::shared_ptr<metrics::meter_wrapper> meter_{};
|
|
56
54
|
std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter_{ nullptr };
|
|
57
55
|
std::shared_ptr<io::http_session> session_{};
|
|
58
|
-
|
|
56
|
+
handler_type handler_{};
|
|
59
57
|
std::chrono::milliseconds timeout_{};
|
|
60
58
|
std::string client_context_id_;
|
|
61
|
-
std::shared_ptr<couchbase::tracing::request_span>
|
|
59
|
+
std::shared_ptr<couchbase::tracing::request_span> parent_span_{ nullptr };
|
|
62
60
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
63
61
|
std::chrono::milliseconds dispatch_timeout_{};
|
|
64
62
|
asio::steady_timer dispatch_deadline_;
|
|
@@ -77,12 +75,10 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
77
75
|
, app_telemetry_meter_(std::move(app_telemetry_meter))
|
|
78
76
|
, timeout_(request.timeout.value_or(default_timeout))
|
|
79
77
|
, client_context_id_(request.client_context_id.value_or(uuid::to_string(uuid::random())))
|
|
78
|
+
, parent_span_(request.parent_span)
|
|
80
79
|
, dispatch_timeout_(dispatch_timeout)
|
|
81
80
|
, dispatch_deadline_(ctx)
|
|
82
81
|
{
|
|
83
|
-
if constexpr (io::http_traits::supports_parent_span_v<Request>) {
|
|
84
|
-
parent_span = request.parent_span;
|
|
85
|
-
}
|
|
86
82
|
}
|
|
87
83
|
#else
|
|
88
84
|
http_command(asio::io_context& ctx,
|
|
@@ -98,34 +94,20 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
98
94
|
, app_telemetry_meter_(std::move(app_telemetry_meter))
|
|
99
95
|
, timeout_(request.timeout.value_or(default_timeout))
|
|
100
96
|
, client_context_id_(request.client_context_id.value_or(uuid::to_string(uuid::random())))
|
|
97
|
+
, parent_span_(request.parent_span)
|
|
101
98
|
{
|
|
102
|
-
if constexpr (io::http_traits::supports_parent_span_v<Request>) {
|
|
103
|
-
parent_span = request.parent_span;
|
|
104
|
-
}
|
|
105
99
|
}
|
|
106
100
|
#endif
|
|
107
101
|
|
|
108
|
-
void
|
|
109
|
-
{
|
|
110
|
-
if (span_ == nullptr) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (span_->uses_tags())
|
|
114
|
-
span_->add_tag(tracing::attributes::remote_socket, remote_address);
|
|
115
|
-
if (span_->uses_tags())
|
|
116
|
-
span_->add_tag(tracing::attributes::local_socket, local_address);
|
|
117
|
-
span_->end();
|
|
118
|
-
span_ = nullptr;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
void start(http_command_handler&& handler)
|
|
102
|
+
void start(handler_type&& handler)
|
|
122
103
|
{
|
|
123
|
-
|
|
104
|
+
#ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
|
|
105
|
+
span_ = tracer_->create_span(tracing::span_name_for_http_service(request.type), parent_span_);
|
|
124
106
|
if (span_->uses_tags()) {
|
|
125
|
-
span_->add_tag(tracing::attributes::service,
|
|
107
|
+
span_->add_tag(tracing::attributes::op::service,
|
|
126
108
|
tracing::service_name_for_http_service(request.type));
|
|
127
|
-
span_->add_tag(tracing::attributes::operation_id, client_context_id_);
|
|
128
109
|
}
|
|
110
|
+
#endif
|
|
129
111
|
|
|
130
112
|
handler_ = std::move(handler);
|
|
131
113
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
@@ -172,11 +154,7 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
172
154
|
void invoke_handler(std::error_code ec, io::http_response&& msg)
|
|
173
155
|
#endif
|
|
174
156
|
{
|
|
175
|
-
if (
|
|
176
|
-
span_->end();
|
|
177
|
-
span_ = nullptr;
|
|
178
|
-
}
|
|
179
|
-
if (auto handler = std::move(handler_); handler) {
|
|
157
|
+
if (handler_type handler = std::move(handler_); handler) {
|
|
180
158
|
const auto& node_uuid = session_ ? session_->node_uuid() : "";
|
|
181
159
|
auto telemetry_recorder = app_telemetry_meter_->value_recorder(node_uuid, {});
|
|
182
160
|
telemetry_recorder->update_counter(total_counter_for_service_type(request.type));
|
|
@@ -193,13 +171,48 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
193
171
|
} else if (ec == errc::common::request_canceled) {
|
|
194
172
|
telemetry_recorder->update_counter(canceled_counter_for_service_type(request.type));
|
|
195
173
|
}
|
|
174
|
+
encoded_response_type encoded_resp{ std::move(msg) };
|
|
175
|
+
error_context_type ctx{};
|
|
196
176
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
177
|
+
if (!std::holds_alternative<std::monostate>(error)) {
|
|
178
|
+
if (std::holds_alternative<impl::bootstrap_error>(error)) {
|
|
179
|
+
auto bootstrap_error = std::get<impl::bootstrap_error>(error);
|
|
180
|
+
if (bootstrap_error.ec == errc::common::unambiguous_timeout) {
|
|
181
|
+
CB_LOG_DEBUG("Timeout caused by bootstrap error. code={}, ec_message={}, message={}.",
|
|
182
|
+
bootstrap_error.ec.value(),
|
|
183
|
+
bootstrap_error.ec.message(),
|
|
184
|
+
bootstrap_error.error_message);
|
|
185
|
+
}
|
|
186
|
+
ctx.ec = bootstrap_error.ec;
|
|
187
|
+
} else {
|
|
188
|
+
ctx.ec = std::get<std::error_code>(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
200
191
|
#else
|
|
201
|
-
|
|
192
|
+
ctx.ec = ec;
|
|
193
|
+
#endif
|
|
194
|
+
ctx.client_context_id = client_context_id_;
|
|
195
|
+
ctx.method = encoded.method;
|
|
196
|
+
ctx.path = encoded.path;
|
|
197
|
+
ctx.http_status = encoded_resp.status_code;
|
|
198
|
+
ctx.http_body = encoded_resp.body.data();
|
|
199
|
+
ctx.last_dispatched_from = session_->local_address();
|
|
200
|
+
ctx.last_dispatched_to = session_->remote_address();
|
|
201
|
+
ctx.hostname = session_->http_context().hostname;
|
|
202
|
+
ctx.port = session_->http_context().port;
|
|
203
|
+
|
|
204
|
+
// Can raise priv::retry_http_request when a retry is required
|
|
205
|
+
auto resp = request.make_response(std::move(ctx), std::move(encoded_resp));
|
|
206
|
+
|
|
207
|
+
#ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
|
|
208
|
+
span_->end();
|
|
209
|
+
span_ = nullptr;
|
|
210
|
+
#endif
|
|
211
|
+
|
|
212
|
+
handler(std::move(resp));
|
|
202
213
|
}
|
|
214
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
|
215
|
+
dispatch_deadline_.cancel();
|
|
203
216
|
#endif
|
|
204
217
|
deadline.cancel();
|
|
205
218
|
}
|
|
@@ -212,9 +225,6 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
212
225
|
if (!handler_) {
|
|
213
226
|
return;
|
|
214
227
|
}
|
|
215
|
-
if (span_->uses_tags()) {
|
|
216
|
-
span_->add_tag(tracing::attributes::local_id, session_->id());
|
|
217
|
-
}
|
|
218
228
|
send();
|
|
219
229
|
}
|
|
220
230
|
|
|
@@ -247,6 +257,7 @@ private:
|
|
|
247
257
|
return invoke_handler(ec, {});
|
|
248
258
|
}
|
|
249
259
|
encoded.headers["client-context-id"] = client_context_id_;
|
|
260
|
+
|
|
250
261
|
CB_LOG_TRACE(
|
|
251
262
|
R"({} HTTP request: {}, method={}, path="{}", client_context_id="{}", timeout={}ms)",
|
|
252
263
|
session_->log_prefix(),
|
|
@@ -255,19 +266,29 @@ private:
|
|
|
255
266
|
encoded.path,
|
|
256
267
|
client_context_id_,
|
|
257
268
|
timeout_.count());
|
|
269
|
+
|
|
270
|
+
auto dispatch_span = create_dispatch_span();
|
|
271
|
+
|
|
258
272
|
session_->write_and_subscribe(
|
|
259
273
|
encoded,
|
|
260
274
|
[self = this->shared_from_this(),
|
|
275
|
+
dispatch_span = std::move(dispatch_span),
|
|
261
276
|
start = std::chrono::steady_clock::now()](std::error_code ec, io::http_response&& msg) {
|
|
262
277
|
if (ec == asio::error::operation_aborted) {
|
|
278
|
+
dispatch_span->end();
|
|
263
279
|
return self->invoke_handler(errc::common::ambiguous_timeout, std::move(msg));
|
|
264
280
|
}
|
|
265
281
|
|
|
266
|
-
|
|
267
|
-
std::chrono::steady_clock::now() - start);
|
|
268
|
-
self->app_telemetry_meter_->value_recorder(self->session_->node_uuid(), {})
|
|
269
|
-
->record_latency(latency_for_service_type(self->request.type), latency);
|
|
282
|
+
dispatch_span->end();
|
|
270
283
|
|
|
284
|
+
{
|
|
285
|
+
auto latency = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
286
|
+
std::chrono::steady_clock::now() - start);
|
|
287
|
+
self->app_telemetry_meter_->value_recorder(self->session_->node_uuid(), {})
|
|
288
|
+
->record_latency(latency_for_service_type(self->request.type), latency);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
|
|
271
292
|
if (self->meter_) {
|
|
272
293
|
metrics::metric_attributes attrs{
|
|
273
294
|
self->request.type,
|
|
@@ -276,8 +297,9 @@ private:
|
|
|
276
297
|
};
|
|
277
298
|
self->meter_->record_value(std::move(attrs), start);
|
|
278
299
|
}
|
|
300
|
+
#endif
|
|
301
|
+
|
|
279
302
|
self->deadline.cancel();
|
|
280
|
-
self->finish_dispatch(self->session_->remote_address(), self->session_->local_address());
|
|
281
303
|
CB_LOG_TRACE(R"({} HTTP response: {}, client_context_id="{}", ec={}, status={}, body={})",
|
|
282
304
|
self->session_->log_prefix(),
|
|
283
305
|
self->request.type,
|
|
@@ -295,6 +317,33 @@ private:
|
|
|
295
317
|
}
|
|
296
318
|
});
|
|
297
319
|
}
|
|
320
|
+
|
|
321
|
+
[[nodiscard]] auto create_dispatch_span() const
|
|
322
|
+
-> std::shared_ptr<couchbase::tracing::request_span>
|
|
323
|
+
{
|
|
324
|
+
#ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
|
|
325
|
+
std::shared_ptr<couchbase::tracing::request_span> dispatch_span =
|
|
326
|
+
tracer_->create_span(tracing::operation::step_dispatch, span_);
|
|
327
|
+
#else
|
|
328
|
+
std::shared_ptr<couchbase::tracing::request_span> dispatch_span =
|
|
329
|
+
tracer_->create_span(tracing::operation::step_dispatch, parent_span_);
|
|
330
|
+
#endif
|
|
331
|
+
if (dispatch_span->uses_tags()) {
|
|
332
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::network_transport, "tcp");
|
|
333
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::operation_id, client_context_id_);
|
|
334
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::local_id, session_->id());
|
|
335
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::server_address,
|
|
336
|
+
session_->http_context().canonical_hostname);
|
|
337
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::server_port,
|
|
338
|
+
session_->http_context().canonical_port);
|
|
339
|
+
|
|
340
|
+
const auto& peer_endpoint = session_->remote_endpoint();
|
|
341
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::peer_address,
|
|
342
|
+
peer_endpoint.address().to_string());
|
|
343
|
+
dispatch_span->add_tag(tracing::attributes::dispatch::peer_port, peer_endpoint.port());
|
|
344
|
+
}
|
|
345
|
+
return dispatch_span;
|
|
346
|
+
}
|
|
298
347
|
};
|
|
299
348
|
|
|
300
349
|
} // namespace couchbase::core::operations
|
|
@@ -103,7 +103,7 @@ http_session::http_session(couchbase::core::service_type type,
|
|
|
103
103
|
std::string client_id,
|
|
104
104
|
std::string node_uuid,
|
|
105
105
|
asio::io_context& ctx,
|
|
106
|
-
|
|
106
|
+
origin& origin,
|
|
107
107
|
std::string hostname,
|
|
108
108
|
std::string service,
|
|
109
109
|
couchbase::core::http_context http_ctx)
|
|
@@ -117,7 +117,7 @@ http_session::http_session(couchbase::core::service_type type,
|
|
|
117
117
|
, connect_deadline_timer_(stream_->get_executor())
|
|
118
118
|
, idle_timer_(stream_->get_executor())
|
|
119
119
|
, retry_backoff_(stream_->get_executor())
|
|
120
|
-
,
|
|
120
|
+
, origin_(origin)
|
|
121
121
|
, hostname_(std::move(hostname))
|
|
122
122
|
, service_(std::move(service))
|
|
123
123
|
, user_agent_(meta::user_agent_for_http(client_id_, id_, http_ctx.options.user_agent_extra))
|
|
@@ -130,8 +130,8 @@ http_session::http_session(couchbase::core::service_type type,
|
|
|
130
130
|
std::string client_id,
|
|
131
131
|
std::string node_uuid,
|
|
132
132
|
asio::io_context& ctx,
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
tls_context_provider& tls,
|
|
134
|
+
origin& origin,
|
|
135
135
|
std::string hostname,
|
|
136
136
|
std::string service,
|
|
137
137
|
couchbase::core::http_context http_ctx)
|
|
@@ -145,7 +145,7 @@ http_session::http_session(couchbase::core::service_type type,
|
|
|
145
145
|
, connect_deadline_timer_(ctx_)
|
|
146
146
|
, idle_timer_(ctx_)
|
|
147
147
|
, retry_backoff_(ctx_)
|
|
148
|
-
,
|
|
148
|
+
, origin_(origin)
|
|
149
149
|
, hostname_(std::move(hostname))
|
|
150
150
|
, service_(std::move(service))
|
|
151
151
|
, user_agent_(meta::user_agent_for_http(client_id_, id_, http_ctx.options.user_agent_extra))
|
|
@@ -185,6 +185,13 @@ http_session::local_address() -> std::string
|
|
|
185
185
|
return info_.local_address();
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
auto
|
|
189
|
+
http_session::remote_endpoint() -> const asio::ip::tcp::endpoint&
|
|
190
|
+
{
|
|
191
|
+
const std::scoped_lock lock(info_mutex_);
|
|
192
|
+
return info_.remote_endpoint();
|
|
193
|
+
}
|
|
194
|
+
|
|
188
195
|
auto
|
|
189
196
|
http_session::diag_info() -> diag::endpoint_diag_info
|
|
190
197
|
{
|
|
@@ -219,9 +226,9 @@ http_session::node_uuid() const -> const std::string&
|
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
auto
|
|
222
|
-
http_session::credentials() const ->
|
|
229
|
+
http_session::credentials() const -> cluster_credentials
|
|
223
230
|
{
|
|
224
|
-
return
|
|
231
|
+
return origin_.credentials();
|
|
225
232
|
}
|
|
226
233
|
|
|
227
234
|
auto
|
|
@@ -433,9 +440,15 @@ http_session::write_and_stream(
|
|
|
433
440
|
keep_alive_ = true;
|
|
434
441
|
}
|
|
435
442
|
request.headers["user-agent"] = user_agent_;
|
|
436
|
-
auto
|
|
437
|
-
|
|
438
|
-
"
|
|
443
|
+
auto creds = credentials();
|
|
444
|
+
if (creds.uses_jwt()) {
|
|
445
|
+
request.headers["authorization"] = fmt::format("Bearer {}", creds.jwt_token);
|
|
446
|
+
} else {
|
|
447
|
+
const auto credentials = fmt::format("{}:{}", creds.username, creds.password);
|
|
448
|
+
request.headers["authorization"] = fmt::format(
|
|
449
|
+
"Basic {}",
|
|
450
|
+
base64::encode(gsl::as_bytes(gsl::span{ credentials.data(), credentials.size() })));
|
|
451
|
+
}
|
|
439
452
|
write(fmt::format(
|
|
440
453
|
"{} {} HTTP/1.1\r\nhost: {}:{}\r\n", request.method, request.path, hostname_, service_));
|
|
441
454
|
if (!request.body.empty()) {
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
#include "core/impl/bootstrap_error.hxx"
|
|
34
34
|
#endif
|
|
35
35
|
|
|
36
|
+
#include "core/tls_context_provider.hxx"
|
|
37
|
+
|
|
36
38
|
#include <asio.hpp>
|
|
37
39
|
#include <spdlog/fmt/bundled/chrono.h>
|
|
38
40
|
|
|
@@ -73,7 +75,7 @@ public:
|
|
|
73
75
|
std::string client_id,
|
|
74
76
|
std::string node_uuid,
|
|
75
77
|
asio::io_context& ctx,
|
|
76
|
-
|
|
78
|
+
origin& origin,
|
|
77
79
|
std::string hostname,
|
|
78
80
|
std::string service,
|
|
79
81
|
http_context http_ctx);
|
|
@@ -82,8 +84,8 @@ public:
|
|
|
82
84
|
std::string client_id,
|
|
83
85
|
std::string node_uuid,
|
|
84
86
|
asio::io_context& ctx,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
tls_context_provider& tls,
|
|
88
|
+
origin& origin,
|
|
87
89
|
std::string hostname,
|
|
88
90
|
std::string service,
|
|
89
91
|
http_context http_ctx);
|
|
@@ -94,11 +96,12 @@ public:
|
|
|
94
96
|
[[nodiscard]] auto http_context() -> couchbase::core::http_context&;
|
|
95
97
|
[[nodiscard]] auto remote_address() -> std::string;
|
|
96
98
|
[[nodiscard]] auto local_address() -> std::string;
|
|
99
|
+
[[nodiscard]] auto remote_endpoint() -> const asio::ip::tcp::endpoint&;
|
|
97
100
|
[[nodiscard]] auto diag_info() -> diag::endpoint_diag_info;
|
|
98
101
|
[[nodiscard]] auto log_prefix() -> std::string;
|
|
99
102
|
[[nodiscard]] auto id() const -> const std::string&;
|
|
100
103
|
[[nodiscard]] auto node_uuid() const -> const std::string&;
|
|
101
|
-
[[nodiscard]] auto credentials() const ->
|
|
104
|
+
[[nodiscard]] auto credentials() const -> cluster_credentials;
|
|
102
105
|
[[nodiscard]] auto is_connected() const -> bool;
|
|
103
106
|
[[nodiscard]] auto type() const -> service_type;
|
|
104
107
|
[[nodiscard]] auto hostname() const -> const std::string&;
|
|
@@ -131,10 +134,15 @@ public:
|
|
|
131
134
|
keep_alive_ = true;
|
|
132
135
|
}
|
|
133
136
|
request.headers["user-agent"] = user_agent_;
|
|
134
|
-
auto
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
|
|
137
|
+
auto creds = origin_.credentials();
|
|
138
|
+
if (creds.uses_jwt()) {
|
|
139
|
+
request.headers["authorization"] = fmt::format("Bearer {}", creds.jwt_token);
|
|
140
|
+
} else {
|
|
141
|
+
const auto credentials = fmt::format("{}:{}", creds.username, creds.password);
|
|
142
|
+
request.headers["authorization"] = fmt::format(
|
|
143
|
+
"Basic {}",
|
|
144
|
+
base64::encode(gsl::as_bytes(gsl::span{ credentials.data(), credentials.size() })));
|
|
145
|
+
}
|
|
138
146
|
write(fmt::format(
|
|
139
147
|
"{} {} HTTP/1.1\r\nhost: {}:{}\r\n", request.method, request.path, hostname_, service_));
|
|
140
148
|
if (!request.body.empty()) {
|
|
@@ -208,7 +216,7 @@ private:
|
|
|
208
216
|
asio::steady_timer idle_timer_;
|
|
209
217
|
asio::steady_timer retry_backoff_;
|
|
210
218
|
|
|
211
|
-
|
|
219
|
+
core::origin& origin_;
|
|
212
220
|
std::string hostname_;
|
|
213
221
|
std::string service_;
|
|
214
222
|
std::string user_agent_;
|