couchbase 4.2.3 → 4.2.5-dev.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CMakeLists.txt +136 -11
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
  3. package/deps/couchbase-cxx-client/README.md +1 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
  5. package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
  6. package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
  7. package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
  8. package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
  9. package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
  11. package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
  12. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
  13. package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
  14. package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
  15. package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
  16. package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
  17. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
  18. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
  19. package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
  20. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  21. package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
  22. package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
  23. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
  24. package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
  25. package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
  26. package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
  27. package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
  28. package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
  29. package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
  30. package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
  31. package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
  32. package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
  33. package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
  34. package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
  35. package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
  36. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
  37. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
  38. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
  39. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
  40. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
  41. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
  42. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
  43. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
  44. package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
  45. package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
  46. package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
  47. package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
  48. package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
  49. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
  50. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
  51. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
  52. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
  53. package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
  54. package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
  55. package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
  56. package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
  57. package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
  58. package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
  59. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
  60. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
  61. package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
  62. package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
  63. package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
  64. package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
  65. package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
  66. package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
  67. package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
  68. package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
  69. package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
  70. package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
  71. package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
  72. package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
  73. package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
  74. package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
  75. package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
  76. package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
  77. package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
  78. package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
  79. package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
  80. package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
  81. package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
  82. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
  83. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
  84. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
  85. package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
  86. package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
  87. package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
  88. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
  89. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
  90. package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
  91. package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
  92. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
  93. package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
  94. package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
  95. package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
  96. package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
  97. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
  98. package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
  99. package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
  100. package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
  101. package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
  102. package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
  103. package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
  104. package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
  105. package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
  106. package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
  107. package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  108. package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
  109. package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
  110. package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
  111. package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
  112. package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
  113. package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
  114. package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
  115. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
  116. package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
  117. package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
  118. package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
  119. package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
  120. package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
  121. package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
  122. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
  123. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
  124. package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
  125. package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
  126. package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
  127. package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
  128. package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
  129. package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
  130. package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
  131. package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
  132. package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
  133. package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
  134. package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
  135. package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
  136. package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
  137. package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
  138. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
  139. package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
  140. package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
  141. package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
  142. package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
  143. package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
  144. package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
  145. package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
  146. package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
  147. package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
  148. package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
  149. package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
  150. package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
  151. package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
  152. package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
  153. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
  154. package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
  155. package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
  156. package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
  157. package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
  158. package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
  159. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
  160. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
  161. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
  162. package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
  163. package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
  164. package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
  165. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
  166. package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
  167. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
  168. package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
  169. package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
  170. package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
  171. package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
  172. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  173. package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
  174. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
  175. package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
  176. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
  177. package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
  178. package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
  179. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
  180. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
  181. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
  182. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
  183. package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
  184. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
  185. package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
  186. package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
  187. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
  188. package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
  189. package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
  190. package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
  191. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
  192. package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
  193. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
  194. package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
  195. package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
  196. package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
  197. package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
  198. package/dist/binding.d.ts +1 -1
  199. package/dist/binding.js +3 -2
  200. package/package.json +96 -1
  201. package/scripts/createPlatformPackages.js +108 -0
  202. package/scripts/install.js +45 -0
  203. package/scripts/prebuilds.js +249 -0
  204. package/scripts/prune.js +124 -0
  205. package/src/jstocbpp_autogen.hpp +3 -2
@@ -72,7 +72,7 @@ class collection_cache
72
72
  if (auto ptr = cid_map_.find(path); ptr != cid_map_.end()) {
73
73
  return ptr->second;
74
74
  }
75
- return {};
75
+ return std::nullopt;
76
76
  }
77
77
 
78
78
  void update(const std::string& path, std::uint32_t id)
@@ -379,7 +379,7 @@ class mcbp_session_impl
379
379
  Expects(protocol::is_valid_server_request_opcode(msg.header.opcode));
380
380
  switch (static_cast<protocol::server_opcode>(msg.header.opcode)) {
381
381
  case protocol::server_opcode::cluster_map_change_notification: {
382
- protocol::cmd_info info{ session_->endpoint_address_, session_->endpoint_.port() };
382
+ protocol::cmd_info info{ session_->bootstrap_hostname_, session_->bootstrap_port_number_ };
383
383
  if (session_->origin_.options().dump_configuration) {
384
384
  std::string_view config_text{ reinterpret_cast<const char*>(msg.body.data()), msg.body.size() };
385
385
  CB_LOG_TRACE(
@@ -404,7 +404,7 @@ class mcbp_session_impl
404
404
  CB_LOG_WARNING("{} unexpected server request: opcode={:x}, opaque={}{:a}{:a}",
405
405
  session_->log_prefix_,
406
406
  msg.header.opcode,
407
- msg.header.opaque,
407
+ utils::byte_swap(msg.header.opaque),
408
408
  spdlog::to_hex(msg.header_data()),
409
409
  spdlog::to_hex(msg.body));
410
410
  }
@@ -416,7 +416,7 @@ class mcbp_session_impl
416
416
  session_->log_prefix_,
417
417
  magic,
418
418
  msg.header.opcode,
419
- msg.header.opaque,
419
+ utils::byte_swap(msg.header.opaque),
420
420
  spdlog::to_hex(msg.header_data()),
421
421
  spdlog::to_hex(msg.body));
422
422
  break;
@@ -473,7 +473,7 @@ class mcbp_session_impl
473
473
  Expects(protocol::is_valid_client_opcode(msg.header.opcode));
474
474
  switch (auto opcode = static_cast<protocol::client_opcode>(msg.header.opcode)) {
475
475
  case protocol::client_opcode::get_cluster_config: {
476
- protocol::cmd_info info{ session_->endpoint_address_, session_->endpoint_.port() };
476
+ protocol::cmd_info info{ session_->bootstrap_hostname_, session_->bootstrap_port_number_ };
477
477
  if (session_->origin_.options().dump_configuration) {
478
478
  std::string_view config_text{ reinterpret_cast<const char*>(msg.body.data()), msg.body.size() };
479
479
  CB_LOG_TRACE("{} configuration from get_cluster_config response (size={}, endpoint=\"{}:{}\"), {}",
@@ -781,13 +781,10 @@ class mcbp_session_impl
781
781
  return;
782
782
  }
783
783
  std::tie(bootstrap_hostname_, bootstrap_port_) = origin_.next_address();
784
- log_prefix_ = fmt::format("[{}/{}/{}/{}] <{}:{}>",
785
- client_id_,
786
- id_,
787
- stream_->log_prefix(),
788
- bucket_name_.value_or("-"),
789
- bootstrap_hostname_,
790
- bootstrap_port_);
784
+ bootstrap_port_number_ = gsl::narrow_cast<std::uint16_t>(std::stoul(bootstrap_port_, nullptr, 10));
785
+ bootstrap_address_ = fmt::format("{}:{}", bootstrap_hostname_, bootstrap_port_);
786
+ log_prefix_ =
787
+ fmt::format("[{}/{}/{}/{}] <{}>", client_id_, id_, stream_->log_prefix(), bucket_name_.value_or("-"), bootstrap_address_);
791
788
  CB_LOG_DEBUG("{} attempt to establish MCBP connection", log_prefix_);
792
789
 
793
790
  async_resolve(origin_.options().use_ip_protocol,
@@ -807,7 +804,7 @@ class mcbp_session_impl
807
804
  return stopped_;
808
805
  }
809
806
 
810
- void on_stop(utils::movable_function<void(retry_reason)> handler)
807
+ void on_stop(utils::movable_function<void()> handler)
811
808
  {
812
809
  on_stop_handler_ = std::move(handler);
813
810
  }
@@ -863,7 +860,7 @@ class mcbp_session_impl
863
860
  config_listeners_.clear();
864
861
  state_ = diag::endpoint_state::disconnected;
865
862
  if (auto on_stop = std::move(on_stop_handler_); on_stop) {
866
- on_stop(reason);
863
+ on_stop();
867
864
  }
868
865
  }
869
866
 
@@ -874,7 +871,7 @@ class mcbp_session_impl
874
871
  }
875
872
  std::uint32_t opaque{ 0 };
876
873
  std::memcpy(&opaque, buf.data() + 12, sizeof(opaque));
877
- CB_LOG_TRACE("{} MCBP send, opaque={}, {:n}", log_prefix_, opaque, spdlog::to_hex(buf.begin(), buf.begin() + 24));
874
+ CB_LOG_TRACE("{} MCBP send, opaque={}, {:n}", log_prefix_, utils::byte_swap(opaque), spdlog::to_hex(buf.begin(), buf.begin() + 24));
878
875
  std::scoped_lock lock(output_buffer_mutex_);
879
876
  output_buffer_.emplace_back(std::move(buf));
880
877
  }
@@ -1058,6 +1055,11 @@ class mcbp_session_impl
1058
1055
  return config_->index_for_this_node();
1059
1056
  }
1060
1057
 
1058
+ [[nodiscard]] const std::string& bootstrap_address() const
1059
+ {
1060
+ return bootstrap_address_;
1061
+ }
1062
+
1061
1063
  [[nodiscard]] const std::string& bootstrap_hostname() const
1062
1064
  {
1063
1065
  return bootstrap_hostname_;
@@ -1068,6 +1070,11 @@ class mcbp_session_impl
1068
1070
  return bootstrap_port_;
1069
1071
  }
1070
1072
 
1073
+ [[nodiscard]] std::uint16_t bootstrap_port_number() const
1074
+ {
1075
+ return bootstrap_port_number_;
1076
+ }
1077
+
1071
1078
  [[nodiscard]] std::uint32_t next_opaque()
1072
1079
  {
1073
1080
  return ++opaque_;
@@ -1161,15 +1168,15 @@ class mcbp_session_impl
1161
1168
  CB_LOG_TRACE("{} configuration from not_my_vbucket response (size={}, endpoint=\"{}:{}\"), {}",
1162
1169
  log_prefix_,
1163
1170
  config_text.size(),
1164
- endpoint_address_,
1165
- endpoint_.port(),
1171
+ bootstrap_hostname_,
1172
+ bootstrap_port_number_,
1166
1173
  config_text);
1167
1174
  }
1168
- auto config = protocol::parse_config(config_text, endpoint_address_, endpoint_.port());
1175
+ auto config = protocol::parse_config(config_text, bootstrap_hostname_, bootstrap_port_number_);
1169
1176
  CB_LOG_DEBUG("{} received not_my_vbucket status for {}, opaque={} with config rev={} in the payload",
1170
1177
  log_prefix_,
1171
1178
  protocol::client_opcode(msg.header.opcode),
1172
- msg.header.opaque,
1179
+ utils::byte_swap(msg.header.opaque),
1173
1180
  config.rev_str());
1174
1181
  update_configuration(std::move(config));
1175
1182
  }
@@ -1204,6 +1211,12 @@ class mcbp_session_impl
1204
1211
  CB_LOG_DEBUG(R"({} server returned {} ({}), it must be transient condition, retrying)", log_prefix_, ec.value(), ec.message());
1205
1212
  return initiate_bootstrap();
1206
1213
  }
1214
+ if (!origin_.exhausted() && ec == errc::common::authentication_failure) {
1215
+ CB_LOG_DEBUG(
1216
+ R"({} server returned authentication_failure, but the bootstrap list is not exhausted yet. It must be transient condition, retrying)",
1217
+ log_prefix_);
1218
+ return initiate_bootstrap();
1219
+ }
1207
1220
 
1208
1221
  if (!bootstrapped_ && bootstrap_callback_) {
1209
1222
  bootstrap_deadline_.cancel();
@@ -1382,8 +1395,10 @@ class mcbp_session_impl
1382
1395
  if (self->stopped_) {
1383
1396
  return;
1384
1397
  }
1385
- CB_LOG_TRACE(
1386
- "{} MCBP recv, opaque={}, {:n}", self->log_prefix_, msg.header.opaque, spdlog::to_hex(msg.header_data()));
1398
+ CB_LOG_TRACE("{} MCBP recv, opaque={}, {:n}",
1399
+ self->log_prefix_,
1400
+ utils::byte_swap(msg.header.opaque),
1401
+ spdlog::to_hex(msg.header_data()));
1387
1402
  if (self->bootstrapped_) {
1388
1403
  self->handler_->handle(std::move(msg));
1389
1404
  } else {
@@ -1462,7 +1477,7 @@ class mcbp_session_impl
1462
1477
  std::mutex command_handlers_mutex_{};
1463
1478
  std::map<std::uint32_t, command_handler> command_handlers_{};
1464
1479
  std::vector<std::shared_ptr<config_listener>> config_listeners_{};
1465
- utils::movable_function<void(retry_reason)> on_stop_handler_{};
1480
+ utils::movable_function<void()> on_stop_handler_{};
1466
1481
 
1467
1482
  std::atomic_bool bootstrapped_{ false };
1468
1483
  std::atomic_bool stopped_{ false };
@@ -1482,6 +1497,8 @@ class mcbp_session_impl
1482
1497
  std::mutex writing_buffer_mutex_{};
1483
1498
  std::string bootstrap_hostname_{};
1484
1499
  std::string bootstrap_port_{};
1500
+ std::string bootstrap_address_{};
1501
+ std::uint16_t bootstrap_port_number_{};
1485
1502
  asio::ip::tcp::endpoint endpoint_{}; // connected endpoint
1486
1503
  std::string endpoint_address_{}; // cached string with endpoint address
1487
1504
  asio::ip::tcp::endpoint local_endpoint_{};
@@ -1582,22 +1599,16 @@ mcbp_session::supports_feature(protocol::hello_feature feature)
1582
1599
  return impl_->supports_feature(feature);
1583
1600
  }
1584
1601
 
1585
- // const std::string&
1586
- // mcbp_session::id() const
1587
- // {
1588
- // return impl_->id();
1589
- // }
1590
- std::string
1602
+ const std::string&
1591
1603
  mcbp_session::id() const
1592
1604
  {
1593
- if (impl_) {
1594
- return fmt::format("{}, {}, {}, refcnt={}",
1595
- reinterpret_cast<const void*>(this),
1596
- reinterpret_cast<const void*>(impl_.get()),
1597
- impl_->id(),
1598
- impl_.use_count());
1599
- }
1600
- return fmt::format("{}, nullptr", reinterpret_cast<const void*>(this));
1605
+ return impl_->id();
1606
+ }
1607
+
1608
+ const std::string&
1609
+ mcbp_session::bootstrap_address() const
1610
+ {
1611
+ return impl_->bootstrap_address();
1601
1612
  }
1602
1613
 
1603
1614
  std::string
@@ -1624,6 +1635,12 @@ mcbp_session::bootstrap_port() const
1624
1635
  return impl_->bootstrap_port();
1625
1636
  }
1626
1637
 
1638
+ std::uint16_t
1639
+ mcbp_session::bootstrap_port_number() const
1640
+ {
1641
+ return impl_->bootstrap_port_number();
1642
+ }
1643
+
1627
1644
  void
1628
1645
  mcbp_session::write_and_subscribe(std::uint32_t opaque, std::vector<std::byte>&& data, command_handler&& handler)
1629
1646
  {
@@ -1637,7 +1654,7 @@ mcbp_session::bootstrap(utils::movable_function<void(std::error_code, topology::
1637
1654
  }
1638
1655
 
1639
1656
  void
1640
- mcbp_session::on_stop(utils::movable_function<void(retry_reason)> handler)
1657
+ mcbp_session::on_stop(utils::movable_function<void()> handler)
1641
1658
  {
1642
1659
  return impl_->on_stop(std::move(handler));
1643
1660
  }
@@ -101,17 +101,18 @@ class mcbp_session
101
101
  [[nodiscard]] mcbp_context context() const;
102
102
  [[nodiscard]] bool supports_feature(protocol::hello_feature feature);
103
103
  [[nodiscard]] std::vector<protocol::hello_feature> supported_features() const;
104
- //[[nodiscard]] const std::string& id() const;
105
- [[nodiscard]] std::string id() const;
104
+ [[nodiscard]] const std::string& id() const;
106
105
  [[nodiscard]] std::string remote_address() const;
107
106
  [[nodiscard]] std::string local_address() const;
107
+ [[nodiscard]] const std::string& bootstrap_address() const;
108
108
  [[nodiscard]] const std::string& bootstrap_hostname() const;
109
109
  [[nodiscard]] const std::string& bootstrap_port() const;
110
+ [[nodiscard]] std::uint16_t bootstrap_port_number() const;
110
111
  void write_and_subscribe(std::shared_ptr<mcbp::queue_request>, std::shared_ptr<response_handler> handler);
111
112
  void write_and_subscribe(std::uint32_t opaque, std::vector<std::byte>&& data, command_handler&& handler);
112
113
  void bootstrap(utils::movable_function<void(std::error_code, topology::configuration)>&& handler,
113
114
  bool retry_on_bucket_not_found = false);
114
- void on_stop(utils::movable_function<void(retry_reason)> handler);
115
+ void on_stop(utils::movable_function<void()> handler);
115
116
  void stop(retry_reason reason);
116
117
  [[nodiscard]] std::size_t index() const;
117
118
  [[nodiscard]] bool has_config() const;
@@ -37,6 +37,11 @@ struct json_string {
37
37
  return *this;
38
38
  }
39
39
 
40
+ json_string(const std::vector<std::byte>& value)
41
+ : value_(value)
42
+ {
43
+ }
44
+
40
45
  json_string(std::vector<std::byte>&& value)
41
46
  : value_(std::move(value))
42
47
  {
@@ -17,10 +17,12 @@
17
17
 
18
18
  #include "version.hxx"
19
19
 
20
+ #include "core/mozilla_ca_bundle.hxx"
20
21
  #include "core/transactions/forward_compat.hxx"
21
22
  #include "core/utils/join_strings.hxx"
22
23
  #include "core/utils/json.hxx"
23
24
 
25
+ #include <couchbase/build_config.hxx>
24
26
  #include <couchbase/build_info.hxx>
25
27
  #include <couchbase/build_version.hxx>
26
28
 
@@ -76,7 +78,7 @@ sdk_build_info()
76
78
  info["link_libraries"] = COUCHBASE_CXX_CLIENT_LINK_LIBRARIES;
77
79
  info["link_options"] = COUCHBASE_CXX_CLIENT_LINK_OPTIONS;
78
80
  info["static_stdlib"] =
79
- #if defined(STATIC_STDLIB)
81
+ #if defined(COUCHBASE_CXX_CLIENT_STATIC_STDLIB)
80
82
  "true"
81
83
  #else
82
84
  "false"
@@ -84,7 +86,7 @@ sdk_build_info()
84
86
  ;
85
87
  info["post_linked_openssl"] = COUCHBASE_CXX_CLIENT_POST_LINKED_OPENSSL;
86
88
  info["static_openssl"] =
87
- #if defined(STATIC_OPENSSL)
89
+ #if defined(COUCHBASE_CXX_CLIENT_STATIC_OPENSSL)
88
90
  "true"
89
91
  #else
90
92
  "false"
@@ -112,8 +114,19 @@ sdk_build_info()
112
114
  }
113
115
  }
114
116
  #endif
117
+
118
+ #if defined(COUCHBASE_CXX_CLIENT_EMBED_MOZILLA_CA_BUNDLE)
119
+ info["mozilla_ca_bundle_embedded"] = "true";
120
+ info["mozilla_ca_bundle_sha256"] = COUCHBASE_CXX_CLIENT_MOZILLA_CA_BUNDLE_SHA256;
121
+ info["mozilla_ca_bundle_date"] = COUCHBASE_CXX_CLIENT_MOZILLA_CA_BUNDLE_DATE;
122
+ #else
123
+ info["mozilla_ca_bundle_embedded"] = "false";
124
+ #endif
125
+ info["mozilla_ca_bundle_size"] = std::to_string(default_ca::mozilla_ca_certs().size());
115
126
  info["openssl_default_cert_dir"] = X509_get_default_cert_dir();
116
127
  info["openssl_default_cert_file"] = X509_get_default_cert_file();
128
+ info["openssl_default_cert_dir_env"] = X509_get_default_cert_dir_env();
129
+ info["openssl_default_cert_file_env"] = X509_get_default_cert_file_env();
117
130
  info["openssl_ssl_interface_include_directories"] = OPENSSL_SSL_INTERFACE_INCLUDE_DIRECTORIES;
118
131
  info["openssl_ssl_interface_link_libraries"] = OPENSSL_SSL_INTERFACE_LINK_LIBRARIES;
119
132
  info["openssl_ssl_imported_location"] = OPENSSL_SSL_IMPORTED_LOCATION;
@@ -138,9 +151,10 @@ sdk_build_info_json()
138
151
  {
139
152
  tao::json::value info;
140
153
  for (const auto& [name, value] : sdk_build_info()) {
141
- if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build") {
154
+ if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build" ||
155
+ name == "mozilla_ca_bundle_size") {
142
156
  info[name] = std::stoi(value);
143
- } else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl") {
157
+ } else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl" || name == "mozilla_ca_bundle_embedded") {
144
158
  info[name] = value == "true";
145
159
  } else {
146
160
  info[name] = value;
@@ -0,0 +1,39 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <array>
21
+ #include <gsl/span>
22
+ #include <string_view>
23
+
24
+ namespace couchbase::core::default_ca
25
+ {
26
+ struct certificate {
27
+ std::string_view authority;
28
+ std::string_view body;
29
+ };
30
+
31
+ auto
32
+ mozilla_ca_certs() -> gsl::span<const certificate>;
33
+
34
+ auto
35
+ mozilla_ca_certs_date() -> std::string_view;
36
+
37
+ auto
38
+ mozilla_ca_certs_sha256() -> std::string_view;
39
+ } // namespace couchbase::core::default_ca
@@ -32,9 +32,11 @@ search_request::encode_to(search_request::encoded_request_type& encoded, http_co
32
32
  {
33
33
  auto body = tao::json::value{
34
34
  { "query", utils::json::parse(query) },
35
- { "explain", explain },
36
35
  { "ctl", { { "timeout", encoded.timeout.count() } } },
37
36
  };
37
+ if (explain) {
38
+ body["explain"] = *explain;
39
+ }
38
40
  if (limit) {
39
41
  body["size"] = *limit;
40
42
  }
@@ -121,7 +121,7 @@ struct search_request {
121
121
 
122
122
  std::optional<std::uint32_t> limit{};
123
123
  std::optional<std::uint32_t> skip{};
124
- bool explain{ false };
124
+ std::optional<bool> explain{ false };
125
125
  bool disable_scoring{ false };
126
126
  /**
127
127
  * UNCOMMITTED: If set to true, will include the vector of search_location in rows.
@@ -29,6 +29,8 @@
29
29
  #include <cstring>
30
30
  #include <gsl/util>
31
31
 
32
+ #include <iostream>
33
+
32
34
  namespace couchbase::core::protocol
33
35
  {
34
36
  std::pair<bool, std::uint32_t>
@@ -110,10 +112,17 @@ class client_request
110
112
  private:
111
113
  [[nodiscard]] std::vector<std::byte> generate_payload(bool try_to_compress)
112
114
  {
113
- std::vector<std::byte> payload(header_size + body_.size());
115
+ // SA: for some reason GCC 8.5.0 on CentOS 8 sees here null-pointer dereference
116
+ #if defined(__GNUC__) && __GNUC__ == 8
117
+ #pragma GCC diagnostic push
118
+ #pragma GCC diagnostic ignored "-Wnull-dereference"
119
+ #endif
120
+ std::vector<std::byte> payload(header_size + body_.size(), std::byte{});
114
121
  payload[0] = static_cast<std::byte>(magic_);
115
122
  payload[1] = static_cast<std::byte>(opcode_);
116
-
123
+ #if defined(__GNUC__) && __GNUC__ == 8
124
+ #pragma GCC diagnostic pop
125
+ #endif
117
126
  const auto& framing_extras = body_.framing_extras();
118
127
 
119
128
  std::uint16_t key_size = gsl::narrow_cast<std::uint16_t>(body_.key().size());
@@ -148,6 +148,7 @@ class client_response
148
148
  data_.resize(body_size_);
149
149
 
150
150
  memcpy(&opaque_, header_.data() + 12, sizeof(opaque_));
151
+ opaque_ = utils::byte_swap(opaque_);
151
152
 
152
153
  memcpy(&cas_, header_.data() + 16, sizeof(cas_));
153
154
  cas_ = utils::byte_swap(cas_);