couchbase 4.4.2 → 4.4.3

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.
Files changed (98) hide show
  1. package/CMakeLists.txt +2 -0
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +17 -14
  3. package/deps/couchbase-cxx-client/README.md +2 -2
  4. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +4 -0
  5. package/deps/couchbase-cxx-client/cmake/Testing.cmake +1 -1
  6. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +24 -2
  7. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +43 -4
  8. package/deps/couchbase-cxx-client/core/agent_group.cxx +8 -0
  9. package/deps/couchbase-cxx-client/core/agent_group.hxx +4 -0
  10. package/deps/couchbase-cxx-client/core/bucket.cxx +16 -20
  11. package/deps/couchbase-cxx-client/core/bucket.hxx +12 -12
  12. package/deps/couchbase-cxx-client/core/cluster.cxx +44 -52
  13. package/deps/couchbase-cxx-client/core/cluster_agent.cxx +8 -0
  14. package/deps/couchbase-cxx-client/core/cluster_agent.hxx +4 -0
  15. package/deps/couchbase-cxx-client/core/collections_component.cxx +2 -2
  16. package/deps/couchbase-cxx-client/core/columnar/agent.cxx +2 -2
  17. package/deps/couchbase-cxx-client/core/columnar/agent.hxx +1 -1
  18. package/deps/couchbase-cxx-client/core/columnar/management_component.cxx +3 -3
  19. package/deps/couchbase-cxx-client/core/columnar/query_component.cxx +103 -45
  20. package/deps/couchbase-cxx-client/core/columnar/query_component.hxx +1 -0
  21. package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +8 -0
  22. package/deps/couchbase-cxx-client/core/http_component.cxx +55 -24
  23. package/deps/couchbase-cxx-client/core/http_component.hxx +4 -0
  24. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +15 -15
  25. package/deps/couchbase-cxx-client/core/impl/bootstrap_error.hxx +10 -2
  26. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +1 -1
  27. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +6 -6
  28. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +36 -40
  29. package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
  30. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +5 -5
  31. package/deps/couchbase-cxx-client/core/impl/observe_poll.cxx +13 -5
  32. package/deps/couchbase-cxx-client/core/impl/observe_poll.hxx +1 -3
  33. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  34. package/deps/couchbase-cxx-client/core/impl/scan_result.cxx +1 -1
  35. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +12 -12
  36. package/deps/couchbase-cxx-client/core/io/http_command.hxx +31 -20
  37. package/deps/couchbase-cxx-client/core/io/http_session.cxx +5 -0
  38. package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -4
  39. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -49
  40. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +15 -14
  41. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  42. package/deps/couchbase-cxx-client/core/io/streams.cxx +256 -0
  43. package/deps/couchbase-cxx-client/core/io/streams.hxx +31 -155
  44. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +5 -0
  45. package/deps/couchbase-cxx-client/core/logger/custom_rotating_file_sink.cxx +2 -3
  46. package/deps/couchbase-cxx-client/core/logger/logger.cxx +39 -7
  47. package/deps/couchbase-cxx-client/core/logger/logger.hxx +7 -0
  48. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +188 -0
  49. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +73 -0
  50. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.cxx +2 -1
  51. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.cxx +3 -1
  52. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.cxx +3 -1
  53. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.cxx +3 -1
  54. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.cxx +3 -1
  55. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +3 -2
  56. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +5 -2
  57. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +4 -2
  58. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.cxx +3 -3
  59. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +2 -1
  60. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +4 -1
  61. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.cxx +3 -1
  62. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +3 -2
  63. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +3 -2
  64. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +3 -2
  65. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +3 -2
  66. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +5 -2
  67. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +5 -2
  68. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +4 -2
  69. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +3 -2
  70. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +5 -2
  71. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.cxx +2 -1
  72. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.cxx +2 -1
  73. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.cxx +3 -1
  74. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.cxx +2 -1
  75. package/deps/couchbase-cxx-client/core/origin.cxx +37 -17
  76. package/deps/couchbase-cxx-client/core/platform/base64.cc +1 -1
  77. package/deps/couchbase-cxx-client/core/platform/random.cc +2 -0
  78. package/deps/couchbase-cxx-client/core/platform/uuid.h +6 -6
  79. package/deps/couchbase-cxx-client/core/row_streamer.cxx +1 -1
  80. package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.cc +1 -1
  81. package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.h +4 -4
  82. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +2 -0
  83. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +8 -0
  84. package/deps/couchbase-cxx-client/core/tracing/constants.hxx +3 -0
  85. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +87 -0
  86. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +57 -0
  87. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +16 -15
  88. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +2 -2
  89. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +2 -2
  90. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +2 -2
  91. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +128 -52
  92. package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +4 -3
  93. package/deps/couchbase-cxx-client/couchbase/codec/tao_json_serializer.hxx +1 -1
  94. package/deps/couchbase-cxx-client/couchbase/mutate_in_specs.hxx +2 -2
  95. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +4 -3
  96. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +1 -1
  97. package/package.json +8 -8
  98. package/src/binding.cpp +13 -13
@@ -269,7 +269,7 @@ public:
269
269
  {},
270
270
  options.timeout,
271
271
  },
272
- [handler = std::move(handler)](auto resp) mutable {
272
+ [handler = std::move(handler)](const auto& resp) mutable {
273
273
  return handler(core::impl::make_error(resp.ctx), map_bucket_settings(resp.bucket));
274
274
  });
275
275
  }
@@ -282,7 +282,7 @@ public:
282
282
  {},
283
283
  options.timeout,
284
284
  },
285
- [handler = std::move(handler)](auto resp) mutable {
285
+ [handler = std::move(handler)](const auto& resp) mutable {
286
286
  return handler(core::impl::make_error(resp.ctx), map_all_bucket_settings(resp.buckets));
287
287
  });
288
288
  }
@@ -297,7 +297,7 @@ public:
297
297
  {},
298
298
  options.timeout,
299
299
  },
300
- [handler = std::move(handler)](auto resp) mutable {
300
+ [handler = std::move(handler)](const auto& resp) mutable {
301
301
  return handler(core::impl::make_error(resp.ctx));
302
302
  });
303
303
  }
@@ -312,7 +312,7 @@ public:
312
312
  {},
313
313
  options.timeout,
314
314
  },
315
- [handler = std::move(handler)](auto resp) mutable {
315
+ [handler = std::move(handler)](const auto& resp) mutable {
316
316
  return handler(core::impl::make_error(resp.ctx));
317
317
  });
318
318
  }
@@ -327,7 +327,7 @@ public:
327
327
  {},
328
328
  options.timeout,
329
329
  },
330
- [handler = std::move(handler)](auto resp) mutable {
330
+ [handler = std::move(handler)](const auto& resp) mutable {
331
331
  return handler(core::impl::make_error(resp.ctx));
332
332
  });
333
333
  }
@@ -342,7 +342,7 @@ public:
342
342
  {},
343
343
  options.timeout,
344
344
  },
345
- [handler = std::move(handler)](auto resp) mutable {
345
+ [handler = std::move(handler)](const auto& resp) mutable {
346
346
  return handler(core::impl::make_error(resp.ctx));
347
347
  });
348
348
  }
@@ -230,21 +230,8 @@ public:
230
230
  // We cannot use close() method here, as it is capturing self as a shared
231
231
  // pointer to extend lifetime for the user's callback. Here the reference
232
232
  // counter has reached zero already, so we can only capture `*this`.
233
- std::thread([this, &barrier]() mutable {
234
- if (auto txns = std::move(transactions_); txns != nullptr) {
235
- // blocks until cleanup is finished
236
- txns->close();
237
- }
238
- std::promise<void> core_stopped;
239
- auto f = core_stopped.get_future();
240
- core_.close([&core_stopped]() {
241
- core_stopped.set_value();
242
- });
243
- f.get();
244
- io_.stop();
245
- if (io_thread_.joinable()) {
246
- io_thread_.join();
247
- }
233
+ std::thread([this, barrier = std::move(barrier)]() mutable {
234
+ do_close();
248
235
  barrier.set_value();
249
236
  }).detach();
250
237
 
@@ -291,7 +278,7 @@ public:
291
278
  }));
292
279
  return;
293
280
  }
294
- impl->transactions_ = txns;
281
+ impl->transactions_ = std::move(txns);
295
282
  handler(ec, couchbase::cluster(std::move(impl)));
296
283
  });
297
284
  });
@@ -323,16 +310,17 @@ public:
323
310
  {},
324
311
  core::impl::to_core_service_types(options.service_types),
325
312
  options.timeout,
326
- [handler = std::move(handler)](auto resp) mutable {
313
+ [handler = std::move(handler)](const auto& resp) mutable {
327
314
  return handler({}, core::impl::build_result(resp));
328
315
  });
329
316
  };
330
317
 
331
318
  void diagnostics(const diagnostics_options::built& options, diagnostics_handler&& handler) const
332
319
  {
333
- return core_.diagnostics(options.report_id, [handler = std::move(handler)](auto resp) mutable {
334
- return handler({}, core::impl::build_result(resp));
335
- });
320
+ return core_.diagnostics(options.report_id,
321
+ [handler = std::move(handler)](const auto& resp) mutable {
322
+ return handler({}, core::impl::build_result(resp));
323
+ });
336
324
  }
337
325
 
338
326
  void search(std::string index_name,
@@ -342,7 +330,7 @@ public:
342
330
  {
343
331
  return core_.execute(
344
332
  core::impl::build_search_request(std::move(index_name), std::move(request), options, {}, {}),
345
- [handler = std::move(handler)](auto resp) mutable {
333
+ [handler = std::move(handler)](const auto& resp) mutable {
346
334
  return handler(core::impl::make_error(resp.ctx),
347
335
  search_result{ internal_search_result{ resp } });
348
336
  });
@@ -371,20 +359,7 @@ public:
371
359
  {
372
360
  // Spawn new thread to avoid joining IO thread from the same thread
373
361
  std::thread([self = shared_from_this(), handler = std::move(handler)]() mutable {
374
- if (auto txns = std::move(self->transactions_); txns != nullptr) {
375
- // blocks until cleanup is finished
376
- txns->close();
377
- }
378
- std::promise<void> barrier;
379
- auto future = barrier.get_future();
380
- self->core_.close([&barrier]() {
381
- barrier.set_value();
382
- });
383
- future.get();
384
- self->io_.stop();
385
- if (self->io_thread_.joinable()) {
386
- self->io_thread_.join();
387
- }
362
+ self->do_close();
388
363
  handler();
389
364
  }).detach();
390
365
  }
@@ -400,7 +375,25 @@ public:
400
375
  }
401
376
 
402
377
  private:
403
- asio::io_context io_{ ASIO_CONCURRENCY_HINT_1 };
378
+ void do_close()
379
+ {
380
+ if (auto txns = std::move(transactions_); txns != nullptr) {
381
+ // blocks until cleanup is finished
382
+ txns->close();
383
+ }
384
+ std::promise<void> core_stopped;
385
+ auto f = core_stopped.get_future();
386
+ core_.close([core_stopped = std::move(core_stopped)]() mutable {
387
+ core_stopped.set_value();
388
+ });
389
+ f.get();
390
+ io_.stop();
391
+ if (io_thread_.joinable()) {
392
+ io_thread_.join();
393
+ }
394
+ }
395
+
396
+ asio::io_context io_{ ASIO_CONCURRENCY_HINT_SAFE };
404
397
  core::cluster core_{ io_ };
405
398
  std::shared_ptr<core::transactions::transactions> transactions_{ nullptr };
406
399
  std::thread io_thread_{ [&io = io_] {
@@ -539,12 +532,15 @@ cluster::connect(const std::string& connection_string,
539
532
  // Spawn new thread for connection to ensure that cluster_impl pointer will
540
533
  // not be deallocated in IO thread in case of error.
541
534
  std::thread([connection_string, options, handler = std::move(handler)]() {
542
- auto impl = std::make_shared<cluster_impl>();
543
535
  auto barrier = std::make_shared<std::promise<std::pair<error, cluster>>>();
544
536
  auto future = barrier->get_future();
545
- impl->open(connection_string, options, [barrier](auto err, auto c) {
546
- barrier->set_value({ std::move(err), std::move(c) });
547
- });
537
+ {
538
+ auto impl = std::make_shared<cluster_impl>();
539
+ impl->open(connection_string, options, [barrier](auto err, auto c) {
540
+ barrier->set_value({ std::move(err), std::move(c) });
541
+ });
542
+ }
543
+
548
544
  auto [err, c] = future.get();
549
545
  handler(std::move(err), std::move(c));
550
546
  }).detach();
@@ -211,7 +211,7 @@ public:
211
211
  options.timeout,
212
212
  { options.retry_strategy },
213
213
  },
214
- [handler = std::move(handler)](auto resp) mutable {
214
+ [handler = std::move(handler)](const auto& resp) mutable {
215
215
  return handler(core::impl::make_error(std::move(resp.ctx)), result{ resp.cas });
216
216
  });
217
217
  }
@@ -1390,7 +1390,7 @@ collection::scan(const couchbase::scan_type& scan_type, const couchbase::scan_op
1390
1390
  {
1391
1391
  auto barrier = std::make_shared<std::promise<std::pair<error, scan_result>>>();
1392
1392
  auto future = barrier->get_future();
1393
- scan(scan_type, options, [barrier](auto err, auto result) {
1393
+ scan(scan_type, options, [barrier](const auto& err, auto result) {
1394
1394
  barrier->set_value({ err, std::move(result) });
1395
1395
  });
1396
1396
  return future;
@@ -101,7 +101,7 @@ public:
101
101
  {},
102
102
  options.timeout,
103
103
  },
104
- [handler = std::move(handler)](auto resp) mutable {
104
+ [handler = std::move(handler)](const auto& resp) mutable {
105
105
  return handler(core::impl::make_error(resp.ctx));
106
106
  });
107
107
  }
@@ -122,7 +122,7 @@ public:
122
122
  {},
123
123
  options.timeout,
124
124
  },
125
- [handler = std::move(handler)](auto resp) mutable {
125
+ [handler = std::move(handler)](const auto& resp) mutable {
126
126
  return handler(core::impl::make_error(resp.ctx));
127
127
  });
128
128
  }
@@ -143,7 +143,7 @@ public:
143
143
  {},
144
144
  options.timeout,
145
145
  },
146
- [handler = std::move(handler)](auto resp) mutable {
146
+ [handler = std::move(handler)](const auto& resp) mutable {
147
147
  return handler(core::impl::make_error(resp.ctx));
148
148
  });
149
149
  }
@@ -173,7 +173,7 @@ public:
173
173
  {},
174
174
  options.timeout,
175
175
  },
176
- [handler = std::move(handler)](auto resp) mutable {
176
+ [handler = std::move(handler)](const auto& resp) mutable {
177
177
  return handler(core::impl::make_error(resp.ctx));
178
178
  });
179
179
  }
@@ -189,7 +189,7 @@ public:
189
189
  {},
190
190
  options.timeout,
191
191
  },
192
- [handler = std::move(handler)](auto resp) mutable {
192
+ [handler = std::move(handler)](const auto& resp) mutable {
193
193
  return handler(core::impl::make_error(resp.ctx));
194
194
  });
195
195
  }
@@ -26,6 +26,7 @@
26
26
 
27
27
  #include <memory>
28
28
  #include <mutex>
29
+ #include <system_error>
29
30
 
30
31
  namespace couchbase::core::impl
31
32
  {
@@ -240,8 +241,7 @@ public:
240
241
  void handle_response(observe_seqno_response&& response)
241
242
  {
242
243
  --expect_number_of_responses_;
243
- auto r = std::move(response);
244
- status_.examine(r);
244
+ status_.examine(response);
245
245
  maybe_finish();
246
246
  }
247
247
 
@@ -249,6 +249,8 @@ public:
249
249
  {
250
250
  poll_backoff_.cancel();
251
251
  poll_deadline_.cancel();
252
+ on_last_response(0, [](std::error_code) {
253
+ });
252
254
  observe_handler handler{};
253
255
  {
254
256
  const std::scoped_lock lock(handler_mutex_);
@@ -268,10 +270,16 @@ public:
268
270
  return;
269
271
  }
270
272
  if (status_.meets_condition(persist_to_, replicate_to_)) {
273
+ poll_backoff_.cancel();
274
+ poll_deadline_.cancel();
275
+ on_last_response(0, [](std::error_code) {
276
+ });
271
277
  std::swap(handler_, handler);
272
- } else if (expect_number_of_responses_ == 0 && on_last_response_) {
273
- poll_backoff_.expires_after(poll_backoff_interval_);
274
- return poll_backoff_.async_wait(std::move(on_last_response_));
278
+ } else if (expect_number_of_responses_ == 0) {
279
+ if (auto on_last_response = std::move(on_last_response_); on_last_response) {
280
+ poll_backoff_.expires_after(poll_backoff_interval_);
281
+ return poll_backoff_.async_wait(std::move(on_last_response));
282
+ }
275
283
  }
276
284
  }
277
285
  if (handler) {
@@ -17,7 +17,6 @@
17
17
 
18
18
  #pragma once
19
19
 
20
- #include "core/error_context/key_value_error_context.hxx"
21
20
  #include <couchbase/mutation_token.hxx>
22
21
  #include <couchbase/persist_to.hxx>
23
22
  #include <couchbase/replicate_to.hxx>
@@ -26,8 +25,7 @@
26
25
  #include "core/utils/movable_function.hxx"
27
26
 
28
27
  #include <chrono>
29
- #include <functional>
30
- #include <memory>
28
+ #include <system_error>
31
29
 
32
30
  namespace couchbase::core
33
31
  {
@@ -232,7 +232,7 @@ public:
232
232
  {},
233
233
  options.timeout,
234
234
  },
235
- [handler = std::move(handler)](auto resp) {
235
+ [handler = std::move(handler)](const auto& resp) {
236
236
  handler(core::impl::make_error(resp.ctx));
237
237
  });
238
238
  }
@@ -259,7 +259,7 @@ public:
259
259
  {},
260
260
  options.timeout,
261
261
  },
262
- [handler = std::move(handler)](auto resp) {
262
+ [handler = std::move(handler)](const auto& resp) {
263
263
  handler(core::impl::make_error(resp.ctx));
264
264
  });
265
265
  }
@@ -283,7 +283,7 @@ public:
283
283
  {},
284
284
  options.timeout,
285
285
  },
286
- [handler = std::move(handler)](auto resp) {
286
+ [handler = std::move(handler)](const auto& resp) {
287
287
  handler(core::impl::make_error(resp.ctx));
288
288
  });
289
289
  }
@@ -342,7 +342,7 @@ public:
342
342
  std::move(list_resp.index_names),
343
343
  {},
344
344
  timeout },
345
- [handler = std::move(handler)](auto build_resp) {
345
+ [handler = std::move(handler)](const auto& build_resp) {
346
346
  return handler(core::impl::make_error(build_resp.ctx));
347
347
  });
348
348
  });
@@ -390,7 +390,7 @@ query_index_manager::get_all_indexes(const std::string& bucket_name,
390
390
  auto barrier =
391
391
  std::make_shared<std::promise<std::pair<error, std::vector<management::query_index>>>>();
392
392
  auto future = barrier->get_future();
393
- get_all_indexes(bucket_name, options, [barrier](auto err, auto resp) mutable {
393
+ get_all_indexes(bucket_name, options, [barrier](auto err, const auto& resp) mutable {
394
394
  barrier->set_value({ std::move(err), resp });
395
395
  });
396
396
  return future;
@@ -563,7 +563,7 @@ collection_query_index_manager::get_all_indexes(const get_all_query_indexes_opti
563
563
  auto barrier =
564
564
  std::make_shared<std::promise<std::pair<error, std::vector<management::query_index>>>>();
565
565
  auto future = barrier->get_future();
566
- get_all_indexes(options, [barrier](auto err, auto resp) mutable {
566
+ get_all_indexes(options, [barrier](auto err, const auto& resp) mutable {
567
567
  barrier->set_value({ std::move(err), resp });
568
568
  });
569
569
  return future;
@@ -97,7 +97,7 @@ scan_result::next() const -> std::future<std::pair<error, std::optional<scan_res
97
97
  {
98
98
  auto barrier =
99
99
  std::make_shared<std::promise<std::pair<error, std::optional<scan_result_item>>>>();
100
- internal_->next([barrier](auto err, auto item) mutable {
100
+ internal_->next([barrier](const auto& err, const auto& item) mutable {
101
101
  barrier->set_value({ err, item });
102
102
  });
103
103
  return barrier->get_future();
@@ -150,7 +150,7 @@ public:
150
150
  core_.execute(
151
151
  core::operations::management::search_index_get_request{
152
152
  std::move(index_name), bucket_name_, scope_name_, {}, options.timeout },
153
- [handler = std::move(handler)](auto resp) mutable {
153
+ [handler = std::move(handler)](const auto& resp) mutable {
154
154
  return handler(core::impl::make_error(resp.ctx), map_search_index(resp.index));
155
155
  });
156
156
  }
@@ -161,7 +161,7 @@ public:
161
161
  core_.execute(
162
162
  core::operations::management::search_index_get_all_request{
163
163
  bucket_name_, scope_name_, {}, options.timeout },
164
- [handler = std::move(handler)](auto resp) mutable {
164
+ [handler = std::move(handler)](const auto& resp) mutable {
165
165
  return handler(core::impl::make_error(resp.ctx), map_all_search_indexes(resp.indexes));
166
166
  });
167
167
  }
@@ -173,7 +173,7 @@ public:
173
173
  core_.execute(
174
174
  core::operations::management::search_index_upsert_request{
175
175
  map_search_index(search_index), bucket_name_, scope_name_, {}, options.timeout },
176
- [handler = std::move(handler)](auto resp) mutable {
176
+ [handler = std::move(handler)](const auto& resp) mutable {
177
177
  return handler(core::impl::make_error(resp.ctx));
178
178
  });
179
179
  }
@@ -185,7 +185,7 @@ public:
185
185
  core_.execute(
186
186
  core::operations::management::search_index_drop_request{
187
187
  std::move(index_name), bucket_name_, scope_name_, {}, options.timeout },
188
- [handler = std::move(handler)](auto resp) mutable {
188
+ [handler = std::move(handler)](const auto& resp) mutable {
189
189
  return handler(core::impl::make_error(resp.ctx));
190
190
  });
191
191
  }
@@ -197,7 +197,7 @@ public:
197
197
  core_.execute(
198
198
  core::operations::management::search_index_get_documents_count_request{
199
199
  std::move(index_name), bucket_name_, scope_name_, {}, options.timeout },
200
- [handler = std::move(handler)](auto resp) mutable {
200
+ [handler = std::move(handler)](const auto& resp) mutable {
201
201
  return handler(core::impl::make_error(resp.ctx), resp.count);
202
202
  });
203
203
  }
@@ -209,7 +209,7 @@ public:
209
209
  core_.execute(
210
210
  core::operations::management::search_index_control_ingest_request{
211
211
  std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout },
212
- [handler = std::move(handler)](auto resp) mutable {
212
+ [handler = std::move(handler)](const auto& resp) mutable {
213
213
  return handler(core::impl::make_error(resp.ctx));
214
214
  });
215
215
  }
@@ -221,7 +221,7 @@ public:
221
221
  core_.execute(
222
222
  core::operations::management::search_index_control_ingest_request{
223
223
  std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout },
224
- [handler = std::move(handler)](auto resp) mutable {
224
+ [handler = std::move(handler)](const auto& resp) mutable {
225
225
  return handler(core::impl::make_error(resp.ctx));
226
226
  });
227
227
  }
@@ -233,7 +233,7 @@ public:
233
233
  core_.execute(
234
234
  core::operations::management::search_index_control_query_request{
235
235
  std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout },
236
- [handler = std::move(handler)](auto resp) mutable {
236
+ [handler = std::move(handler)](const auto& resp) mutable {
237
237
  return handler(core::impl::make_error(resp.ctx));
238
238
  });
239
239
  }
@@ -245,7 +245,7 @@ public:
245
245
  core_.execute(
246
246
  core::operations::management::search_index_control_query_request{
247
247
  std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout },
248
- [handler = std::move(handler)](auto resp) mutable {
248
+ [handler = std::move(handler)](const auto& resp) mutable {
249
249
  return handler(core::impl::make_error(resp.ctx));
250
250
  });
251
251
  }
@@ -257,7 +257,7 @@ public:
257
257
  core_.execute(
258
258
  core::operations::management::search_index_control_plan_freeze_request{
259
259
  std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout },
260
- [handler = std::move(handler)](auto resp) mutable {
260
+ [handler = std::move(handler)](const auto& resp) mutable {
261
261
  return handler(core::impl::make_error(resp.ctx));
262
262
  });
263
263
  }
@@ -269,7 +269,7 @@ public:
269
269
  core_.execute(
270
270
  core::operations::management::search_index_control_plan_freeze_request{
271
271
  std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout },
272
- [handler = std::move(handler)](auto resp) mutable {
272
+ [handler = std::move(handler)](const auto& resp) mutable {
273
273
  return handler(core::impl::make_error(resp.ctx));
274
274
  });
275
275
  }
@@ -286,7 +286,7 @@ public:
286
286
  scope_name_,
287
287
  {},
288
288
  options.timeout },
289
- [handler = std::move(handler)](auto resp) mutable {
289
+ [handler = std::move(handler)](const auto& resp) mutable {
290
290
  return handler(core::impl::make_error(resp.ctx), convert_analysis(resp.analysis));
291
291
  });
292
292
  }
@@ -19,13 +19,15 @@
19
19
 
20
20
  #include <couchbase/build_config.hxx>
21
21
 
22
+ #include "core/impl/bootstrap_error.hxx"
23
+ #include "core/metrics/meter_wrapper.hxx"
22
24
  #include "core/service_type_fmt.hxx"
23
25
  #include "core/tracing/constants.hxx"
26
+ #include "core/tracing/tracer_wrapper.hxx"
24
27
  #include "core/utils/movable_function.hxx"
25
28
  #include "http_session.hxx"
26
29
  #include "http_traits.hxx"
27
30
 
28
- #include <couchbase/metrics/meter.hxx>
29
31
  #include <couchbase/tracing/request_tracer.hxx>
30
32
 
31
33
  #include <utility>
@@ -33,7 +35,11 @@
33
35
  namespace couchbase::core::operations
34
36
  {
35
37
 
38
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
39
+ using http_command_handler = utils::movable_function<void(error_union, io::http_response&&)>;
40
+ #else
36
41
  using http_command_handler = utils::movable_function<void(std::error_code, io::http_response&&)>;
42
+ #endif
37
43
 
38
44
  template<typename Request>
39
45
  struct http_command : public std::enable_shared_from_this<http_command<Request>> {
@@ -43,9 +49,9 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
43
49
  asio::steady_timer deadline;
44
50
  Request request;
45
51
  encoded_request_type encoded;
46
- std::shared_ptr<couchbase::tracing::request_tracer> tracer_;
52
+ std::shared_ptr<tracing::tracer_wrapper> tracer_;
47
53
  std::shared_ptr<couchbase::tracing::request_span> span_{ nullptr };
48
- std::shared_ptr<couchbase::metrics::meter> meter_{};
54
+ std::shared_ptr<metrics::meter_wrapper> meter_{};
49
55
  std::shared_ptr<io::http_session> session_{};
50
56
  http_command_handler handler_{};
51
57
  std::chrono::milliseconds timeout_{};
@@ -57,8 +63,8 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
57
63
 
58
64
  http_command(asio::io_context& ctx,
59
65
  Request req,
60
- std::shared_ptr<couchbase::tracing::request_tracer> tracer,
61
- std::shared_ptr<couchbase::metrics::meter> meter,
66
+ std::shared_ptr<tracing::tracer_wrapper> tracer,
67
+ std::shared_ptr<metrics::meter_wrapper> meter,
62
68
  std::chrono::milliseconds default_timeout,
63
69
  std::chrono::milliseconds dispatch_timeout)
64
70
  : deadline(ctx)
@@ -77,8 +83,8 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
77
83
  #else
78
84
  http_command(asio::io_context& ctx,
79
85
  Request req,
80
- std::shared_ptr<couchbase::tracing::request_tracer> tracer,
81
- std::shared_ptr<couchbase::metrics::meter> meter,
86
+ std::shared_ptr<tracing::tracer_wrapper> tracer,
87
+ std::shared_ptr<metrics::meter_wrapper> meter,
82
88
  std::chrono::milliseconds default_timeout)
83
89
  : deadline(ctx)
84
90
  , request(req)
@@ -108,12 +114,13 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
108
114
 
109
115
  void start(http_command_handler&& handler)
110
116
  {
111
- span_ = tracer_->start_span(tracing::span_name_for_http_service(request.type), parent_span);
112
- if (span_->uses_tags())
117
+ span_ = tracer_->create_span(tracing::span_name_for_http_service(request.type), parent_span);
118
+ if (span_->uses_tags()) {
113
119
  span_->add_tag(tracing::attributes::service,
114
120
  tracing::service_name_for_http_service(request.type));
115
- if (span_->uses_tags())
116
121
  span_->add_tag(tracing::attributes::operation_id, client_context_id_);
122
+ }
123
+
117
124
  handler_ = std::move(handler);
118
125
  #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
119
126
  dispatch_deadline_.expires_after(dispatch_timeout_);
@@ -158,17 +165,24 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
158
165
  }
159
166
  }
160
167
 
168
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
169
+ void invoke_handler(error_union error, io::http_response&& msg)
170
+ #else
161
171
  void invoke_handler(std::error_code ec, io::http_response&& msg)
172
+ #endif
162
173
  {
163
174
  if (span_ != nullptr) {
164
175
  span_->end();
165
176
  span_ = nullptr;
166
177
  }
167
178
  if (auto handler = std::move(handler_); handler) {
168
- handler(ec, std::move(msg));
169
- }
170
179
  #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
180
+ handler(error, std::move(msg));
181
+ }
171
182
  dispatch_deadline_.cancel();
183
+ #else
184
+ handler(ec, std::move(msg));
185
+ }
172
186
  #endif
173
187
  deadline.cancel();
174
188
  }
@@ -231,15 +245,12 @@ private:
231
245
  return self->invoke_handler(errc::common::ambiguous_timeout, std::move(msg));
232
246
  }
233
247
  if (self->meter_) {
234
- static std::string meter_name = "db.couchbase.operations";
235
- static std::map<std::string, std::string> tags = {
236
- { "db.couchbase.service", fmt::format("{}", self->request.type) },
237
- { "db.operation", self->encoded.path },
248
+ metrics::metric_attributes attrs{
249
+ service_type::key_value,
250
+ fmt::format("{}", self->encoded.path),
251
+ ec,
238
252
  };
239
- self->meter_->get_value_recorder(meter_name, tags)
240
- ->record_value(std::chrono::duration_cast<std::chrono::microseconds>(
241
- std::chrono::steady_clock::now() - start)
242
- .count());
253
+ self->meter_->record_value(std::move(attrs), start);
243
254
  }
244
255
  self->deadline.cancel();
245
256
  self->finish_dispatch(self->session_->remote_address(), self->session_->local_address());
@@ -395,7 +395,12 @@ http_session::flush()
395
395
  void
396
396
  http_session::write_and_stream(
397
397
  io::http_request& request,
398
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
399
+ utils::movable_function<void(couchbase::core::error_union, io::http_streaming_response)>
400
+ resp_handler,
401
+ #else
398
402
  utils::movable_function<void(std::error_code, io::http_streaming_response)> resp_handler,
403
+ #endif
399
404
  utils::movable_function<void()> stream_end_handler)
400
405
  {
401
406
  if (stopped_) {
@@ -17,7 +17,10 @@
17
17
 
18
18
  #pragma once
19
19
 
20
+ #include <couchbase/build_config.hxx>
21
+
20
22
  #include "core/diagnostics.hxx"
23
+ #include "core/impl/bootstrap_error.hxx"
21
24
  #include "core/origin.hxx"
22
25
  #include "core/platform/base64.h"
23
26
  #include "core/utils/movable_function.hxx"
@@ -140,10 +143,15 @@ public:
140
143
  flush();
141
144
  }
142
145
 
143
- void write_and_stream(
144
- io::http_request& request,
145
- utils::movable_function<void(std::error_code, io::http_streaming_response)> resp_handler,
146
- utils::movable_function<void()> stream_end_handler);
146
+ void write_and_stream(io::http_request& request,
147
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
148
+ utils::movable_function<void(couchbase::core::error_union,
149
+ io::http_streaming_response)> resp_handler,
150
+ #else
151
+ utils::movable_function<void(std::error_code, io::http_streaming_response)>
152
+ resp_handler,
153
+ #endif
154
+ utils::movable_function<void()> stream_end_handler);
147
155
 
148
156
  void set_idle(std::chrono::milliseconds timeout);
149
157
  auto reset_idle() -> bool;
@@ -155,7 +163,12 @@ public:
155
163
 
156
164
  private:
157
165
  struct streaming_response_context {
166
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
167
+ utils::movable_function<void(couchbase::core::error_union, io::http_streaming_response)>
168
+ resp_handler{};
169
+ #else
158
170
  utils::movable_function<void(std::error_code, io::http_streaming_response)> resp_handler{};
171
+ #endif
159
172
  utils::movable_function<void()> stream_end_handler{};
160
173
  std::optional<io::http_streaming_response> resp{};
161
174
  http_streaming_parser parser{};