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
data/lib/couchbase/collection.rb
CHANGED
|
@@ -32,11 +32,15 @@ module Couchbase
|
|
|
32
32
|
# @param [String] bucket_name name of the bucket
|
|
33
33
|
# @param [String] scope_name name of the scope
|
|
34
34
|
# @param [String] collection_name name of the collection
|
|
35
|
-
|
|
35
|
+
# @param [Observability::Wrapper] observability wrapper containing tracer and meter
|
|
36
|
+
#
|
|
37
|
+
# @api private
|
|
38
|
+
def initialize(backend, bucket_name, scope_name, collection_name, observability)
|
|
36
39
|
@backend = backend
|
|
37
40
|
@bucket_name = bucket_name
|
|
38
41
|
@scope_name = scope_name
|
|
39
42
|
@name = collection_name
|
|
43
|
+
@observability = observability
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
# Provides access to the binary APIs, not used for JSON documents
|
|
@@ -48,7 +52,7 @@ module Couchbase
|
|
|
48
52
|
|
|
49
53
|
# @return [Management::CollectionQueryIndexManager]
|
|
50
54
|
def query_indexes
|
|
51
|
-
Management::CollectionQueryIndexManager.new(@backend, @bucket_name, @scope_name, @name)
|
|
55
|
+
Management::CollectionQueryIndexManager.new(@backend, @bucket_name, @scope_name, @name, @observability)
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
# Fetches the full document from the collection
|
|
@@ -78,17 +82,19 @@ module Couchbase
|
|
|
78
82
|
#
|
|
79
83
|
# @return [GetResult]
|
|
80
84
|
def get(id, options = Options::Get::DEFAULT)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
@observability.record_operation(Observability::OP_GET, options.parent_span, self, :kv) do |obs_handler|
|
|
86
|
+
resp = if options.need_projected_get?
|
|
87
|
+
@backend.document_get_projected(bucket_name, @scope_name, @name, id, options.to_backend, obs_handler)
|
|
88
|
+
else
|
|
89
|
+
@backend.document_get(bucket_name, @scope_name, @name, id, options.to_backend, obs_handler)
|
|
90
|
+
end
|
|
91
|
+
GetResult.new do |res|
|
|
92
|
+
res.transcoder = options.transcoder
|
|
93
|
+
res.cas = resp[:cas]
|
|
94
|
+
res.flags = resp[:flags]
|
|
95
|
+
res.encoded = resp[:content]
|
|
96
|
+
res.expiry = resp[:expiry] if resp.key?(:expiry)
|
|
97
|
+
end
|
|
92
98
|
end
|
|
93
99
|
end
|
|
94
100
|
|
|
@@ -107,15 +113,17 @@ module Couchbase
|
|
|
107
113
|
#
|
|
108
114
|
# @return [Array<GetResult>]
|
|
109
115
|
def get_multi(ids, options = Options::GetMulti::DEFAULT)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
@observability.record_operation(Observability::OP_GET_MULTI, options.parent_span, self, :kv) do |_obs_handler|
|
|
117
|
+
resp = @backend.document_get_multi(ids.map { |id| [bucket_name, @scope_name, @name, id] }, options.to_backend)
|
|
118
|
+
resp.map do |entry|
|
|
119
|
+
GetResult.new do |res|
|
|
120
|
+
res.transcoder = options.transcoder
|
|
121
|
+
res.id = entry[:id]
|
|
122
|
+
res.cas = entry[:cas]
|
|
123
|
+
res.flags = entry[:flags]
|
|
124
|
+
res.encoded = entry[:content]
|
|
125
|
+
res.error = entry[:error]
|
|
126
|
+
end
|
|
119
127
|
end
|
|
120
128
|
end
|
|
121
129
|
end
|
|
@@ -137,14 +145,16 @@ module Couchbase
|
|
|
137
145
|
#
|
|
138
146
|
# @return [GetResult]
|
|
139
147
|
def get_and_lock(id, lock_time, options = Options::GetAndLock::DEFAULT)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
@observability.record_operation(Observability::OP_GET_AND_LOCK, options.parent_span, self, :kv) do |obs_handler|
|
|
149
|
+
resp = @backend.document_get_and_lock(bucket_name, @scope_name, @name, id,
|
|
150
|
+
lock_time.respond_to?(:in_seconds) ? lock_time.in_seconds : lock_time,
|
|
151
|
+
options.to_backend, obs_handler)
|
|
152
|
+
GetResult.new do |res|
|
|
153
|
+
res.transcoder = options.transcoder
|
|
154
|
+
res.cas = resp[:cas]
|
|
155
|
+
res.flags = resp[:flags]
|
|
156
|
+
res.encoded = resp[:content]
|
|
157
|
+
end
|
|
148
158
|
end
|
|
149
159
|
end
|
|
150
160
|
|
|
@@ -159,14 +169,16 @@ module Couchbase
|
|
|
159
169
|
#
|
|
160
170
|
# @return [GetResult]
|
|
161
171
|
def get_and_touch(id, expiry, options = Options::GetAndTouch::DEFAULT)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
@observability.record_operation(Observability::OP_GET_AND_TOUCH, options.parent_span, self, :kv) do |obs_handler|
|
|
173
|
+
resp = @backend.document_get_and_touch(bucket_name, @scope_name, @name, id,
|
|
174
|
+
Utils::Time.extract_expiry_time(expiry),
|
|
175
|
+
options.to_backend, obs_handler)
|
|
176
|
+
GetResult.new do |res|
|
|
177
|
+
res.transcoder = options.transcoder
|
|
178
|
+
res.cas = resp[:cas]
|
|
179
|
+
res.flags = resp[:flags]
|
|
180
|
+
res.encoded = resp[:content]
|
|
181
|
+
end
|
|
170
182
|
end
|
|
171
183
|
end
|
|
172
184
|
|
|
@@ -177,14 +189,16 @@ module Couchbase
|
|
|
177
189
|
#
|
|
178
190
|
# @return [Array<GetReplicaResult>]
|
|
179
191
|
def get_all_replicas(id, options = Options::GetAllReplicas::DEFAULT)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
@observability.record_operation(Observability::OP_GET_ALL_REPLICAS, options.parent_span, self, :kv) do |obs_handler|
|
|
193
|
+
resp = @backend.document_get_all_replicas(@bucket_name, @scope_name, @name, id, options.to_backend, obs_handler)
|
|
194
|
+
resp.map do |entry|
|
|
195
|
+
GetReplicaResult.new do |res|
|
|
196
|
+
res.transcoder = options.transcoder
|
|
197
|
+
res.cas = entry[:cas]
|
|
198
|
+
res.flags = entry[:flags]
|
|
199
|
+
res.encoded = entry[:content]
|
|
200
|
+
res.is_replica = entry[:is_replica]
|
|
201
|
+
end
|
|
188
202
|
end
|
|
189
203
|
end
|
|
190
204
|
end
|
|
@@ -207,13 +221,15 @@ module Couchbase
|
|
|
207
221
|
#
|
|
208
222
|
# @return [GetReplicaResult]
|
|
209
223
|
def get_any_replica(id, options = Options::GetAnyReplica::DEFAULT)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
224
|
+
@observability.record_operation(Observability::OP_GET_ANY_REPLICA, options.parent_span, self, :kv) do |obs_handler|
|
|
225
|
+
resp = @backend.document_get_any_replica(@bucket_name, @scope_name, @name, id, options.to_backend, obs_handler)
|
|
226
|
+
GetReplicaResult.new do |res|
|
|
227
|
+
res.transcoder = options.transcoder
|
|
228
|
+
res.cas = resp[:cas]
|
|
229
|
+
res.flags = resp[:flags]
|
|
230
|
+
res.encoded = resp[:content]
|
|
231
|
+
res.is_replica = resp[:is_replica]
|
|
232
|
+
end
|
|
217
233
|
end
|
|
218
234
|
end
|
|
219
235
|
|
|
@@ -228,15 +244,17 @@ module Couchbase
|
|
|
228
244
|
#
|
|
229
245
|
# @return [ExistsResult]
|
|
230
246
|
def exists(id, options = Options::Exists::DEFAULT)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
@observability.record_operation(Observability::OP_EXISTS, options.parent_span, self, :kv) do |obs_handler|
|
|
248
|
+
resp = @backend.document_exists(bucket_name, @scope_name, @name, id, options.to_backend, obs_handler)
|
|
249
|
+
ExistsResult.new do |res|
|
|
250
|
+
res.deleted = resp[:deleted]
|
|
251
|
+
res.exists = resp[:exists]
|
|
252
|
+
res.expiry = resp[:expiry]
|
|
253
|
+
res.flags = resp[:flags]
|
|
254
|
+
res.sequence_number = resp[:sequence_number]
|
|
255
|
+
res.datatype = resp[:datatype]
|
|
256
|
+
res.cas = resp[:cas]
|
|
257
|
+
end
|
|
240
258
|
end
|
|
241
259
|
end
|
|
242
260
|
|
|
@@ -261,10 +279,13 @@ module Couchbase
|
|
|
261
279
|
#
|
|
262
280
|
# @return [MutationResult]
|
|
263
281
|
def remove(id, options = Options::Remove::DEFAULT)
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
282
|
+
@observability.record_operation(Observability::OP_REMOVE, options.parent_span, self, :kv) do |obs_handler|
|
|
283
|
+
obs_handler.add_durability_level(options.durability_level)
|
|
284
|
+
resp = @backend.document_remove(bucket_name, @scope_name, @name, id, options.to_backend, obs_handler)
|
|
285
|
+
MutationResult.new do |res|
|
|
286
|
+
res.cas = resp[:cas]
|
|
287
|
+
res.mutation_token = extract_mutation_token(resp)
|
|
288
|
+
end
|
|
268
289
|
end
|
|
269
290
|
end
|
|
270
291
|
|
|
@@ -287,22 +308,25 @@ module Couchbase
|
|
|
287
308
|
#
|
|
288
309
|
# @return [Array<MutationResult>]
|
|
289
310
|
def remove_multi(ids, options = Options::RemoveMulti::DEFAULT)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
311
|
+
@observability.record_operation(Observability::OP_REMOVE_MULTI, options.parent_span, self, :kv) do |obs_handler|
|
|
312
|
+
obs_handler.add_durability_level(options.durability_level)
|
|
313
|
+
resp = @backend.document_remove_multi(bucket_name, @scope_name, @name, ids.map do |id|
|
|
314
|
+
case id
|
|
315
|
+
when String
|
|
316
|
+
[id, nil]
|
|
317
|
+
when Array
|
|
318
|
+
id
|
|
319
|
+
else
|
|
320
|
+
raise ArgumentError, "id argument of remove_multi must be a String or Array<String, Integer>, given: #{id.inspect}"
|
|
321
|
+
end
|
|
322
|
+
end, options.to_backend)
|
|
323
|
+
resp.map do |entry|
|
|
324
|
+
MutationResult.new do |res|
|
|
325
|
+
res.cas = entry[:cas]
|
|
326
|
+
res.mutation_token = extract_mutation_token(entry)
|
|
327
|
+
res.error = entry[:error]
|
|
328
|
+
res.id = entry[:id]
|
|
329
|
+
end
|
|
306
330
|
end
|
|
307
331
|
end
|
|
308
332
|
end
|
|
@@ -327,11 +351,14 @@ module Couchbase
|
|
|
327
351
|
#
|
|
328
352
|
# @return [MutationResult]
|
|
329
353
|
def insert(id, content, options = Options::Insert::DEFAULT)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
354
|
+
@observability.record_operation(Observability::OP_INSERT, options.parent_span, self, :kv) do |obs_handler|
|
|
355
|
+
obs_handler.add_durability_level(options.durability_level)
|
|
356
|
+
blob, flags = encode_content(content, options, obs_handler)
|
|
357
|
+
resp = @backend.document_insert(bucket_name, @scope_name, @name, id, blob, flags, options.to_backend, obs_handler)
|
|
358
|
+
MutationResult.new do |res|
|
|
359
|
+
res.cas = resp[:cas]
|
|
360
|
+
res.mutation_token = extract_mutation_token(resp)
|
|
361
|
+
end
|
|
335
362
|
end
|
|
336
363
|
end
|
|
337
364
|
|
|
@@ -347,11 +374,14 @@ module Couchbase
|
|
|
347
374
|
#
|
|
348
375
|
# @return [MutationResult]
|
|
349
376
|
def upsert(id, content, options = Options::Upsert::DEFAULT)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
377
|
+
@observability.record_operation(Observability::OP_UPSERT, options.parent_span, self, :kv) do |obs_handler|
|
|
378
|
+
obs_handler.add_durability_level(options.durability_level)
|
|
379
|
+
blob, flags = encode_content(content, options, obs_handler)
|
|
380
|
+
resp = @backend.document_upsert(bucket_name, @scope_name, @name, id, blob, flags, options.to_backend, obs_handler)
|
|
381
|
+
MutationResult.new do |res|
|
|
382
|
+
res.cas = resp[:cas]
|
|
383
|
+
res.mutation_token = extract_mutation_token(resp)
|
|
384
|
+
end
|
|
355
385
|
end
|
|
356
386
|
end
|
|
357
387
|
|
|
@@ -374,16 +404,16 @@ module Couchbase
|
|
|
374
404
|
#
|
|
375
405
|
# @return [Array<MutationResult>]
|
|
376
406
|
def upsert_multi(id_content, options = Options::UpsertMulti::DEFAULT)
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
407
|
+
@observability.record_operation(Observability::OP_UPSERT, options.parent_span, self, :kv) do |obs_handler|
|
|
408
|
+
encoded_id_content = encode_content_multi(id_content, options, obs_handler)
|
|
409
|
+
resp = @backend.document_upsert_multi(bucket_name, @scope_name, @name, encoded_id_content, options.to_backend)
|
|
410
|
+
resp.map do |entry|
|
|
411
|
+
MutationResult.new do |res|
|
|
412
|
+
res.cas = entry[:cas]
|
|
413
|
+
res.mutation_token = extract_mutation_token(entry)
|
|
414
|
+
res.error = entry[:error]
|
|
415
|
+
res.id = entry[:id]
|
|
416
|
+
end
|
|
387
417
|
end
|
|
388
418
|
end
|
|
389
419
|
end
|
|
@@ -401,11 +431,14 @@ module Couchbase
|
|
|
401
431
|
#
|
|
402
432
|
# @return [MutationResult]
|
|
403
433
|
def replace(id, content, options = Options::Replace::DEFAULT)
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
434
|
+
@observability.record_operation(Observability::OP_REPLACE, options.parent_span, self, :kv) do |obs_handler|
|
|
435
|
+
obs_handler.add_durability_level(options.durability_level)
|
|
436
|
+
blob, flags = encode_content(content, options, obs_handler)
|
|
437
|
+
resp = @backend.document_replace(bucket_name, @scope_name, @name, id, blob, flags, options.to_backend, obs_handler)
|
|
438
|
+
MutationResult.new do |res|
|
|
439
|
+
res.cas = resp[:cas]
|
|
440
|
+
res.mutation_token = extract_mutation_token(resp)
|
|
441
|
+
end
|
|
409
442
|
end
|
|
410
443
|
end
|
|
411
444
|
|
|
@@ -420,11 +453,13 @@ module Couchbase
|
|
|
420
453
|
#
|
|
421
454
|
# @return [MutationResult]
|
|
422
455
|
def touch(id, expiry, options = Options::Touch::DEFAULT)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
456
|
+
@observability.record_operation(Observability::OP_TOUCH, options.parent_span, self, :kv) do |obs_handler|
|
|
457
|
+
resp = @backend.document_touch(bucket_name, @scope_name, @name, id,
|
|
458
|
+
Utils::Time.extract_expiry_time(expiry),
|
|
459
|
+
options.to_backend, obs_handler)
|
|
460
|
+
MutationResult.new do |res|
|
|
461
|
+
res.cas = resp[:cas]
|
|
462
|
+
end
|
|
428
463
|
end
|
|
429
464
|
end
|
|
430
465
|
|
|
@@ -442,7 +477,9 @@ module Couchbase
|
|
|
442
477
|
#
|
|
443
478
|
# @raise [Error::DocumentNotFound]
|
|
444
479
|
def unlock(id, cas, options = Options::Unlock::DEFAULT)
|
|
445
|
-
@
|
|
480
|
+
@observability.record_operation(Observability::OP_UNLOCK, options.parent_span, self, :kv) do |obs_handler|
|
|
481
|
+
@backend.document_unlock(bucket_name, @scope_name, @name, id, cas, options.to_backend, obs_handler)
|
|
482
|
+
end
|
|
446
483
|
end
|
|
447
484
|
|
|
448
485
|
# Performs lookups to document fragments
|
|
@@ -464,27 +501,29 @@ module Couchbase
|
|
|
464
501
|
# ]
|
|
465
502
|
# @return [LookupInResult]
|
|
466
503
|
def lookup_in(id, specs, options = Options::LookupIn::DEFAULT)
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
504
|
+
@observability.record_operation(Observability::OP_LOOKUP_IN, options.parent_span, self, :kv) do |obs_handler|
|
|
505
|
+
resp = @backend.document_lookup_in(
|
|
506
|
+
bucket_name, @scope_name, @name, id,
|
|
507
|
+
specs.map do |s|
|
|
508
|
+
{
|
|
509
|
+
opcode: s.type,
|
|
510
|
+
xattr: s.xattr?,
|
|
511
|
+
path: s.path,
|
|
512
|
+
}
|
|
513
|
+
end, options.to_backend, obs_handler
|
|
514
|
+
)
|
|
515
|
+
LookupInResult.new do |res|
|
|
516
|
+
res.transcoder = options.transcoder
|
|
517
|
+
res.cas = resp[:cas]
|
|
518
|
+
res.deleted = resp[:deleted]
|
|
519
|
+
res.encoded = resp[:fields].map do |field|
|
|
520
|
+
SubDocumentField.new do |f|
|
|
521
|
+
f.exists = field[:exists]
|
|
522
|
+
f.index = field[:index]
|
|
523
|
+
f.path = field[:path]
|
|
524
|
+
f.value = field[:value]
|
|
525
|
+
f.error = field[:error]
|
|
526
|
+
end
|
|
488
527
|
end
|
|
489
528
|
end
|
|
490
529
|
end
|
|
@@ -504,17 +543,19 @@ module Couchbase
|
|
|
504
543
|
# @raise [Error::CouchbaseError]
|
|
505
544
|
# @raise [Error::FeatureNotAvailable]
|
|
506
545
|
def lookup_in_any_replica(id, specs, options = Options::LookupInAnyReplica::DEFAULT)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
546
|
+
@observability.record_operation(Observability::OP_LOOKUP_IN_ANY_REPLICA, options.parent_span, self, :kv) do |obs_handler|
|
|
547
|
+
resp = @backend.document_lookup_in_any_replica(
|
|
548
|
+
bucket_name, @scope_name, @name, id,
|
|
549
|
+
specs.map do |s|
|
|
550
|
+
{
|
|
551
|
+
opcode: s.type,
|
|
552
|
+
xattr: s.xattr?,
|
|
553
|
+
path: s.path,
|
|
554
|
+
}
|
|
555
|
+
end, options.to_backend, obs_handler
|
|
556
|
+
)
|
|
557
|
+
extract_lookup_in_replica_result(resp, options)
|
|
558
|
+
end
|
|
518
559
|
end
|
|
519
560
|
|
|
520
561
|
# Performs lookups to document fragments. Reads from the active node and all available replicas and returns all of
|
|
@@ -531,18 +572,20 @@ module Couchbase
|
|
|
531
572
|
# @raise [Error::CouchbaseError]
|
|
532
573
|
# @raise [Error::FeatureNotAvailable]
|
|
533
574
|
def lookup_in_all_replicas(id, specs, options = Options::LookupInAllReplicas::DEFAULT)
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
575
|
+
@observability.record_operation(Observability::OP_LOOKUP_IN_ALL_REPLICAS, options.parent_span, self, :kv) do |obs_handler|
|
|
576
|
+
resp = @backend.document_lookup_in_all_replicas(
|
|
577
|
+
bucket_name, @scope_name, @name, id,
|
|
578
|
+
specs.map do |s|
|
|
579
|
+
{
|
|
580
|
+
opcode: s.type,
|
|
581
|
+
xattr: s.xattr?,
|
|
582
|
+
path: s.path,
|
|
583
|
+
}
|
|
584
|
+
end, options.to_backend, obs_handler
|
|
585
|
+
)
|
|
586
|
+
resp.map do |entry|
|
|
587
|
+
extract_lookup_in_replica_result(entry, options)
|
|
588
|
+
end
|
|
546
589
|
end
|
|
547
590
|
end
|
|
548
591
|
|
|
@@ -567,29 +610,32 @@ module Couchbase
|
|
|
567
610
|
#
|
|
568
611
|
# @return [MutateInResult]
|
|
569
612
|
def mutate_in(id, specs, options = Options::MutateIn::DEFAULT)
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
613
|
+
@observability.record_operation(Observability::OP_MUTATE_IN, options.parent_span, self, :kv) do |obs_handler|
|
|
614
|
+
obs_handler.add_durability_level(options.durability_level)
|
|
615
|
+
resp = @backend.document_mutate_in(
|
|
616
|
+
bucket_name, @scope_name, @name, id,
|
|
617
|
+
specs.map do |s|
|
|
618
|
+
{
|
|
619
|
+
opcode: s.type,
|
|
620
|
+
path: s.path,
|
|
621
|
+
param: s.param,
|
|
622
|
+
xattr: s.xattr?,
|
|
623
|
+
expand_macros: s.expand_macros?,
|
|
624
|
+
create_path: s.create_path?,
|
|
625
|
+
}
|
|
626
|
+
end, options.to_backend, obs_handler
|
|
627
|
+
)
|
|
628
|
+
MutateInResult.new do |res|
|
|
629
|
+
res.transcoder = options.transcoder
|
|
630
|
+
res.cas = resp[:cas]
|
|
631
|
+
res.deleted = resp[:deleted]
|
|
632
|
+
res.mutation_token = extract_mutation_token(resp)
|
|
633
|
+
res.encoded = resp[:fields].map do |field|
|
|
634
|
+
SubDocumentField.new do |f|
|
|
635
|
+
f.index = field[:index]
|
|
636
|
+
f.path = field[:path]
|
|
637
|
+
f.value = field[:value]
|
|
638
|
+
end
|
|
593
639
|
end
|
|
594
640
|
end
|
|
595
641
|
end
|
|
@@ -622,16 +668,41 @@ module Couchbase
|
|
|
622
668
|
# a lot of documents to find the matching documents. For low latency range queries, it is recommended that you use
|
|
623
669
|
# SQL++ with the necessary indexes.
|
|
624
670
|
def scan(scan_type, options = Options::Scan::DEFAULT)
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
671
|
+
@observability.record_operation(Observability::OP_SCAN, options.parent_span, self, :kv) do |_obs_handler|
|
|
672
|
+
ScanResults.new(
|
|
673
|
+
core_scan_result: @backend.document_scan_create(
|
|
674
|
+
@bucket_name, @scope_name, @name, scan_type.to_backend, options.to_backend
|
|
675
|
+
),
|
|
676
|
+
transcoder: options.transcoder,
|
|
677
|
+
)
|
|
678
|
+
end
|
|
631
679
|
end
|
|
632
680
|
|
|
633
681
|
private
|
|
634
682
|
|
|
683
|
+
def encode_content(content, options, obs_handler)
|
|
684
|
+
return [content, 0] unless options.transcoder
|
|
685
|
+
|
|
686
|
+
obs_handler.with_request_encoding_span do
|
|
687
|
+
options.transcoder.encode(content)
|
|
688
|
+
end
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
def encode_content_multi(id_content_pairs, options, obs_handler)
|
|
692
|
+
unless options.transcoder
|
|
693
|
+
return id_content_pairs.map do |(id, content)|
|
|
694
|
+
[id, content, 0]
|
|
695
|
+
end
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
obs_handler.with_request_encoding_span do
|
|
699
|
+
id_content_pairs.map do |(id, content)|
|
|
700
|
+
blob, flags = options.transcoder.encode(content)
|
|
701
|
+
[id, blob, flags]
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
|
|
635
706
|
def extract_mutation_token(resp)
|
|
636
707
|
return unless resp.key?(:mutation_token)
|
|
637
708
|
|