couchbase 3.6.0-aarch64-linux → 3.8.0-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 +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/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 +69 -3
- data/lib/couchbase/protostellar/cluster.rb +3 -0
- data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
- data/lib/couchbase/scope.rb +62 -48
- data/lib/couchbase/search_options.rb +25 -20
- 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 +37 -8
|
@@ -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
|