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
data/ext/rcb_users.cxx
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
#include <ruby.h>
|
|
38
38
|
|
|
39
39
|
#include "rcb_backend.hxx"
|
|
40
|
+
#include "rcb_observability.hxx"
|
|
40
41
|
#include "rcb_utils.hxx"
|
|
41
42
|
|
|
42
43
|
namespace couchbase::ruby
|
|
@@ -61,7 +62,7 @@ cb_extract_role(const core::management::rbac::role_and_description& entry, VALUE
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
VALUE
|
|
64
|
-
cb_Backend_role_get_all(VALUE self, VALUE timeout)
|
|
65
|
+
cb_Backend_role_get_all(VALUE self, VALUE timeout, VALUE observability_handler)
|
|
65
66
|
{
|
|
66
67
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
67
68
|
|
|
@@ -69,11 +70,13 @@ cb_Backend_role_get_all(VALUE self, VALUE timeout)
|
|
|
69
70
|
core::operations::management::role_get_all_request req{};
|
|
70
71
|
cb_extract_timeout(req, timeout);
|
|
71
72
|
std::promise<core::operations::management::role_get_all_response> promise;
|
|
73
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
72
74
|
auto f = promise.get_future();
|
|
73
75
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
74
76
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
75
77
|
});
|
|
76
78
|
auto resp = cb_wait_for_future(f);
|
|
79
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
77
80
|
if (resp.ctx.ec) {
|
|
78
81
|
cb_throw_error(resp.ctx, "unable to fetch roles");
|
|
79
82
|
}
|
|
@@ -172,7 +175,7 @@ cb_extract_user(const core::management::rbac::user_and_metadata& entry, VALUE us
|
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
VALUE
|
|
175
|
-
cb_Backend_user_get_all(VALUE self, VALUE domain, VALUE timeout)
|
|
178
|
+
cb_Backend_user_get_all(VALUE self, VALUE domain, VALUE timeout, VALUE observability_handler)
|
|
176
179
|
{
|
|
177
180
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
178
181
|
|
|
@@ -189,12 +192,14 @@ cb_Backend_user_get_all(VALUE self, VALUE domain, VALUE timeout)
|
|
|
189
192
|
throw ruby_exception(exc_invalid_argument(),
|
|
190
193
|
rb_sprintf("unsupported authentication domain: %+" PRIsVALUE, domain));
|
|
191
194
|
}
|
|
195
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
192
196
|
std::promise<core::operations::management::user_get_all_response> promise;
|
|
193
197
|
auto f = promise.get_future();
|
|
194
198
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
195
199
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
196
200
|
});
|
|
197
201
|
auto resp = cb_wait_for_future(f);
|
|
202
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
198
203
|
if (resp.ctx.ec) {
|
|
199
204
|
cb_throw_error(resp.ctx, "unable to fetch users");
|
|
200
205
|
}
|
|
@@ -216,7 +221,11 @@ cb_Backend_user_get_all(VALUE self, VALUE domain, VALUE timeout)
|
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
VALUE
|
|
219
|
-
cb_Backend_user_get(VALUE self,
|
|
224
|
+
cb_Backend_user_get(VALUE self,
|
|
225
|
+
VALUE domain,
|
|
226
|
+
VALUE username,
|
|
227
|
+
VALUE timeout,
|
|
228
|
+
VALUE observability_handler)
|
|
220
229
|
{
|
|
221
230
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
222
231
|
|
|
@@ -235,12 +244,14 @@ cb_Backend_user_get(VALUE self, VALUE domain, VALUE username, VALUE timeout)
|
|
|
235
244
|
rb_sprintf("unsupported authentication domain: %+" PRIsVALUE, domain));
|
|
236
245
|
}
|
|
237
246
|
req.username = cb_string_new(username);
|
|
247
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
238
248
|
std::promise<core::operations::management::user_get_response> promise;
|
|
239
249
|
auto f = promise.get_future();
|
|
240
250
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
241
251
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
242
252
|
});
|
|
243
253
|
auto resp = cb_wait_for_future(f);
|
|
254
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
244
255
|
if (resp.ctx.ec) {
|
|
245
256
|
cb_throw_error(resp.ctx, fmt::format(R"(unable to fetch user "{}")", req.username));
|
|
246
257
|
}
|
|
@@ -258,7 +269,11 @@ cb_Backend_user_get(VALUE self, VALUE domain, VALUE username, VALUE timeout)
|
|
|
258
269
|
}
|
|
259
270
|
|
|
260
271
|
VALUE
|
|
261
|
-
cb_Backend_user_drop(VALUE self,
|
|
272
|
+
cb_Backend_user_drop(VALUE self,
|
|
273
|
+
VALUE domain,
|
|
274
|
+
VALUE username,
|
|
275
|
+
VALUE timeout,
|
|
276
|
+
VALUE observability_handler)
|
|
262
277
|
{
|
|
263
278
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
264
279
|
|
|
@@ -277,12 +292,15 @@ cb_Backend_user_drop(VALUE self, VALUE domain, VALUE username, VALUE timeout)
|
|
|
277
292
|
rb_sprintf("unsupported authentication domain: %+" PRIsVALUE, domain));
|
|
278
293
|
}
|
|
279
294
|
req.username = cb_string_new(username);
|
|
295
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
280
296
|
std::promise<core::operations::management::user_drop_response> promise;
|
|
281
297
|
auto f = promise.get_future();
|
|
282
298
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
283
299
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
284
300
|
});
|
|
285
|
-
|
|
301
|
+
auto resp = cb_wait_for_future(f);
|
|
302
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
303
|
+
if (resp.ctx.ec) {
|
|
286
304
|
cb_throw_error(resp.ctx, fmt::format(R"(unable to fetch user "{}")", req.username));
|
|
287
305
|
}
|
|
288
306
|
|
|
@@ -297,7 +315,11 @@ cb_Backend_user_drop(VALUE self, VALUE domain, VALUE username, VALUE timeout)
|
|
|
297
315
|
}
|
|
298
316
|
|
|
299
317
|
VALUE
|
|
300
|
-
cb_Backend_user_upsert(VALUE self,
|
|
318
|
+
cb_Backend_user_upsert(VALUE self,
|
|
319
|
+
VALUE domain,
|
|
320
|
+
VALUE user,
|
|
321
|
+
VALUE timeout,
|
|
322
|
+
VALUE observability_handler)
|
|
301
323
|
{
|
|
302
324
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
303
325
|
|
|
@@ -365,13 +387,17 @@ cb_Backend_user_upsert(VALUE self, VALUE domain, VALUE user, VALUE timeout)
|
|
|
365
387
|
}
|
|
366
388
|
}
|
|
367
389
|
|
|
390
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
391
|
+
|
|
368
392
|
std::promise<core::operations::management::user_upsert_response> promise;
|
|
369
393
|
auto f = promise.get_future();
|
|
370
394
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
371
395
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
372
396
|
});
|
|
373
397
|
|
|
374
|
-
|
|
398
|
+
auto resp = cb_wait_for_future(f);
|
|
399
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
400
|
+
if (resp.ctx.ec) {
|
|
375
401
|
cb_throw_error(resp.ctx,
|
|
376
402
|
fmt::format(R"(unable to upsert user "{}" ({}))",
|
|
377
403
|
req.user.username,
|
|
@@ -389,7 +415,10 @@ cb_Backend_user_upsert(VALUE self, VALUE domain, VALUE user, VALUE timeout)
|
|
|
389
415
|
}
|
|
390
416
|
|
|
391
417
|
VALUE
|
|
392
|
-
cb_Backend_change_password(VALUE self,
|
|
418
|
+
cb_Backend_change_password(VALUE self,
|
|
419
|
+
VALUE new_password,
|
|
420
|
+
VALUE timeout,
|
|
421
|
+
VALUE observability_handler)
|
|
393
422
|
{
|
|
394
423
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
395
424
|
|
|
@@ -399,12 +428,15 @@ cb_Backend_change_password(VALUE self, VALUE new_password, VALUE timeout)
|
|
|
399
428
|
core::operations::management::change_password_request req{};
|
|
400
429
|
cb_extract_timeout(req, timeout);
|
|
401
430
|
req.newPassword = cb_string_new(new_password);
|
|
431
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
402
432
|
std::promise<core::operations::management::change_password_response> promise;
|
|
403
433
|
auto f = promise.get_future();
|
|
404
434
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
405
435
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
406
436
|
});
|
|
407
|
-
|
|
437
|
+
auto resp = cb_wait_for_future(f);
|
|
438
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
439
|
+
if (resp.ctx.ec) {
|
|
408
440
|
cb_throw_error(resp.ctx, "unable to change password");
|
|
409
441
|
}
|
|
410
442
|
|
|
@@ -449,19 +481,21 @@ cb_extract_group(const core::management::rbac::group& entry, VALUE group)
|
|
|
449
481
|
}
|
|
450
482
|
|
|
451
483
|
VALUE
|
|
452
|
-
cb_Backend_group_get_all(VALUE self, VALUE timeout)
|
|
484
|
+
cb_Backend_group_get_all(VALUE self, VALUE timeout, VALUE observability_handler)
|
|
453
485
|
{
|
|
454
486
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
455
487
|
|
|
456
488
|
try {
|
|
457
489
|
core::operations::management::group_get_all_request req{};
|
|
458
490
|
cb_extract_timeout(req, timeout);
|
|
491
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
459
492
|
std::promise<core::operations::management::group_get_all_response> promise;
|
|
460
493
|
auto f = promise.get_future();
|
|
461
494
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
462
495
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
463
496
|
});
|
|
464
497
|
auto resp = cb_wait_for_future(f);
|
|
498
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
465
499
|
if (resp.ctx.ec) {
|
|
466
500
|
cb_throw_error(resp.ctx, "unable to fetch groups");
|
|
467
501
|
}
|
|
@@ -483,7 +517,7 @@ cb_Backend_group_get_all(VALUE self, VALUE timeout)
|
|
|
483
517
|
}
|
|
484
518
|
|
|
485
519
|
VALUE
|
|
486
|
-
cb_Backend_group_get(VALUE self, VALUE name, VALUE timeout)
|
|
520
|
+
cb_Backend_group_get(VALUE self, VALUE name, VALUE timeout, VALUE observability_handler)
|
|
487
521
|
{
|
|
488
522
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
489
523
|
|
|
@@ -493,12 +527,14 @@ cb_Backend_group_get(VALUE self, VALUE name, VALUE timeout)
|
|
|
493
527
|
core::operations::management::group_get_request req{};
|
|
494
528
|
cb_extract_timeout(req, timeout);
|
|
495
529
|
req.name = cb_string_new(name);
|
|
530
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
496
531
|
std::promise<core::operations::management::group_get_response> promise;
|
|
497
532
|
auto f = promise.get_future();
|
|
498
533
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
499
534
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
500
535
|
});
|
|
501
536
|
auto resp = cb_wait_for_future(f);
|
|
537
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
502
538
|
if (resp.ctx.ec) {
|
|
503
539
|
cb_throw_error(resp.ctx, fmt::format(R"(unable to fetch group "{}")", req.name));
|
|
504
540
|
}
|
|
@@ -516,7 +552,7 @@ cb_Backend_group_get(VALUE self, VALUE name, VALUE timeout)
|
|
|
516
552
|
}
|
|
517
553
|
|
|
518
554
|
VALUE
|
|
519
|
-
cb_Backend_group_drop(VALUE self, VALUE name, VALUE timeout)
|
|
555
|
+
cb_Backend_group_drop(VALUE self, VALUE name, VALUE timeout, VALUE observability_handler)
|
|
520
556
|
{
|
|
521
557
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
522
558
|
|
|
@@ -526,13 +562,16 @@ cb_Backend_group_drop(VALUE self, VALUE name, VALUE timeout)
|
|
|
526
562
|
core::operations::management::group_drop_request req{};
|
|
527
563
|
cb_extract_timeout(req, timeout);
|
|
528
564
|
req.name = cb_string_new(name);
|
|
565
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
529
566
|
std::promise<core::operations::management::group_drop_response> promise;
|
|
530
567
|
auto f = promise.get_future();
|
|
531
568
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
532
569
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
533
570
|
});
|
|
534
571
|
|
|
535
|
-
|
|
572
|
+
auto resp = cb_wait_for_future(f);
|
|
573
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
574
|
+
if (resp.ctx.ec) {
|
|
536
575
|
cb_throw_error(resp.ctx, fmt::format(R"(unable to drop group "{}")", req.name));
|
|
537
576
|
}
|
|
538
577
|
return Qtrue;
|
|
@@ -546,7 +585,7 @@ cb_Backend_group_drop(VALUE self, VALUE name, VALUE timeout)
|
|
|
546
585
|
}
|
|
547
586
|
|
|
548
587
|
VALUE
|
|
549
|
-
cb_Backend_group_upsert(VALUE self, VALUE group, VALUE timeout)
|
|
588
|
+
cb_Backend_group_upsert(VALUE self, VALUE group, VALUE timeout, VALUE observability_handler)
|
|
550
589
|
{
|
|
551
590
|
auto cluster = cb_backend_to_core_api_cluster(self);
|
|
552
591
|
|
|
@@ -596,12 +635,16 @@ cb_Backend_group_upsert(VALUE self, VALUE group, VALUE timeout)
|
|
|
596
635
|
}
|
|
597
636
|
}
|
|
598
637
|
|
|
638
|
+
auto parent_span = cb_create_parent_span(req, self);
|
|
639
|
+
|
|
599
640
|
std::promise<core::operations::management::group_upsert_response> promise;
|
|
600
641
|
auto f = promise.get_future();
|
|
601
642
|
cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
|
|
602
643
|
promise.set_value(std::forward<decltype(resp)>(resp));
|
|
603
644
|
});
|
|
604
|
-
|
|
645
|
+
auto resp = cb_wait_for_future(f);
|
|
646
|
+
cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts);
|
|
647
|
+
if (resp.ctx.ec) {
|
|
605
648
|
cb_throw_error(resp.ctx,
|
|
606
649
|
fmt::format(R"(unable to upsert group "{}" ({}))",
|
|
607
650
|
req.group.name,
|
|
@@ -621,16 +664,16 @@ cb_Backend_group_upsert(VALUE self, VALUE group, VALUE timeout)
|
|
|
621
664
|
void
|
|
622
665
|
init_users(VALUE cBackend)
|
|
623
666
|
{
|
|
624
|
-
rb_define_method(cBackend, "role_get_all", cb_Backend_role_get_all,
|
|
625
|
-
rb_define_method(cBackend, "user_get_all", cb_Backend_user_get_all,
|
|
626
|
-
rb_define_method(cBackend, "user_get", cb_Backend_user_get,
|
|
627
|
-
rb_define_method(cBackend, "user_drop", cb_Backend_user_drop,
|
|
628
|
-
rb_define_method(cBackend, "user_upsert", cb_Backend_user_upsert,
|
|
629
|
-
rb_define_method(cBackend, "group_get_all", cb_Backend_group_get_all,
|
|
630
|
-
rb_define_method(cBackend, "group_get", cb_Backend_group_get,
|
|
631
|
-
rb_define_method(cBackend, "group_drop", cb_Backend_group_drop,
|
|
632
|
-
rb_define_method(cBackend, "group_upsert", cb_Backend_group_upsert,
|
|
633
|
-
|
|
634
|
-
rb_define_method(cBackend, "change_password", cb_Backend_change_password,
|
|
667
|
+
rb_define_method(cBackend, "role_get_all", cb_Backend_role_get_all, 2);
|
|
668
|
+
rb_define_method(cBackend, "user_get_all", cb_Backend_user_get_all, 3);
|
|
669
|
+
rb_define_method(cBackend, "user_get", cb_Backend_user_get, 4);
|
|
670
|
+
rb_define_method(cBackend, "user_drop", cb_Backend_user_drop, 4);
|
|
671
|
+
rb_define_method(cBackend, "user_upsert", cb_Backend_user_upsert, 4);
|
|
672
|
+
rb_define_method(cBackend, "group_get_all", cb_Backend_group_get_all, 2);
|
|
673
|
+
rb_define_method(cBackend, "group_get", cb_Backend_group_get, 3);
|
|
674
|
+
rb_define_method(cBackend, "group_drop", cb_Backend_group_drop, 3);
|
|
675
|
+
rb_define_method(cBackend, "group_upsert", cb_Backend_group_upsert, 3);
|
|
676
|
+
|
|
677
|
+
rb_define_method(cBackend, "change_password", cb_Backend_change_password, 3);
|
|
635
678
|
}
|
|
636
679
|
} // namespace couchbase::ruby
|
data/ext/rcb_utils.cxx
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
#include <couchbase/expiry.hxx>
|
|
19
|
+
|
|
18
20
|
#include <core/utils/binary.hxx>
|
|
19
21
|
|
|
20
22
|
#include "rcb_exceptions.hxx"
|
|
@@ -212,6 +214,20 @@ cb_str_new(const std::optional<std::string>& str)
|
|
|
212
214
|
return Qnil;
|
|
213
215
|
}
|
|
214
216
|
|
|
217
|
+
void
|
|
218
|
+
cb_extract_content(std::vector<std::byte>& field, VALUE content)
|
|
219
|
+
{
|
|
220
|
+
cb_check_type(content, T_STRING);
|
|
221
|
+
field = cb_binary_new(content);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
void
|
|
225
|
+
cb_extract_flags(std::uint32_t& field, VALUE flags)
|
|
226
|
+
{
|
|
227
|
+
cb_check_type(flags, T_FIXNUM);
|
|
228
|
+
field = FIX2UINT(flags);
|
|
229
|
+
}
|
|
230
|
+
|
|
215
231
|
void
|
|
216
232
|
cb_extract_timeout(std::chrono::milliseconds& field, VALUE options)
|
|
217
233
|
{
|
|
@@ -358,6 +374,62 @@ cb_extract_cas(couchbase::cas& field, VALUE cas)
|
|
|
358
374
|
}
|
|
359
375
|
}
|
|
360
376
|
|
|
377
|
+
void
|
|
378
|
+
cb_extract_expiry(std::uint32_t& field, VALUE options)
|
|
379
|
+
{
|
|
380
|
+
if (NIL_P(options)) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
Check_Type(options, T_HASH);
|
|
384
|
+
|
|
385
|
+
static VALUE property_name = rb_id2sym(rb_intern("expiry"));
|
|
386
|
+
VALUE val = rb_hash_aref(options, property_name);
|
|
387
|
+
if (NIL_P(val)) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const auto [type, duration] = unpack_expiry(val);
|
|
391
|
+
switch (type) {
|
|
392
|
+
case expiry_type::relative:
|
|
393
|
+
field = couchbase::core::impl::expiry_relative(duration);
|
|
394
|
+
break;
|
|
395
|
+
case expiry_type::absolute:
|
|
396
|
+
field =
|
|
397
|
+
couchbase::core::impl::expiry_absolute(std::chrono::system_clock::time_point(duration));
|
|
398
|
+
break;
|
|
399
|
+
case expiry_type::none:
|
|
400
|
+
field = couchbase::core::impl::expiry_none();
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
void
|
|
406
|
+
cb_extract_expiry(std::optional<std::uint32_t>& field, VALUE options)
|
|
407
|
+
{
|
|
408
|
+
if (NIL_P(options)) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
Check_Type(options, T_HASH);
|
|
412
|
+
|
|
413
|
+
static VALUE property_name = rb_id2sym(rb_intern("expiry"));
|
|
414
|
+
VALUE val = rb_hash_aref(options, property_name);
|
|
415
|
+
if (NIL_P(val)) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const auto [type, duration] = unpack_expiry(val);
|
|
419
|
+
switch (type) {
|
|
420
|
+
case expiry_type::relative:
|
|
421
|
+
field = couchbase::core::impl::expiry_relative(duration);
|
|
422
|
+
break;
|
|
423
|
+
case expiry_type::absolute:
|
|
424
|
+
field =
|
|
425
|
+
couchbase::core::impl::expiry_absolute(std::chrono::system_clock::time_point(duration));
|
|
426
|
+
break;
|
|
427
|
+
case expiry_type::none:
|
|
428
|
+
field = couchbase::core::impl::expiry_none();
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
361
433
|
std::pair<expiry_type, std::chrono::seconds>
|
|
362
434
|
unpack_expiry(VALUE val, bool allow_nil)
|
|
363
435
|
{
|
|
@@ -568,6 +640,25 @@ get_symbol(VALUE options, VALUE name)
|
|
|
568
640
|
return {};
|
|
569
641
|
}
|
|
570
642
|
|
|
643
|
+
std::optional<VALUE>
|
|
644
|
+
get_hash(VALUE options, VALUE name)
|
|
645
|
+
{
|
|
646
|
+
if (!NIL_P(options) && TYPE(options) == T_HASH) {
|
|
647
|
+
cb_check_type(name, T_SYMBOL);
|
|
648
|
+
VALUE val = rb_hash_aref(options, name);
|
|
649
|
+
if (NIL_P(val)) {
|
|
650
|
+
return {};
|
|
651
|
+
}
|
|
652
|
+
if (TYPE(val) == T_HASH) {
|
|
653
|
+
return val;
|
|
654
|
+
}
|
|
655
|
+
throw couchbase::ruby::ruby_exception(
|
|
656
|
+
rb_eArgError,
|
|
657
|
+
rb_sprintf("%+" PRIsVALUE " must be a Hash, but given %+" PRIsVALUE, name, val));
|
|
658
|
+
}
|
|
659
|
+
return {};
|
|
660
|
+
}
|
|
661
|
+
|
|
571
662
|
std::optional<std::string>
|
|
572
663
|
get_string(VALUE options, VALUE name)
|
|
573
664
|
{
|