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
|
@@ -37,6 +37,7 @@ module Couchbase
|
|
|
37
37
|
@collection = collection
|
|
38
38
|
@options = options
|
|
39
39
|
@cas = 0
|
|
40
|
+
@observability = @collection.instance_variable_get(:@observability)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
# Calls the given block once for each element in the list, passing that element as a parameter.
|
|
@@ -44,38 +45,45 @@ module Couchbase
|
|
|
44
45
|
# @yieldparam [Object] item
|
|
45
46
|
#
|
|
46
47
|
# @return [CouchbaseList, Enumerable]
|
|
47
|
-
def each(&)
|
|
48
|
+
def each(parent_span: nil, &)
|
|
48
49
|
if block_given?
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
current =
|
|
51
|
+
@observability.record_operation(Observability::OP_LIST_EACH, parent_span, self) do |obs_handler|
|
|
52
|
+
options = @options.get_options.clone
|
|
53
|
+
options.parent_span = obs_handler.op_span
|
|
54
|
+
result = @collection.get(@id, options)
|
|
55
|
+
@cas = result.cas
|
|
56
|
+
result.content
|
|
57
|
+
rescue Error::DocumentNotFound
|
|
58
|
+
@cas = 0
|
|
59
|
+
[]
|
|
60
|
+
end
|
|
57
61
|
current.each(&)
|
|
58
62
|
self
|
|
59
63
|
else
|
|
60
|
-
enum_for(:each)
|
|
64
|
+
enum_for(:each, parent_span: parent_span)
|
|
61
65
|
end
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
# @return [Integer] returns the number of elements in the list.
|
|
65
|
-
def length
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
def length(parent_span: nil)
|
|
70
|
+
@observability.record_operation(Observability::OP_LIST_LENGTH, parent_span, self) do |obs_handler|
|
|
71
|
+
options = @options.lookup_in_options.clone
|
|
72
|
+
options.parent_span = obs_handler.op_span
|
|
73
|
+
result = @collection.lookup_in(@id, [
|
|
74
|
+
LookupInSpec.count(""),
|
|
75
|
+
], options)
|
|
76
|
+
result.content(0)
|
|
77
|
+
rescue Error::DocumentNotFound
|
|
78
|
+
0
|
|
79
|
+
end
|
|
72
80
|
end
|
|
73
81
|
|
|
74
82
|
alias size length
|
|
75
83
|
|
|
76
84
|
# @return [Boolean] returns true if list is empty
|
|
77
|
-
def empty?
|
|
78
|
-
size.zero?
|
|
85
|
+
def empty?(parent_span: nil)
|
|
86
|
+
size(parent_span: parent_span).zero?
|
|
79
87
|
end
|
|
80
88
|
|
|
81
89
|
# Appends the given object(s) on to the end of this error. This expression returns the array itself, so several
|
|
@@ -83,10 +91,14 @@ module Couchbase
|
|
|
83
91
|
#
|
|
84
92
|
# @param [Object...] obj object(s) to append
|
|
85
93
|
# @return [CouchbaseList]
|
|
86
|
-
def push(*obj)
|
|
87
|
-
@
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
def push(*obj, parent_span: nil)
|
|
95
|
+
@observability.record_operation(Observability::OP_LIST_PUSH, parent_span, self) do |obs_handler|
|
|
96
|
+
options = @options.mutate_in_options.clone
|
|
97
|
+
options.parent_span = obs_handler.op_span
|
|
98
|
+
@collection.mutate_in(@id, [
|
|
99
|
+
MutateInSpec.array_append("", obj),
|
|
100
|
+
], options)
|
|
101
|
+
end
|
|
90
102
|
self
|
|
91
103
|
end
|
|
92
104
|
|
|
@@ -96,10 +108,14 @@ module Couchbase
|
|
|
96
108
|
#
|
|
97
109
|
# @param [Object...] obj object(s) to prepend
|
|
98
110
|
# @return [CouchbaseList]
|
|
99
|
-
def unshift(*obj)
|
|
100
|
-
@
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
def unshift(*obj, parent_span: nil)
|
|
112
|
+
@observability.record_operation(Observability::OP_LIST_UNSHIFT, parent_span, self) do |obs_handler|
|
|
113
|
+
options = @options.mutate_in_options.clone
|
|
114
|
+
options.parent_span = obs_handler.op_span
|
|
115
|
+
@collection.mutate_in(@id, [
|
|
116
|
+
MutateInSpec.array_prepend("", obj),
|
|
117
|
+
], options)
|
|
118
|
+
end
|
|
103
119
|
self
|
|
104
120
|
end
|
|
105
121
|
|
|
@@ -110,10 +126,14 @@ module Couchbase
|
|
|
110
126
|
# @param [Integer] index
|
|
111
127
|
# @param [Object...] obj object(s) to insert
|
|
112
128
|
# @return [CouchbaseList]
|
|
113
|
-
def insert(index, *obj)
|
|
114
|
-
@
|
|
115
|
-
|
|
116
|
-
|
|
129
|
+
def insert(index, *obj, parent_span: nil)
|
|
130
|
+
@observability.record_operation(Observability::OP_LIST_INSERT, parent_span, self) do |obs_handler|
|
|
131
|
+
options = @options.mutate_in_options.clone
|
|
132
|
+
options.parent_span = obs_handler.op_span
|
|
133
|
+
@collection.mutate_in(@id, [
|
|
134
|
+
MutateInSpec.array_insert("[#{index.to_i}]", obj),
|
|
135
|
+
])
|
|
136
|
+
end
|
|
117
137
|
self
|
|
118
138
|
end
|
|
119
139
|
|
|
@@ -121,13 +141,17 @@ module Couchbase
|
|
|
121
141
|
#
|
|
122
142
|
# @param [Integer] index
|
|
123
143
|
# @return [Object, nil]
|
|
124
|
-
def at(index)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
def at(index, parent_span: nil)
|
|
145
|
+
@observability.record_operation(Observability::OP_LIST_AT, parent_span, self) do |obs_handler|
|
|
146
|
+
options = @options.mutate_in_options.clone
|
|
147
|
+
options.parent_span = obs_handler.op_span
|
|
148
|
+
result = @collection.lookup_in(@id, [
|
|
149
|
+
LookupInSpec.get("[#{index.to_i}]"),
|
|
150
|
+
], options)
|
|
151
|
+
result.exists?(0) ? result.content(0) : nil
|
|
152
|
+
rescue Error::DocumentNotFound
|
|
153
|
+
nil
|
|
154
|
+
end
|
|
131
155
|
end
|
|
132
156
|
|
|
133
157
|
alias [] at
|
|
@@ -136,21 +160,28 @@ module Couchbase
|
|
|
136
160
|
#
|
|
137
161
|
# @param [Integer] index
|
|
138
162
|
# @return [CouchbaseList]
|
|
139
|
-
def delete_at(index)
|
|
140
|
-
@
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
def delete_at(index, parent_span: nil)
|
|
164
|
+
@observability.record_operation(Observability::OP_LIST_DELETE_AT, parent_span, self) do |obs_handler|
|
|
165
|
+
options = Options::MutateIn.new(parent_span: obs_handler.op_span)
|
|
166
|
+
@collection.mutate_in(@id, [
|
|
167
|
+
MutateInSpec.remove("[#{index.to_i}]"),
|
|
168
|
+
], options)
|
|
169
|
+
self
|
|
170
|
+
rescue Error::DocumentNotFound
|
|
171
|
+
self
|
|
172
|
+
end
|
|
146
173
|
end
|
|
147
174
|
|
|
148
175
|
# Removes all elements from the list
|
|
149
|
-
def clear
|
|
150
|
-
@
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
176
|
+
def clear(parent_span: nil)
|
|
177
|
+
@observability.record_operation(Observability::OP_LIST_CLEAR, parent_span, self) do |obs_handler|
|
|
178
|
+
options = @options.remove_options.clone
|
|
179
|
+
options.parent_span = obs_handler.op_span
|
|
180
|
+
@collection.remove(@id, options)
|
|
181
|
+
nil
|
|
182
|
+
rescue Error::DocumentNotFound
|
|
183
|
+
nil
|
|
184
|
+
end
|
|
154
185
|
end
|
|
155
186
|
end
|
|
156
187
|
|
|
@@ -37,6 +37,7 @@ module Couchbase
|
|
|
37
37
|
@collection = collection
|
|
38
38
|
@options = options
|
|
39
39
|
@cas = 0
|
|
40
|
+
@observability = collection.instance_variable_get(:@observability)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
# Calls the given block once for each element in the map, passing that element as a parameter.
|
|
@@ -44,46 +45,57 @@ module Couchbase
|
|
|
44
45
|
# @yieldparam [Object] item
|
|
45
46
|
#
|
|
46
47
|
# @return [CouchbaseMap, Enumerable]
|
|
47
|
-
def each(&)
|
|
48
|
+
def each(parent_span: nil, &)
|
|
48
49
|
if block_given?
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
current =
|
|
51
|
+
@observability.record_operation(Observability::OP_MAP_EACH, parent_span, self) do |obs_handler|
|
|
52
|
+
options = @options.get_options.clone
|
|
53
|
+
options.parent_span = obs_handler.op_span
|
|
54
|
+
result = @collection.get(@id, options)
|
|
55
|
+
@cas = result.cas
|
|
56
|
+
result.content
|
|
57
|
+
rescue Error::DocumentNotFound
|
|
58
|
+
@cas = 0
|
|
59
|
+
[]
|
|
60
|
+
end
|
|
57
61
|
current.each(&)
|
|
58
62
|
self
|
|
59
63
|
else
|
|
60
|
-
enum_for(:each)
|
|
64
|
+
enum_for(:each, parent_span: parent_span)
|
|
61
65
|
end
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
# @return [Integer] returns the number of elements in the map.
|
|
65
|
-
def length
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
def length(parent_span: nil)
|
|
70
|
+
@observability.record_operation(Observability::OP_MAP_LENGTH, parent_span, self) do |obs_handler|
|
|
71
|
+
options = @options.lookup_in_options.clone
|
|
72
|
+
options.parent_span = obs_handler.op_span
|
|
73
|
+
result = @collection.lookup_in(@id, [
|
|
74
|
+
LookupInSpec.count(""),
|
|
75
|
+
], options)
|
|
76
|
+
result.content(0)
|
|
77
|
+
rescue Error::DocumentNotFound
|
|
78
|
+
0
|
|
79
|
+
end
|
|
72
80
|
end
|
|
73
81
|
|
|
74
82
|
alias size length
|
|
75
83
|
|
|
76
84
|
# @return [Boolean] returns true if map is empty
|
|
77
|
-
def empty?
|
|
78
|
-
size.zero?
|
|
85
|
+
def empty?(parent_span: nil)
|
|
86
|
+
size(parent_span: parent_span).zero?
|
|
79
87
|
end
|
|
80
88
|
|
|
81
89
|
# Removes all elements from the map
|
|
82
|
-
def clear
|
|
83
|
-
@
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
def clear(parent_span: nil)
|
|
91
|
+
@observability.record_operation(Observability::OP_MAP_CLEAR, parent_span, self) do |obs_handler|
|
|
92
|
+
options = @options.remove_options.clone
|
|
93
|
+
options.parent_span = obs_handler.op_span
|
|
94
|
+
@collection.remove(@id, options)
|
|
95
|
+
nil
|
|
96
|
+
rescue Error::DocumentNotFound
|
|
97
|
+
nil
|
|
98
|
+
end
|
|
87
99
|
end
|
|
88
100
|
|
|
89
101
|
# Returns a value from the map for the given key.
|
|
@@ -109,16 +121,20 @@ module Couchbase
|
|
|
109
121
|
# @yieldreturn [Object] the default value to return in case the key could not be found
|
|
110
122
|
#
|
|
111
123
|
# @return [Object]
|
|
112
|
-
def fetch(key, *rest)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
def fetch(key, *rest, parent_span: nil)
|
|
125
|
+
@observability.record_operation(Observability::OP_MAP_FETCH, parent_span, self) do |obs_handler|
|
|
126
|
+
options = @options.lookup_in_options.clone
|
|
127
|
+
options.parent_span = obs_handler.op_span
|
|
128
|
+
result = @collection.lookup_in(@id, [
|
|
129
|
+
LookupInSpec.get(key),
|
|
130
|
+
], options)
|
|
131
|
+
result.content(0)
|
|
132
|
+
rescue Error::DocumentNotFound, Error::PathNotFound
|
|
133
|
+
return yield if block_given?
|
|
134
|
+
return rest.first unless rest.empty?
|
|
135
|
+
|
|
136
|
+
raise KeyError, "key not found: #{key}"
|
|
137
|
+
end
|
|
122
138
|
end
|
|
123
139
|
|
|
124
140
|
# Returns a value from the map for the given key.
|
|
@@ -132,6 +148,22 @@ module Couchbase
|
|
|
132
148
|
fetch(key, nil)
|
|
133
149
|
end
|
|
134
150
|
|
|
151
|
+
# Associate the value given by +value+ with the key given by +key+.
|
|
152
|
+
#
|
|
153
|
+
# @param [String] key
|
|
154
|
+
# @param [Object] value
|
|
155
|
+
#
|
|
156
|
+
# @return [void]
|
|
157
|
+
def store(key, value, parent_span: nil)
|
|
158
|
+
@observability.record_operation(Observability::OP_MAP_STORE, parent_span, self) do |obs_handler|
|
|
159
|
+
options = @options.mutate_in_options.clone
|
|
160
|
+
options.parent_span = obs_handler.op_span
|
|
161
|
+
@collection.mutate_in(@id, [
|
|
162
|
+
MutateInSpec.upsert(key, value),
|
|
163
|
+
], options)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
135
167
|
# Associate the value given by +value+ with the key given by +key+.
|
|
136
168
|
#
|
|
137
169
|
# @param [String] key
|
|
@@ -139,9 +171,7 @@ module Couchbase
|
|
|
139
171
|
#
|
|
140
172
|
# @return [void]
|
|
141
173
|
def []=(key, value)
|
|
142
|
-
|
|
143
|
-
MutateInSpec.upsert(key, value),
|
|
144
|
-
], @options.mutate_in_options)
|
|
174
|
+
store(key, value)
|
|
145
175
|
end
|
|
146
176
|
|
|
147
177
|
# Deletes the key-value pair from the map.
|
|
@@ -149,25 +179,31 @@ module Couchbase
|
|
|
149
179
|
# @param [String] key
|
|
150
180
|
#
|
|
151
181
|
# @return void
|
|
152
|
-
def delete(key)
|
|
153
|
-
@
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
182
|
+
def delete(key, parent_span: nil)
|
|
183
|
+
@observability.record_operation(Observability::OP_MAP_DELETE, parent_span, self) do |obs_handler|
|
|
184
|
+
@collection.mutate_in(@id, [
|
|
185
|
+
MutateInSpec.remove(key),
|
|
186
|
+
], Options::MutateIn.new(parent_span: obs_handler.op_span))
|
|
187
|
+
rescue Error::DocumentNotFound, Error::PathNotFound
|
|
188
|
+
nil
|
|
189
|
+
end
|
|
158
190
|
end
|
|
159
191
|
|
|
160
192
|
# Returns +true+ if the given key is present
|
|
161
193
|
#
|
|
162
194
|
# @param [String] key
|
|
163
195
|
# @return [Boolean]
|
|
164
|
-
def key?(key)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
196
|
+
def key?(key, parent_span: nil)
|
|
197
|
+
@observability.record_operation(Observability::OP_MAP_KEY_EXISTS, parent_span, self) do |obs_handler|
|
|
198
|
+
options = @options.lookup_in_options.clone
|
|
199
|
+
options.parent_span = obs_handler.op_span
|
|
200
|
+
result = @collection.lookup_in(@id, [
|
|
201
|
+
LookupInSpec.exists(key),
|
|
202
|
+
], options)
|
|
203
|
+
result.exists?(0)
|
|
204
|
+
rescue Error::DocumentNotFound, Error::PathNotFound
|
|
205
|
+
false
|
|
206
|
+
end
|
|
171
207
|
end
|
|
172
208
|
|
|
173
209
|
alias member? key?
|
|
@@ -37,6 +37,7 @@ module Couchbase
|
|
|
37
37
|
@collection = collection
|
|
38
38
|
@options = options
|
|
39
39
|
@cas = 0
|
|
40
|
+
@observability = @collection.instance_variable_get(:@observability)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
# Calls the given block once for each element in the queue, passing that element as a parameter.
|
|
@@ -44,57 +45,69 @@ module Couchbase
|
|
|
44
45
|
# @yieldparam [Object] item
|
|
45
46
|
#
|
|
46
47
|
# @return [CouchbaseQueue, Enumerable]
|
|
47
|
-
def each(&)
|
|
48
|
+
def each(parent_span: nil, &)
|
|
48
49
|
if block_given?
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
current = @observability.record_operation(Observability::OP_QUEUE_EACH, parent_span, self) do |obs_handler|
|
|
51
|
+
options = @options.get_options.clone
|
|
52
|
+
options.parent_span = obs_handler.op_span
|
|
53
|
+
result = @collection.get(@id, options)
|
|
52
54
|
@cas = result.cas
|
|
55
|
+
result.content
|
|
53
56
|
rescue Error::DocumentNotFound
|
|
54
|
-
current = []
|
|
55
57
|
@cas = 0
|
|
58
|
+
[]
|
|
56
59
|
end
|
|
57
60
|
current.each(&)
|
|
58
61
|
self
|
|
59
62
|
else
|
|
60
|
-
enum_for(:each)
|
|
63
|
+
enum_for(:each, parent_span: parent_span)
|
|
61
64
|
end
|
|
62
65
|
end
|
|
63
66
|
|
|
64
67
|
# @return [Integer] returns the number of elements in the queue.
|
|
65
|
-
def length
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
def length(parent_span: nil)
|
|
69
|
+
@observability.record_operation(Observability::OP_QUEUE_LENGTH, parent_span, self) do |obs_handler|
|
|
70
|
+
options = @options.lookup_in_options.clone
|
|
71
|
+
options.parent_span = obs_handler.op_span
|
|
72
|
+
result = @collection.lookup_in(@id, [
|
|
73
|
+
LookupInSpec.count(""),
|
|
74
|
+
], options)
|
|
75
|
+
result.content(0)
|
|
76
|
+
rescue Error::DocumentNotFound
|
|
77
|
+
0
|
|
78
|
+
end
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
alias size length
|
|
75
82
|
|
|
76
83
|
# @return [Boolean] returns true if queue is empty
|
|
77
|
-
def empty?
|
|
78
|
-
size.zero?
|
|
84
|
+
def empty?(parent_span: nil)
|
|
85
|
+
size(parent_span: parent_span).zero?
|
|
79
86
|
end
|
|
80
87
|
|
|
81
88
|
# Removes all elements from the queue
|
|
82
|
-
def clear
|
|
83
|
-
@
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
def clear(parent_span: nil)
|
|
90
|
+
@observability.record_operation(Observability::OP_QUEUE_CLEAR, parent_span, self) do |obs_handler|
|
|
91
|
+
options = @options.remove_options.clone
|
|
92
|
+
options.parent_span = obs_handler.op_span
|
|
93
|
+
@collection.remove(@id, options)
|
|
94
|
+
nil
|
|
95
|
+
rescue Error::DocumentNotFound
|
|
96
|
+
nil
|
|
97
|
+
end
|
|
87
98
|
end
|
|
88
99
|
|
|
89
100
|
# Adds the given value to the queue
|
|
90
101
|
#
|
|
91
102
|
# @param [Object] obj
|
|
92
103
|
# @return [CouchbaseQueue]
|
|
93
|
-
def push(obj)
|
|
94
|
-
|
|
104
|
+
def push(obj, parent_span: nil)
|
|
105
|
+
@observability.record_operation(Observability::OP_QUEUE_PUSH, parent_span, self) do |obs_handler|
|
|
106
|
+
options = @options.mutate_in_options.clone
|
|
107
|
+
options.parent_span = obs_handler.op_span
|
|
95
108
|
@collection.mutate_in(@id, [
|
|
96
109
|
MutateInSpec.array_prepend("", [obj]),
|
|
97
|
-
],
|
|
110
|
+
], options)
|
|
98
111
|
rescue Error::PathExists
|
|
99
112
|
# ignore
|
|
100
113
|
end
|
|
@@ -107,21 +120,34 @@ module Couchbase
|
|
|
107
120
|
# Retrieves object from the queue
|
|
108
121
|
#
|
|
109
122
|
# @return [Object, nil] queue entry or nil
|
|
110
|
-
def pop
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
def pop(parent_span: nil)
|
|
124
|
+
@observability.record_operation(Observability::OP_QUEUE_POP, parent_span, self) do |obs_handler|
|
|
125
|
+
obj, cas = begin
|
|
126
|
+
options = @options.lookup_in_options.clone
|
|
127
|
+
options.parent_span = obs_handler.op_span
|
|
128
|
+
result = @collection.lookup_in(@id, [
|
|
129
|
+
LookupInSpec.get("[-1]"),
|
|
130
|
+
], @options.lookup_in_options)
|
|
131
|
+
[
|
|
132
|
+
result.exists?(0) ? result.content(0) : nil,
|
|
133
|
+
result.cas,
|
|
134
|
+
]
|
|
135
|
+
end
|
|
136
|
+
begin
|
|
137
|
+
options = Options::MutateIn.new(
|
|
138
|
+
parent_span: obs_handler.op_span,
|
|
139
|
+
cas: cas,
|
|
140
|
+
)
|
|
141
|
+
@collection.mutate_in(@id, [
|
|
142
|
+
MutateInSpec.remove("[-1]"),
|
|
143
|
+
], options)
|
|
144
|
+
end
|
|
145
|
+
obj
|
|
146
|
+
rescue Error::CasMismatch
|
|
147
|
+
retry
|
|
148
|
+
rescue Error::DocumentNotFound, Error::PathNotFound
|
|
149
|
+
nil
|
|
150
|
+
end
|
|
125
151
|
end
|
|
126
152
|
|
|
127
153
|
alias deq pop
|