couchbase 4.4.2 → 4.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. package/BUILDING.md +182 -0
  2. package/CMakeLists.txt +13 -0
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -2
  5. package/deps/couchbase-cxx-cache/boringssl/e31ea00c1ea52052d2d78d44006cc88c80fa24a9/boringssl/src/BUILDING.md +206 -0
  6. package/deps/couchbase-cxx-client/CMakeLists.txt +18 -13
  7. package/deps/couchbase-cxx-client/README.md +2 -2
  8. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +54 -0
  9. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +0 -5
  10. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +177 -10
  11. package/deps/couchbase-cxx-client/cmake/RPath.cmake +10 -0
  12. package/deps/couchbase-cxx-client/cmake/Testing.cmake +1 -1
  13. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +28 -2
  14. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  15. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +45 -6
  16. package/deps/couchbase-cxx-client/cmake/couchbase_cxx_client.pc.in +2 -2
  17. package/deps/couchbase-cxx-client/cmake/debian/changelog.in +5 -0
  18. package/deps/couchbase-cxx-client/cmake/debian/compat +1 -0
  19. package/deps/couchbase-cxx-client/cmake/debian/control +40 -0
  20. package/deps/couchbase-cxx-client/cmake/debian/rules +41 -0
  21. package/deps/couchbase-cxx-client/cmake/debian/source/format +1 -0
  22. package/deps/couchbase-cxx-client/core/agent_group.cxx +8 -0
  23. package/deps/couchbase-cxx-client/core/agent_group.hxx +4 -0
  24. package/deps/couchbase-cxx-client/core/bucket.cxx +16 -20
  25. package/deps/couchbase-cxx-client/core/bucket.hxx +12 -12
  26. package/deps/couchbase-cxx-client/core/cluster.cxx +44 -52
  27. package/deps/couchbase-cxx-client/core/cluster_agent.cxx +8 -0
  28. package/deps/couchbase-cxx-client/core/cluster_agent.hxx +4 -0
  29. package/deps/couchbase-cxx-client/core/collections_component.cxx +2 -2
  30. package/deps/couchbase-cxx-client/core/columnar/agent.cxx +2 -2
  31. package/deps/couchbase-cxx-client/core/columnar/agent.hxx +1 -1
  32. package/deps/couchbase-cxx-client/core/columnar/management_component.cxx +3 -3
  33. package/deps/couchbase-cxx-client/core/columnar/query_component.cxx +103 -45
  34. package/deps/couchbase-cxx-client/core/columnar/query_component.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +8 -0
  36. package/deps/couchbase-cxx-client/core/http_component.cxx +55 -24
  37. package/deps/couchbase-cxx-client/core/http_component.hxx +4 -0
  38. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  39. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +15 -15
  40. package/deps/couchbase-cxx-client/core/impl/bootstrap_error.hxx +10 -2
  41. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +1 -1
  42. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +6 -6
  43. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +36 -40
  44. package/deps/couchbase-cxx-client/core/impl/collection.cxx +29 -5
  45. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +5 -5
  46. package/deps/couchbase-cxx-client/core/impl/error.cxx +24 -3
  47. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +2 -0
  49. package/deps/couchbase-cxx-client/core/impl/observe_poll.cxx +13 -5
  50. package/deps/couchbase-cxx-client/core/impl/observe_poll.hxx +1 -3
  51. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  52. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  53. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  54. package/deps/couchbase-cxx-client/core/impl/scan_result.cxx +1 -1
  55. package/deps/couchbase-cxx-client/core/impl/search.cxx +2 -0
  56. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +12 -12
  57. package/deps/couchbase-cxx-client/core/io/http_command.hxx +31 -20
  58. package/deps/couchbase-cxx-client/core/io/http_session.cxx +5 -0
  59. package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -4
  60. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -49
  61. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +15 -14
  62. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  63. package/deps/couchbase-cxx-client/core/io/streams.cxx +256 -0
  64. package/deps/couchbase-cxx-client/core/io/streams.hxx +31 -155
  65. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +5 -0
  66. package/deps/couchbase-cxx-client/core/logger/custom_rotating_file_sink.cxx +2 -3
  67. package/deps/couchbase-cxx-client/core/logger/logger.cxx +39 -7
  68. package/deps/couchbase-cxx-client/core/logger/logger.hxx +7 -0
  69. package/deps/couchbase-cxx-client/core/meta/features.hxx +11 -0
  70. package/deps/couchbase-cxx-client/core/meta/version.cxx +47 -6
  71. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +188 -0
  72. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +73 -0
  73. package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +23 -17
  74. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +1 -0
  75. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +2 -0
  76. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +2 -0
  77. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +2 -0
  78. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +2 -0
  79. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +2 -0
  80. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +2 -0
  81. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +2 -0
  82. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +2 -0
  83. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +2 -0
  84. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +2 -0
  85. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +2 -0
  86. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +2 -0
  87. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +2 -0
  88. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +2 -0
  89. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +2 -0
  90. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +2 -0
  91. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  92. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +2 -0
  93. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +2 -0
  94. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -0
  95. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +2 -0
  96. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +2 -0
  97. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +2 -0
  98. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  99. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  100. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +1 -0
  101. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +1 -0
  102. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +1 -0
  103. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +1 -0
  104. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +1 -0
  105. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  106. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +1 -0
  107. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +1 -0
  108. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +1 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +1 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +1 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +1 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +1 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.cxx +23 -15
  114. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +4 -3
  115. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +1 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +1 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.cxx +2 -1
  118. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +1 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.cxx +3 -1
  120. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +1 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.cxx +3 -1
  122. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +1 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.cxx +3 -1
  124. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +1 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +1 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.cxx +3 -1
  127. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +1 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +1 -0
  129. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +1 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +1 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +3 -2
  132. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +5 -2
  134. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +1 -0
  135. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +4 -2
  136. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
  137. package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
  138. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +3 -2
  139. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +3 -2
  140. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +3 -2
  141. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +3 -2
  142. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +3 -2
  143. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +3 -2
  144. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +3 -2
  145. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +3 -2
  146. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +3 -2
  147. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  148. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +1 -0
  149. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +1 -0
  150. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +1 -0
  151. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.cxx +3 -3
  152. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +1 -0
  153. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
  154. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +3 -0
  155. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -0
  156. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +1 -0
  157. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +2 -0
  158. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -0
  159. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +1 -0
  160. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +2 -1
  161. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +1 -0
  162. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +4 -1
  163. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +1 -0
  164. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.cxx +3 -1
  165. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +1 -0
  166. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +1 -0
  167. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +3 -2
  168. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +1 -0
  169. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +3 -2
  170. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +1 -0
  171. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +3 -2
  172. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +1 -0
  173. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +3 -2
  174. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +1 -0
  175. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +5 -2
  176. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +1 -0
  177. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +5 -2
  178. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +1 -0
  179. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +4 -2
  180. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +1 -0
  181. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +3 -2
  182. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  183. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +1 -0
  184. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +5 -2
  185. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +1 -0
  186. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +1 -0
  187. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +1 -0
  188. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +1 -0
  189. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.cxx +3 -3
  190. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +1 -0
  191. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.cxx +2 -1
  192. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +1 -0
  193. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.cxx +2 -1
  194. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +1 -0
  195. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.cxx +3 -1
  196. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  197. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.cxx +2 -1
  198. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +1 -0
  199. package/deps/couchbase-cxx-client/core/origin.cxx +37 -17
  200. package/deps/couchbase-cxx-client/core/platform/base64.cc +1 -1
  201. package/deps/couchbase-cxx-client/core/platform/random.cc +2 -0
  202. package/deps/couchbase-cxx-client/core/platform/uuid.h +6 -6
  203. package/deps/couchbase-cxx-client/core/row_streamer.cxx +1 -1
  204. package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.cc +1 -1
  205. package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.h +4 -4
  206. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +2 -0
  207. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +8 -0
  208. package/deps/couchbase-cxx-client/core/tracing/constants.hxx +3 -0
  209. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +87 -0
  210. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +57 -0
  211. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +9 -21
  212. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +6 -33
  213. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +57 -56
  214. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +17 -18
  215. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +2 -2
  216. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +2 -2
  217. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +0 -20
  218. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +2 -2
  219. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +128 -52
  220. package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +4 -3
  221. package/deps/couchbase-cxx-client/couchbase/codec/tao_json_serializer.hxx +1 -1
  222. package/deps/couchbase-cxx-client/couchbase/common_options.hxx +16 -1
  223. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +16 -20
  224. package/deps/couchbase-cxx-client/couchbase/mutate_in_specs.hxx +2 -2
  225. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +4 -3
  226. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +1 -1
  227. package/dist/analyticsindexmanager.d.ts +98 -14
  228. package/dist/analyticsindexmanager.js +452 -411
  229. package/dist/binding.d.ts +53 -4
  230. package/dist/bindingutilities.d.ts +26 -1
  231. package/dist/bindingutilities.js +108 -1
  232. package/dist/couchbase.d.ts +3 -1
  233. package/dist/couchbase.js +2 -0
  234. package/dist/rangeScan.d.ts +1 -1
  235. package/dist/rangeScan.js +1 -1
  236. package/dist/transactions.d.ts +34 -3
  237. package/dist/transactions.js +25 -18
  238. package/dist/transcoders.d.ts +68 -0
  239. package/dist/transcoders.js +194 -1
  240. package/dist/usermanager.d.ts +14 -14
  241. package/dist/usermanager.js +178 -228
  242. package/dist/utilities.js +4 -6
  243. package/dist/utilities_internal.js +1 -2
  244. package/package.json +9 -8
  245. package/src/binding.cpp +13 -13
  246. package/src/connection.cpp +22 -0
  247. package/src/connection.hpp +12 -0
  248. package/src/connection_autogen.cpp +100 -0
  249. package/src/jstocbpp_autogen.hpp +315 -8
  250. package/src/jstocbpp_transactions.hpp +1 -2
  251. package/tools/gen-bindings-js.js +38 -3
  252. package/tools/gen-bindings-json.py +575 -328
@@ -15,6 +15,9 @@
15
15
 
16
16
  #pragma once
17
17
 
18
+ #include <couchbase/build_config.hxx>
19
+
20
+ #include "core/impl/bootstrap_error.hxx"
18
21
  #include "service_type.hxx"
19
22
  #include "utils/movable_function.hxx"
20
23
 
@@ -101,8 +104,13 @@ private:
101
104
  std::shared_ptr<http_response_impl> impl_;
102
105
  };
103
106
 
107
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
108
+ using free_form_http_request_callback =
109
+ utils::movable_function<void(http_response response, couchbase::core::error_union err)>;
110
+ #else
104
111
  using free_form_http_request_callback =
105
112
  utils::movable_function<void(http_response response, std::error_code ec)>;
113
+ #endif
106
114
 
107
115
  class buffered_http_response_impl;
108
116
 
@@ -131,19 +131,22 @@ public:
131
131
  invoke_response_handler(errc::common::request_canceled, {});
132
132
  }
133
133
 
134
- void invoke_response_handler(std::error_code ec, io::http_streaming_response resp)
135
- {
136
- deadline_.cancel();
137
134
  #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
135
+ void invoke_response_handler(error_union err, io::http_streaming_response resp)
136
+ {
138
137
  dispatch_deadline_.cancel();
138
+ #else
139
+ void invoke_response_handler(std::error_code err, io::http_streaming_response resp)
140
+ {
139
141
  #endif
142
+ deadline_.cancel();
140
143
  free_form_http_request_callback callback{};
141
144
  {
142
145
  const std::scoped_lock lock(callback_mutex_);
143
146
  std::swap(callback, callback_);
144
147
  }
145
148
  if (callback) {
146
- callback(http_response{ std::move(resp) }, ec);
149
+ callback(http_response{ std::move(resp) }, err);
147
150
  }
148
151
  }
149
152
 
@@ -157,12 +160,22 @@ public:
157
160
  auto start_op = [self = shared_from_this()]() {
158
161
  self->session_->write_and_stream(
159
162
  self->encoded_,
163
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
164
+ [self](error_union err, io::http_streaming_response resp) {
165
+ if (std::holds_alternative<std::error_code>(err) &&
166
+ std::get<std::error_code>(err) == asio::error::operation_aborted) {
167
+ return;
168
+ }
169
+ self->invoke_response_handler(err, std::move(resp));
170
+ },
171
+ #else
160
172
  [self](std::error_code ec, io::http_streaming_response resp) {
161
173
  if (ec == asio::error::operation_aborted) {
162
174
  return;
163
175
  }
164
176
  self->invoke_response_handler(ec, std::move(resp));
165
177
  },
178
+ #endif
166
179
  [self]() {
167
180
  self->stream_end_callback_();
168
181
  });
@@ -409,8 +422,13 @@ public:
409
422
  {
410
423
  }
411
424
 
425
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
426
+ auto do_http_request(const http_request& request, free_form_http_request_callback&& callback)
427
+ -> tl::expected<std::shared_ptr<pending_operation>, error_union>
428
+ #else
412
429
  auto do_http_request(const http_request& request, free_form_http_request_callback&& callback)
413
430
  -> tl::expected<std::shared_ptr<pending_operation>, std::error_code>
431
+ #endif
414
432
  {
415
433
  std::shared_ptr<io::http_session_manager> session_manager;
416
434
  {
@@ -436,9 +454,9 @@ public:
436
454
  auto op =
437
455
  std::make_shared<pending_http_operation>(io_, request, session_manager->dispatch_timeout());
438
456
  if (!session_manager->is_configured()) {
439
- auto ec = defer_command(op, session_manager, credentials, std::move(callback));
440
- if (ec) {
441
- return tl::unexpected{ ec };
457
+ auto err = defer_command(op, session_manager, credentials, std::move(callback));
458
+ if (!std::holds_alternative<std::monostate>(err)) {
459
+ return tl::unexpected{ err };
442
460
  }
443
461
  return op;
444
462
  }
@@ -478,8 +496,11 @@ public:
478
496
  auto op = std::make_shared<pending_buffered_http_operation>(
479
497
  io_, request, session_manager->dispatch_timeout());
480
498
  if (!session_manager->is_configured()) {
481
- auto ec = defer_command(op, session_manager, credentials, std::move(callback));
482
- if (ec) {
499
+ auto err = defer_command(op, session_manager, credentials, std::move(callback));
500
+ if (!std::holds_alternative<std::monostate>(err)) {
501
+ auto ec = std::holds_alternative<impl::bootstrap_error>(err)
502
+ ? std::get<impl::bootstrap_error>(err).ec
503
+ : std::get<std::error_code>(err);
483
504
  return tl::unexpected{ ec };
484
505
  }
485
506
  return op;
@@ -498,16 +519,19 @@ private:
498
519
  const couchbase::core::cluster_credentials& credentials,
499
520
  free_form_http_request_callback&& callback)
500
521
  {
501
- op->start([callback = std::move(callback)](auto resp, auto ec) mutable {
502
- callback(std::move(resp), ec);
503
- });
504
-
505
522
  #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
523
+ op->start([callback = std::move(callback)](auto resp, error_union err) mutable {
524
+ callback(std::move(resp), err);
525
+ });
506
526
  // don't do anything if the op wasn't dispatched or has already timed out
507
527
  auto now = std::chrono::steady_clock::now();
508
528
  if (op->dispatch_deadline_expiry() < now || op->deadline_expiry() < now) {
509
529
  return;
510
530
  }
531
+ #else
532
+ op->start([callback = std::move(callback)](auto resp, auto ec) mutable {
533
+ callback(std::move(resp), ec);
534
+ });
511
535
  #endif
512
536
  std::shared_ptr<io::http_session> session;
513
537
  {
@@ -592,10 +616,10 @@ private:
592
616
  auto defer_command(std::shared_ptr<PendingHttpOp> pending_op,
593
617
  const std::shared_ptr<io::http_session_manager>& session_manager,
594
618
  const couchbase::core::cluster_credentials& credentials,
595
- Callback&& callback) -> std::error_code
619
+ Callback&& callback) -> error_union
596
620
  {
597
621
  if (auto last_error = session_manager->last_bootstrap_error(); last_error.has_value()) {
598
- return last_error->ec;
622
+ return last_error.value();
599
623
  }
600
624
  CB_LOG_DEBUG(
601
625
  R"(Adding pending HTTP operation to deferred queue: service={}, client_context_id={})",
@@ -605,26 +629,26 @@ private:
605
629
  callback = std::forward<Callback>(callback),
606
630
  op = std::move(pending_op),
607
631
  session_manager,
608
- credentials](std::error_code ec) mutable {
609
- if (ec) {
632
+ credentials](error_union err) mutable {
633
+ if (!std::holds_alternative<std::monostate>(err)) {
610
634
  // The deferred operation was cancelled - currently this can happen due to closing the
611
635
  // cluster
612
- return callback({}, ec);
636
+ return callback({}, err);
613
637
  }
614
638
 
615
639
  return send_http_operation(
616
640
  op, session_manager, credentials, std::forward<Callback>(callback));
617
641
  });
618
- return {};
642
+ return std::monostate{};
619
643
  }
620
644
 
621
645
  auto defer_command(std::shared_ptr<pending_buffered_http_operation> pending_op,
622
646
  const std::shared_ptr<io::http_session_manager>& session_manager,
623
647
  const couchbase::core::cluster_credentials& credentials,
624
- buffered_free_form_http_request_callback&& callback) -> std::error_code
648
+ buffered_free_form_http_request_callback&& callback) -> error_union
625
649
  {
626
650
  if (auto last_error = session_manager->last_bootstrap_error(); last_error.has_value()) {
627
- return last_error->ec;
651
+ return last_error.value();
628
652
  }
629
653
  CB_LOG_DEBUG(
630
654
  R"(Adding pending HTTP operation to deferred queue: service={}, client_context_id={})",
@@ -634,8 +658,11 @@ private:
634
658
  callback = std::move(callback),
635
659
  op = std::move(pending_op),
636
660
  session_manager,
637
- credentials](std::error_code ec) mutable {
638
- if (ec) {
661
+ credentials](error_union err) mutable {
662
+ if (!std::holds_alternative<std::monostate>(err)) {
663
+ auto ec = std::holds_alternative<impl::bootstrap_error>(err)
664
+ ? std::get<impl::bootstrap_error>(err).ec
665
+ : std::get<std::error_code>(err);
639
666
  // The deferred operation was cancelled - currently this can happen due to closing the
640
667
  // cluster
641
668
  return callback({}, ec);
@@ -643,7 +670,7 @@ private:
643
670
 
644
671
  return send_http_operation(op, session_manager, credentials, std::move(callback));
645
672
  });
646
- return {};
673
+ return std::monostate{};
647
674
  }
648
675
  #endif
649
676
 
@@ -664,7 +691,11 @@ http_component::http_component(asio::io_context& io,
664
691
  auto
665
692
  http_component::do_http_request(const http_request& request,
666
693
  free_form_http_request_callback&& callback)
694
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
695
+ -> tl::expected<std::shared_ptr<pending_operation>, error_union>
696
+ #else
667
697
  -> tl::expected<std::shared_ptr<pending_operation>, std::error_code>
698
+ #endif
668
699
  {
669
700
  return impl_->do_http_request(request, std::move(callback));
670
701
  }
@@ -49,7 +49,11 @@ public:
49
49
  std::shared_ptr<retry_strategy> default_retry_strategy = {});
50
50
 
51
51
  auto do_http_request(const http_request& request, free_form_http_request_callback&& callback)
52
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
53
+ -> tl::expected<std::shared_ptr<pending_operation>, error_union>;
54
+ #else
52
55
  -> tl::expected<std::shared_ptr<pending_operation>, std::error_code>;
56
+ #endif
53
57
 
54
58
  auto do_http_request_buffered(const http_request& request,
55
59
  buffered_free_form_http_request_callback&& callback)
@@ -167,6 +167,7 @@ build_analytics_request(std::string statement,
167
167
  std::move(options.client_context_id),
168
168
  options.timeout,
169
169
  };
170
+ request.parent_span = options.parent_span;
170
171
  if (!options.raw.empty()) {
171
172
  for (auto& [name, value] : options.raw) {
172
173
  request.raw[name] = std::move(value);
@@ -159,7 +159,7 @@ public:
159
159
  {},
160
160
  options.timeout,
161
161
  },
162
- [dataverse_name, handler = std::move(handler)](auto resp) {
162
+ [dataverse_name, handler = std::move(handler)](const auto& resp) {
163
163
  CB_LOG_DEBUG(
164
164
  "Dataverse create for {} error code = {}", dataverse_name, resp.ctx.ec.value());
165
165
  handler(core::impl::make_error(resp.ctx));
@@ -177,7 +177,7 @@ public:
177
177
  {},
178
178
  options.timeout,
179
179
  },
180
- [handler = std::move(handler)](auto resp) {
180
+ [handler = std::move(handler)](const auto& resp) {
181
181
  handler(core::impl::make_error(resp.ctx));
182
182
  });
183
183
  }
@@ -197,7 +197,7 @@ public:
197
197
  options.timeout,
198
198
  options.ignore_if_exists,
199
199
  },
200
- [handler = std::move(handler)](auto resp) {
200
+ [handler = std::move(handler)](const auto& resp) {
201
201
  handler(core::impl::make_error(resp.ctx));
202
202
  });
203
203
  }
@@ -214,7 +214,7 @@ public:
214
214
  {},
215
215
  options.timeout,
216
216
  },
217
- [handler = std::move(handler)](auto resp) {
217
+ [handler = std::move(handler)](const auto& resp) {
218
218
  handler(core::impl::make_error(resp.ctx));
219
219
  });
220
220
  }
@@ -262,7 +262,7 @@ public:
262
262
  {},
263
263
  options.timeout,
264
264
  },
265
- [handler = std::move(handler)](auto resp) {
265
+ [handler = std::move(handler)](const auto& resp) {
266
266
  handler(core::impl::make_error(resp.ctx));
267
267
  });
268
268
  }
@@ -281,7 +281,7 @@ public:
281
281
  {},
282
282
  options.timeout,
283
283
  },
284
- [handler = std::move(handler)](auto resp) {
284
+ [handler = std::move(handler)](const auto& resp) {
285
285
  handler(core::impl::make_error(resp.ctx));
286
286
  });
287
287
  }
@@ -324,7 +324,7 @@ public:
324
324
  {},
325
325
  options.timeout,
326
326
  },
327
- [handler = std::move(handler)](auto resp) {
327
+ [handler = std::move(handler)](const auto& resp) {
328
328
  handler(core::impl::make_error(resp.ctx));
329
329
  });
330
330
  }
@@ -339,7 +339,7 @@ public:
339
339
  {},
340
340
  options.timeout,
341
341
  },
342
- [handler = std::move(handler)](auto resp) {
342
+ [handler = std::move(handler)](const auto& resp) {
343
343
  handler(core::impl::make_error(resp.ctx));
344
344
  });
345
345
  }
@@ -386,7 +386,7 @@ public:
386
386
  {},
387
387
  options.timeout,
388
388
  },
389
- [handler = std::move(handler)](auto resp) {
389
+ [handler = std::move(handler)](const auto& resp) {
390
390
  handler(core::impl::make_error(resp.ctx));
391
391
  });
392
392
 
@@ -398,7 +398,7 @@ public:
398
398
  {},
399
399
  options.timeout,
400
400
  },
401
- [handler = std::move(handler)](auto resp) {
401
+ [handler = std::move(handler)](const auto& resp) {
402
402
  handler(core::impl::make_error(resp.ctx));
403
403
  });
404
404
 
@@ -410,7 +410,7 @@ public:
410
410
  {},
411
411
  options.timeout,
412
412
  },
413
- [handler = std::move(handler)](auto resp) {
413
+ [handler = std::move(handler)](const auto& resp) {
414
414
  handler(core::impl::make_error(resp.ctx));
415
415
  });
416
416
  }
@@ -429,7 +429,7 @@ public:
429
429
  {},
430
430
  options.timeout,
431
431
  },
432
- [handler = std::move(handler)](auto resp) {
432
+ [handler = std::move(handler)](const auto& resp) {
433
433
  handler(core::impl::make_error(resp.ctx));
434
434
  });
435
435
 
@@ -441,7 +441,7 @@ public:
441
441
  {},
442
442
  options.timeout,
443
443
  },
444
- [handler = std::move(handler)](auto resp) {
444
+ [handler = std::move(handler)](const auto& resp) {
445
445
  handler(core::impl::make_error(resp.ctx));
446
446
  });
447
447
 
@@ -453,7 +453,7 @@ public:
453
453
  {},
454
454
  options.timeout,
455
455
  },
456
- [handler = std::move(handler)](auto resp) {
456
+ [handler = std::move(handler)](const auto& resp) {
457
457
  handler(core::impl::make_error(resp.ctx));
458
458
  });
459
459
  }
@@ -471,7 +471,7 @@ public:
471
471
  {},
472
472
  options.timeout,
473
473
  },
474
- [handler = std::move(handler)](auto resp) {
474
+ [handler = std::move(handler)](const auto& resp) {
475
475
  handler(core::impl::make_error(resp.ctx));
476
476
  });
477
477
  }
@@ -20,8 +20,12 @@
20
20
  #include <optional>
21
21
  #include <string>
22
22
  #include <system_error>
23
+ #include <variant>
23
24
 
24
- namespace couchbase::core::impl
25
+ namespace couchbase::core
26
+ {
27
+
28
+ namespace impl
25
29
  {
26
30
 
27
31
  struct bootstrap_error {
@@ -31,4 +35,8 @@ struct bootstrap_error {
31
35
  std::optional<std::string> port;
32
36
  };
33
37
 
34
- } // namespace couchbase::core::impl
38
+ } // namespace impl
39
+
40
+ using error_union = std::variant<std::monostate, std::error_code, impl::bootstrap_error>;
41
+
42
+ } // namespace couchbase::core
@@ -59,7 +59,7 @@ public:
59
59
  name_,
60
60
  core::impl::to_core_service_types(options.service_types),
61
61
  options.timeout,
62
- [handler = std::move(handler)](auto resp) mutable {
62
+ [handler = std::move(handler)](const auto& resp) mutable {
63
63
  return handler({}, core::impl::build_result(resp));
64
64
  });
65
65
  }
@@ -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();