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