couchbase 4.6.0 → 4.7.0-dev.1

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 (320) hide show
  1. package/CMakeLists.txt +2 -1
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +66 -93
  3. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  4. package/deps/couchbase-cxx-client/CMakeLists.txt +24 -11
  5. package/deps/couchbase-cxx-client/README.md +17 -16
  6. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +17 -1
  7. package/deps/couchbase-cxx-client/cmake/Bundler.cmake +9 -1
  8. package/deps/couchbase-cxx-client/cmake/Cache.cmake +48 -19
  9. package/deps/couchbase-cxx-client/cmake/CompilerOptions.cmake +3 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +10 -2
  11. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +48 -8
  12. package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +43 -1
  13. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +2 -0
  14. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +18 -0
  15. package/deps/couchbase-cxx-client/cmake/debian/control +6 -1
  16. package/deps/couchbase-cxx-client/cmake/debian/rules +1 -0
  17. package/deps/couchbase-cxx-client/cmake/tarball_glob.txt +10 -0
  18. package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +1 -0
  19. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +45 -43
  20. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +4 -3
  21. package/deps/couchbase-cxx-client/core/bucket.cxx +128 -13
  22. package/deps/couchbase-cxx-client/core/bucket.hxx +12 -2
  23. package/deps/couchbase-cxx-client/core/cluster.cxx +304 -152
  24. package/deps/couchbase-cxx-client/core/cluster.hxx +32 -0
  25. package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +25 -0
  26. package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +5 -0
  27. package/deps/couchbase-cxx-client/core/cluster_label_listener.cxx +72 -0
  28. package/deps/couchbase-cxx-client/core/cluster_label_listener.hxx +46 -0
  29. package/deps/couchbase-cxx-client/core/cluster_options.hxx +4 -0
  30. package/deps/couchbase-cxx-client/core/deprecation_utils.hxx +26 -0
  31. package/deps/couchbase-cxx-client/core/error.hxx +27 -0
  32. package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +0 -2
  33. package/deps/couchbase-cxx-client/core/http_component.cxx +12 -48
  34. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +3 -2
  35. package/deps/couchbase-cxx-client/core/impl/analytics.hxx +2 -1
  36. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +249 -137
  37. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +134 -58
  38. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +87 -35
  39. package/deps/couchbase-cxx-client/core/impl/collection.cxx +560 -245
  40. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +89 -49
  41. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +4 -4
  42. package/deps/couchbase-cxx-client/core/impl/error.cxx +20 -13
  43. package/deps/couchbase-cxx-client/core/impl/error.hxx +15 -10
  44. package/deps/couchbase-cxx-client/core/impl/get_all_replicas.hxx +1 -1
  45. package/deps/couchbase-cxx-client/core/impl/get_any_replica.hxx +2 -1
  46. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  47. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +1 -1
  48. package/deps/couchbase-cxx-client/core/impl/observability_recorder.cxx +161 -0
  49. package/deps/couchbase-cxx-client/core/impl/observability_recorder.hxx +77 -0
  50. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/impl/public_bucket.cxx +31 -7
  52. package/deps/couchbase-cxx-client/core/impl/public_cluster.cxx +107 -19
  53. package/deps/couchbase-cxx-client/core/impl/query.cxx +6 -3
  54. package/deps/couchbase-cxx-client/core/impl/query.hxx +3 -1
  55. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +267 -102
  56. package/deps/couchbase-cxx-client/core/impl/scope.cxx +53 -11
  57. package/deps/couchbase-cxx-client/core/impl/search.cxx +8 -4
  58. package/deps/couchbase-cxx-client/core/impl/search.hxx +6 -2
  59. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +131 -41
  60. package/deps/couchbase-cxx-client/core/impl/with_cancellation.hxx +75 -0
  61. package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +9 -9
  62. package/deps/couchbase-cxx-client/core/io/config_tracker.hxx +2 -1
  63. package/deps/couchbase-cxx-client/core/io/http_command.hxx +98 -49
  64. package/deps/couchbase-cxx-client/core/io/http_context.hxx +2 -0
  65. package/deps/couchbase-cxx-client/core/io/http_session.cxx +23 -10
  66. package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -9
  67. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +163 -228
  68. package/deps/couchbase-cxx-client/core/io/http_traits.hxx +0 -7
  69. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +123 -44
  70. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +251 -26
  71. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +9 -1
  72. package/deps/couchbase-cxx-client/core/io/mcbp_traits.hxx +0 -8
  73. package/deps/couchbase-cxx-client/core/io/streams.cxx +3 -3
  74. package/deps/couchbase-cxx-client/core/io/streams.hxx +3 -2
  75. package/deps/couchbase-cxx-client/core/meta/features.hxx +15 -0
  76. package/deps/couchbase-cxx-client/core/meta/version.cxx +13 -0
  77. package/deps/couchbase-cxx-client/core/meta/version.hxx +3 -0
  78. package/deps/couchbase-cxx-client/core/metrics/constants.hxx +23 -0
  79. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +5 -5
  80. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +65 -63
  81. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +12 -10
  82. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +0 -5
  83. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +0 -4
  84. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +0 -5
  85. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +0 -7
  86. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +0 -7
  87. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +77 -27
  88. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +0 -9
  89. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +0 -9
  90. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +83 -2
  91. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +0 -9
  92. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +0 -5
  93. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +0 -4
  94. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +0 -9
  95. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +46 -4
  96. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +121 -43
  97. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +0 -5
  98. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +0 -4
  99. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +0 -4
  100. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +0 -4
  101. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +0 -4
  102. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +0 -7
  103. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +0 -7
  104. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +0 -6
  105. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +0 -4
  106. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +2 -0
  107. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +10 -13
  108. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +2 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +2 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +2 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +2 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +2 -0
  114. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  115. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +2 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +2 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +2 -0
  118. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +2 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +2 -0
  120. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +2 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +2 -0
  122. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +2 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +2 -0
  124. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +2 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +2 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +2 -0
  127. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +2 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +2 -0
  129. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +2 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +2 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +2 -0
  132. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
  134. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  135. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +2 -0
  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/error_utils.cxx +4 -1
  139. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +2 -0
  140. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +2 -0
  141. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +2 -0
  142. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +2 -0
  143. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +2 -0
  144. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +2 -0
  145. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +2 -0
  146. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +2 -0
  147. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +2 -0
  148. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  149. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +2 -0
  150. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +2 -0
  151. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +2 -0
  152. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +2 -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 +68 -30
  155. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  156. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  157. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  158. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +2 -1
  159. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +2 -0
  160. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +2 -0
  161. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +2 -0
  162. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +2 -0
  163. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +2 -0
  164. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +2 -0
  165. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +2 -0
  166. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
  167. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +2 -0
  168. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +2 -0
  169. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  170. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +2 -0
  171. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  172. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +2 -0
  173. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +2 -0
  174. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +2 -0
  175. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +2 -0
  176. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +2 -0
  177. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +2 -0
  178. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +2 -0
  179. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +2 -0
  180. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  181. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +2 -0
  182. package/deps/couchbase-cxx-client/core/operations/operation_traits.hxx +6 -0
  183. package/deps/couchbase-cxx-client/core/operations.hxx +0 -1
  184. package/deps/couchbase-cxx-client/core/operations_fwd.hxx +8 -0
  185. package/deps/couchbase-cxx-client/core/origin.cxx +67 -12
  186. package/deps/couchbase-cxx-client/core/origin.hxx +13 -8
  187. package/deps/couchbase-cxx-client/core/orphan_reporter.cxx +164 -0
  188. package/deps/couchbase-cxx-client/core/orphan_reporter.hxx +65 -0
  189. package/deps/couchbase-cxx-client/core/sasl/CMakeLists.txt +1 -0
  190. package/deps/couchbase-cxx-client/core/sasl/client.cc +6 -0
  191. package/deps/couchbase-cxx-client/core/sasl/mechanism.cc +2 -1
  192. package/deps/couchbase-cxx-client/core/sasl/mechanism.h +2 -1
  193. package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.cc +41 -0
  194. package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.h +47 -0
  195. package/deps/couchbase-cxx-client/core/tls_context_provider.cxx +44 -0
  196. package/deps/couchbase-cxx-client/core/tls_context_provider.hxx +44 -0
  197. package/deps/couchbase-cxx-client/core/tracing/attribute_helpers.hxx +45 -0
  198. package/deps/couchbase-cxx-client/core/tracing/constants.hxx +148 -68
  199. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_options.hxx +0 -3
  200. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +122 -170
  201. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +17 -24
  202. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +8 -10
  203. package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.cxx +114 -0
  204. package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.hxx +85 -0
  205. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +16 -14
  206. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +4 -4
  207. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +1 -1
  208. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +1 -2
  209. package/deps/couchbase-cxx-client/core/utils/byteswap.hxx +12 -0
  210. package/deps/couchbase-cxx-client/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
  211. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +2 -0
  212. package/deps/couchbase-cxx-client/couchbase/certificate_authenticator.hxx +1 -0
  213. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +47 -0
  214. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +16 -0
  215. package/deps/couchbase-cxx-client/couchbase/collection.hxx +60 -15
  216. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +48 -48
  217. package/deps/couchbase-cxx-client/couchbase/jwt_authenticator.hxx +52 -0
  218. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +2 -1
  219. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +75 -80
  220. package/deps/couchbase-cxx-client/couchbase/network_options.hxx +19 -0
  221. package/deps/couchbase-cxx-client/couchbase/password_authenticator.hxx +1 -0
  222. package/deps/couchbase-cxx-client/couchbase/tracing/otel_tracer.hxx +15 -17
  223. package/deps/couchbase-cxx-client/couchbase/tracing/request_span.hxx +2 -2
  224. package/dist/analyticsexecutor.d.ts +15 -0
  225. package/dist/analyticsexecutor.js +79 -50
  226. package/dist/analyticsindexmanager.d.ts +66 -0
  227. package/dist/analyticsindexmanager.js +404 -277
  228. package/dist/analyticstypes.d.ts +5 -0
  229. package/dist/authenticators.d.ts +34 -1
  230. package/dist/authenticators.js +19 -1
  231. package/dist/binarycollection.d.ts +17 -0
  232. package/dist/binding.d.ts +245 -228
  233. package/dist/binding.js +2 -2
  234. package/dist/bindingutilities.js +1 -1
  235. package/dist/bucket.d.ts +8 -0
  236. package/dist/bucket.js +8 -0
  237. package/dist/bucketmanager.d.ts +30 -0
  238. package/dist/bucketmanager.js +128 -69
  239. package/dist/cluster.d.ts +45 -0
  240. package/dist/cluster.js +133 -23
  241. package/dist/collection.d.ts +75 -2
  242. package/dist/collection.js +773 -552
  243. package/dist/collectionmanager.d.ts +34 -0
  244. package/dist/collectionmanager.js +172 -89
  245. package/dist/couchbase.d.ts +5 -0
  246. package/dist/couchbase.js +5 -0
  247. package/dist/datastructures.js +310 -97
  248. package/dist/diagnosticsexecutor.js +1 -1
  249. package/dist/errors.d.ts +8 -0
  250. package/dist/errors.js +12 -1
  251. package/dist/eventingfunctionmanager.d.ts +42 -0
  252. package/dist/eventingfunctionmanager.js +172 -100
  253. package/dist/logger.d.ts +192 -0
  254. package/dist/logger.js +213 -0
  255. package/dist/loggingmeter.d.ts +120 -0
  256. package/dist/loggingmeter.js +226 -0
  257. package/dist/metrics.d.ts +33 -0
  258. package/dist/metrics.js +5 -0
  259. package/dist/observability.d.ts +60 -0
  260. package/dist/observability.js +86 -0
  261. package/dist/observabilityhandler.d.ts +176 -0
  262. package/dist/observabilityhandler.js +733 -0
  263. package/dist/observabilitytypes.d.ts +320 -0
  264. package/dist/observabilitytypes.js +362 -0
  265. package/dist/observabilityutilities.d.ts +60 -0
  266. package/dist/observabilityutilities.js +175 -0
  267. package/dist/otelmeter.d.ts +51 -0
  268. package/dist/otelmeter.js +100 -0
  269. package/dist/oteltracer.d.ts +69 -0
  270. package/dist/oteltracer.js +141 -0
  271. package/dist/queryexecutor.d.ts +16 -0
  272. package/dist/queryexecutor.js +128 -86
  273. package/dist/queryindexmanager.d.ts +29 -0
  274. package/dist/queryindexmanager.js +277 -150
  275. package/dist/querytypes.d.ts +5 -0
  276. package/dist/scope.js +2 -2
  277. package/dist/scopeeventingfunctionmanager.d.ts +5 -0
  278. package/dist/scopeeventingfunctionmanager.js +217 -119
  279. package/dist/scopesearchindexmanager.d.ts +5 -0
  280. package/dist/scopesearchindexmanager.js +295 -166
  281. package/dist/sdspecs.js +6 -1
  282. package/dist/searchexecutor.d.ts +15 -0
  283. package/dist/searchexecutor.js +54 -26
  284. package/dist/searchindexmanager.d.ts +54 -0
  285. package/dist/searchindexmanager.js +235 -142
  286. package/dist/searchtypes.d.ts +5 -0
  287. package/dist/thresholdlogging.d.ts +301 -0
  288. package/dist/thresholdlogging.js +657 -0
  289. package/dist/tracing.d.ts +55 -0
  290. package/dist/tracing.js +2 -0
  291. package/dist/transactions.js +1 -1
  292. package/dist/transcoders.js +1 -1
  293. package/dist/usermanager.d.ts +46 -0
  294. package/dist/usermanager.js +199 -118
  295. package/dist/utilities.d.ts +4 -0
  296. package/dist/utilities.js +11 -1
  297. package/dist/utilities_internal.js +0 -1
  298. package/dist/version.d.ts +2 -0
  299. package/dist/version.js +7 -0
  300. package/dist/viewexecutor.d.ts +15 -0
  301. package/dist/viewexecutor.js +54 -29
  302. package/dist/viewindexmanager.d.ts +30 -0
  303. package/dist/viewindexmanager.js +129 -100
  304. package/dist/viewtypes.d.ts +5 -0
  305. package/package.json +32 -18
  306. package/scripts/buildPrebuild.js +2 -0
  307. package/scripts/install.js +2 -0
  308. package/scripts/prebuilds.js +7 -8
  309. package/scripts/prune.js +2 -0
  310. package/scripts/updateVersion.js +26 -0
  311. package/src/connection.cpp +79 -98
  312. package/src/connection.hpp +46 -38
  313. package/src/connection_autogen.cpp +1236 -292
  314. package/src/jstocbpp_autogen.hpp +1117 -313
  315. package/src/jstocbpp_basic.hpp +73 -0
  316. package/src/jstocbpp_defs.hpp +37 -9
  317. package/src/jstocbpp_errors.hpp +37 -11
  318. package/tools/gen-bindings-js.js +100 -22
  319. package/tools/gen-bindings-json.py +40 -6
  320. package/src/transcoder.hpp +0 -96
@@ -21,6 +21,7 @@
21
21
  #include "core/document_id_fmt.hxx"
22
22
  #include "core/error_context/key_value_error_map_info.hxx"
23
23
  #include "core/metrics/meter_wrapper.hxx"
24
+ #include "core/operations/operation_traits.hxx"
24
25
  #include "core/platform/uuid.h"
25
26
  #include "core/protocol/client_request.hxx"
26
27
  #include "core/protocol/client_response.hxx"
@@ -66,10 +67,14 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
66
67
  std::string id_{ fmt::format("{:02x}/{}",
67
68
  static_cast<std::uint8_t>(encoded_request_type::body_type::opcode),
68
69
  uuid::to_string(uuid::random())) };
70
+ #ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
69
71
  std::shared_ptr<couchbase::tracing::request_span> span_{ nullptr };
70
- std::shared_ptr<couchbase::tracing::request_span> parent_span{ nullptr };
72
+ #endif
73
+ std::shared_ptr<couchbase::tracing::request_span> parent_span_{ nullptr };
71
74
  std::optional<std::string> last_dispatched_from_{};
72
75
  std::optional<std::string> last_dispatched_to_{};
76
+ std::chrono::time_point<std::chrono::steady_clock> started_at_{};
77
+ std::vector<std::chrono::microseconds> server_durations_{};
73
78
 
74
79
  mcbp_command(asio::io_context& ctx,
75
80
  std::shared_ptr<Manager> manager,
@@ -80,6 +85,7 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
80
85
  , request(req)
81
86
  , manager_(manager)
82
87
  , timeout_(request.timeout.value_or(default_timeout))
88
+ , parent_span_(request.parent_span)
83
89
  {
84
90
  if constexpr (io::mcbp_traits::supports_durability_v<Request>) {
85
91
  if (request.durability_level != durability_level::none &&
@@ -93,19 +99,19 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
93
99
  timeout_ = durability_timeout_floor;
94
100
  }
95
101
  }
96
- if constexpr (io::mcbp_traits::supports_parent_span_v<Request>) {
97
- parent_span = request.parent_span;
98
- }
99
102
  }
100
103
 
101
104
  void start(mcbp_command_handler&& handler)
102
105
  {
106
+ started_at_ = std::chrono::steady_clock::now();
107
+ #ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
103
108
  span_ = manager_->tracer()->create_span(
104
- tracing::span_name_for_mcbp_command(encoded_request_type::body_type::opcode), parent_span);
109
+ tracing::span_name_for_mcbp_command(encoded_request_type::body_type::opcode), parent_span_);
105
110
  if (span_->uses_tags()) {
106
- span_->add_tag(tracing::attributes::service, tracing::service::key_value);
107
- span_->add_tag(tracing::attributes::instance, request.id.bucket());
111
+ span_->add_tag(tracing::attributes::op::service, tracing::service::key_value);
112
+ span_->add_tag(tracing::attributes::op::bucket_name, request.id.bucket());
108
113
  }
114
+ #endif
109
115
 
110
116
  handler_ = std::move(handler);
111
117
  deadline.expires_after(timeout_);
@@ -115,20 +121,32 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
115
121
  }
116
122
  self->cancel(retry_reason::do_not_retry);
117
123
  });
124
+
125
+ if constexpr (is_cancellable_operation_v<Request>) {
126
+ request.cancel_token->setup([weak_self = this->weak_from_this()] {
127
+ if (auto self = weak_self.lock()) {
128
+ self->cancel(retry_reason::do_not_retry, false);
129
+ }
130
+ });
131
+ }
118
132
  }
119
133
 
120
- void cancel(retry_reason reason)
134
+ void cancel(retry_reason reason, bool is_timeout = true)
121
135
  {
122
136
  if (opaque_ && session_) {
123
137
  if (session_->cancel(opaque_.value(), asio::error::operation_aborted, reason)) {
124
138
  handler_ = nullptr;
125
139
  }
126
140
  }
127
- invoke_handler(
128
- request.retries.idempotent() || !opaque_.has_value()
129
- ? errc::common::unambiguous_timeout // safe to retry or has not been sent to the server
130
- : errc::common::ambiguous_timeout // non-idempotent and has been sent to the server
131
- );
141
+ if (is_timeout) {
142
+ invoke_handler(
143
+ request.retries.idempotent() || !opaque_.has_value()
144
+ ? errc::common::unambiguous_timeout // safe to retry or has not been sent to the server
145
+ : errc::common::ambiguous_timeout // non-idempotent and has been sent to the server
146
+ );
147
+ } else {
148
+ invoke_handler(errc::common::request_canceled);
149
+ }
132
150
  }
133
151
 
134
152
  void invoke_handler(std::error_code ec, std::optional<io::mcbp_message>&& msg = {})
@@ -137,15 +155,12 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
137
155
  deadline.cancel();
138
156
  mcbp_command_handler handler{};
139
157
  std::swap(handler, handler_);
158
+ #ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
140
159
  if (span_ != nullptr) {
141
- if (msg) {
142
- auto server_duration_us =
143
- static_cast<std::uint64_t>(protocol::parse_server_duration_us(msg.value()));
144
- span_->add_tag(tracing::attributes::server_duration, server_duration_us);
145
- }
146
160
  span_->end();
147
161
  span_ = nullptr;
148
162
  }
163
+ #endif
149
164
  if (handler) {
150
165
  const auto& node_uuid = session_ ? session_->node_uuid() : "";
151
166
  auto telemetry_recorder =
@@ -232,9 +247,6 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
232
247
  {
233
248
  opaque_ = session_->next_opaque();
234
249
  request.opaque = *opaque_;
235
- if (span_->uses_tags()) {
236
- span_->add_tag(tracing::attributes::operation_id, fmt::format("0x{:x}", request.opaque));
237
- }
238
250
  if (request.id.use_collections() && !request.id.is_collection_resolved()) {
239
251
  if (session_->supports_feature(protocol::hello_feature::collections)) {
240
252
  auto collection_id = session_->get_collection_uid(request.id.collection_path());
@@ -267,14 +279,23 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
267
279
  }
268
280
  }
269
281
 
282
+ auto dispatch_span = create_dispatch_span();
270
283
  session_->write_and_subscribe(
271
284
  request.opaque,
272
285
  encoded.data(session_->supports_feature(protocol::hello_feature::snappy)),
273
- [self = this->shared_from_this(), start = std::chrono::steady_clock::now()](
286
+ [self = this->shared_from_this(),
287
+ start = std::chrono::steady_clock::now(),
288
+ dispatch_span = std::move(dispatch_span)](
274
289
  std::error_code ec,
275
290
  retry_reason reason,
276
291
  io::mcbp_message&& msg,
277
292
  std::optional<key_value_error_map_info> /* error_info */) mutable {
293
+ {
294
+ const auto server_duration_us =
295
+ static_cast<std::uint64_t>(protocol::parse_server_duration_us(msg));
296
+ self->server_durations_.emplace_back(std::chrono::microseconds(server_duration_us));
297
+ self->close_dispatch_span(dispatch_span, server_duration_us);
298
+ }
278
299
  {
279
300
  auto latency = std::chrono::duration_cast<std::chrono::milliseconds>(
280
301
  std::chrono::steady_clock::now() - start);
@@ -304,30 +325,30 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
304
325
  telemetry_recorder->record_latency(category, latency);
305
326
  }
306
327
 
307
- metrics::metric_attributes attrs{
308
- service_type::key_value,
309
- self->request.observability_identifier,
310
- ec,
311
- self->request.id.bucket(),
312
- self->request.id.scope(),
313
- self->request.id.collection(),
314
- };
315
- self->manager_->meter()->record_value(std::move(attrs), start);
328
+ #ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
329
+ {
330
+ metrics::metric_attributes attrs{
331
+ service_type::key_value,
332
+ self->request.observability_identifier,
333
+ ec,
334
+ self->request.id.bucket(),
335
+ self->request.id.scope(),
336
+ self->request.id.collection(),
337
+ };
338
+ self->manager_->meter()->record_value(std::move(attrs), start);
339
+ }
340
+ #endif
316
341
 
317
342
  self->retry_backoff.cancel();
318
343
  if (ec == asio::error::operation_aborted) {
319
- if (self->span_->uses_tags()) {
320
- self->span_->add_tag(tracing::attributes::orphan, "aborted");
321
- }
344
+ self->manager_->orphan_reporter()->add_orphan(self->create_orphan_attributes());
322
345
  return self->invoke_handler(make_error_code(self->request.retries.idempotent()
323
346
  ? errc::common::unambiguous_timeout
324
347
  : errc::common::ambiguous_timeout));
325
348
  }
326
349
  if (ec == errc::common::request_canceled) {
327
350
  if (!self->request.retries.idempotent() && !allows_non_idempotent_retry(reason)) {
328
- if (self->span_->uses_tags()) {
329
- self->span_->add_tag(tracing::attributes::orphan, "canceled");
330
- }
351
+ self->manager_->orphan_reporter()->add_orphan(self->create_orphan_attributes());
331
352
  return self->invoke_handler(ec);
332
353
  }
333
354
  return io::retry_orchestrator::maybe_retry(self->manager_, self, reason, ec);
@@ -395,18 +416,76 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
395
416
 
396
417
  void send_to(io::mcbp_session session)
397
418
  {
398
- if (!handler_ || !span_) {
419
+ if (!handler_) {
420
+ #ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
421
+ if (!span_) {
422
+ // TODO(DC): Is this necessary? Background:
423
+ // https://github.com/couchbase/couchbase-cxx-client/pull/160
424
+ return;
425
+ }
426
+ #endif
399
427
  return;
400
428
  }
401
429
  session_ = std::move(session);
402
- if (span_->uses_tags())
403
- span_->add_tag(tracing::attributes::remote_socket, session_->remote_address());
404
- if (span_->uses_tags())
405
- span_->add_tag(tracing::attributes::local_socket, session_->local_address());
406
- if (span_->uses_tags())
407
- span_->add_tag(tracing::attributes::local_id, session_->id());
408
430
  send();
409
431
  }
432
+
433
+ private:
434
+ [[nodiscard]] auto create_orphan_attributes() -> orphan_attributes
435
+ {
436
+ orphan_attributes attrs;
437
+
438
+ attrs.operation_name = Request::observability_identifier;
439
+ attrs.connection_id = session_->id();
440
+ attrs.operation_id = fmt::format("0x{:x}", request.opaque);
441
+ attrs.last_remote_socket = session_->remote_address();
442
+ attrs.last_local_socket = session_->local_address();
443
+ if (!server_durations_.empty()) {
444
+ attrs.last_server_duration = server_durations_.back();
445
+ for (const auto d : server_durations_) {
446
+ attrs.total_server_duration += d;
447
+ }
448
+ }
449
+ attrs.total_duration = std::chrono::duration_cast<std::chrono::microseconds>(
450
+ std::chrono::steady_clock::now() - started_at_);
451
+
452
+ return attrs;
453
+ }
454
+
455
+ [[nodiscard]] auto create_dispatch_span() const
456
+ -> std::shared_ptr<couchbase::tracing::request_span>
457
+ {
458
+ #ifdef COUCHBASE_CXX_CLIENT_CREATE_OPERATION_SPAN_IN_CORE
459
+ std::shared_ptr<couchbase::tracing::request_span> dispatch_span =
460
+ manager_->tracer()->create_span(tracing::operation::step_dispatch, span_);
461
+ #else
462
+ std::shared_ptr<couchbase::tracing::request_span> dispatch_span =
463
+ manager_->tracer()->create_span(tracing::operation::step_dispatch, parent_span_);
464
+ #endif
465
+ if (dispatch_span->uses_tags()) {
466
+ dispatch_span->add_tag(tracing::attributes::dispatch::network_transport, "tcp");
467
+ dispatch_span->add_tag(tracing::attributes::dispatch::operation_id,
468
+ fmt::format("0x{:x}", request.opaque));
469
+ dispatch_span->add_tag(tracing::attributes::dispatch::local_id, session_->id());
470
+ }
471
+ return dispatch_span;
472
+ }
473
+
474
+ void close_dispatch_span(const std::shared_ptr<couchbase::tracing::request_span>& dispatch_span,
475
+ const std::uint64_t server_duration_us) const
476
+ {
477
+ if (dispatch_span->uses_tags()) {
478
+ dispatch_span->add_tag(tracing::attributes::dispatch::server_duration, server_duration_us);
479
+ dispatch_span->add_tag(tracing::attributes::dispatch::server_address,
480
+ session_->canonical_hostname());
481
+ dispatch_span->add_tag(tracing::attributes::dispatch::server_port,
482
+ session_->canonical_port_number());
483
+ dispatch_span->add_tag(tracing::attributes::dispatch::peer_address,
484
+ session_->remote_hostname());
485
+ dispatch_span->add_tag(tracing::attributes::dispatch::peer_port, session_->remote_port());
486
+ }
487
+ dispatch_span->end();
488
+ }
410
489
  };
411
490
 
412
491
  } // namespace couchbase::core::operations
@@ -240,19 +240,6 @@ class mcbp_session_impl
240
240
  stopped_.compare_exchange_strong(expected_state, true);
241
241
  }
242
242
 
243
- static auto sasl_mechanisms(const std::shared_ptr<mcbp_session_impl>& session)
244
- -> std::vector<std::string>
245
- {
246
- if (const auto user_mechanisms = session->origin_.credentials().allowed_sasl_mechanisms;
247
- user_mechanisms.has_value()) {
248
- return user_mechanisms.value();
249
- }
250
- if (session->is_tls_) {
251
- return { "PLAIN" };
252
- }
253
- return { "SCRAM-SHA512", "SCRAM-SHA256", "SCRAM-SHA1" };
254
- }
255
-
256
243
  auto last_bootstrap_error() && -> impl::bootstrap_error
257
244
  {
258
245
  return std::move(last_bootstrap_error_);
@@ -265,14 +252,7 @@ class mcbp_session_impl
265
252
 
266
253
  explicit bootstrap_handler(std::shared_ptr<mcbp_session_impl> session)
267
254
  : session_(std::move(session))
268
- , sasl_(
269
- [origin = session_->origin_]() {
270
- return origin.username();
271
- },
272
- [origin = session_->origin_]() {
273
- return origin.password();
274
- },
275
- sasl_mechanisms(session_))
255
+ , sasl_(session_->new_sasl_context())
276
256
  {
277
257
  protocol::client_request<protocol::hello_request_body> hello_req;
278
258
  if (session_->origin_.options().enable_unordered_execution) {
@@ -749,6 +729,12 @@ class mcbp_session_impl
749
729
  if (session_) {
750
730
  session_->update_configuration(resp.body().config());
751
731
  }
732
+ } else if (resp.status() == key_value_status_code::auth_stale) {
733
+ CB_LOG_WARNING("{} received auth stale status for {}, opaque={}",
734
+ session_->log_prefix_,
735
+ resp.opcode(),
736
+ resp.opaque());
737
+ session_->stop(retry_reason::do_not_retry);
752
738
  } else {
753
739
  CB_LOG_WARNING("{} unexpected message status: {} (opaque={})",
754
740
  session_->log_prefix_,
@@ -779,11 +765,20 @@ class mcbp_session_impl
779
765
  case protocol::client_opcode::range_scan_cancel:
780
766
  case protocol::client_opcode::decrement:
781
767
  case protocol::client_opcode::subdoc_multi_lookup:
782
- case protocol::client_opcode::subdoc_multi_mutation: {
768
+ case protocol::client_opcode::subdoc_multi_mutation:
769
+ case protocol::client_opcode::sasl_auth: {
783
770
  const std::uint16_t status = utils::byte_swap(msg.header.specific);
784
771
  if (status == static_cast<std::uint16_t>(key_value_status_code::not_my_vbucket)) {
785
772
  session_->handle_not_my_vbucket(msg);
786
773
  }
774
+ if (status == static_cast<std::uint16_t>(key_value_status_code::auth_stale)) {
775
+ CB_LOG_WARNING("{} received auth stale status for {}, opaque={}",
776
+ session_->log_prefix_,
777
+ protocol::client_opcode(msg.header.opcode),
778
+ utils::byte_swap(msg.header.opaque));
779
+ session_->stop(retry_reason::do_not_retry);
780
+ return;
781
+ }
787
782
 
788
783
  std::uint32_t opaque = utils::byte_swap(msg.header.opaque);
789
784
  if (session_->handle_request(opcode, status, opaque, std::move(msg))) {
@@ -880,6 +875,7 @@ public:
880
875
  , bootstrap_deadline_(ctx_)
881
876
  , resolve_deadline_(ctx_)
882
877
  , connection_deadline_(ctx_)
878
+ , reauth_deadline_(ctx_)
883
879
  , retry_backoff_(ctx_)
884
880
  , ping_timeout_(ctx_)
885
881
  , origin_{ std::move(origin) }
@@ -896,7 +892,7 @@ public:
896
892
  mcbp_session_impl(std::string_view client_id,
897
893
  std::string_view node_uuid,
898
894
  asio::io_context& ctx,
899
- asio::ssl::context& tls,
895
+ tls_context_provider& tls,
900
896
  couchbase::core::origin origin,
901
897
  std::shared_ptr<impl::bootstrap_state_listener> state_listener,
902
898
  std::optional<std::string> bucket_name = {},
@@ -909,6 +905,7 @@ public:
909
905
  , bootstrap_deadline_(ctx_)
910
906
  , resolve_deadline_(ctx_)
911
907
  , connection_deadline_(ctx_)
908
+ , reauth_deadline_(ctx_)
912
909
  , retry_backoff_(ctx_)
913
910
  , ping_timeout_(ctx_)
914
911
  , origin_(std::move(origin))
@@ -943,6 +940,16 @@ public:
943
940
  return connection_endpoints_.remote_address_with_port;
944
941
  }
945
942
 
943
+ auto remote_hostname() const -> std::string
944
+ {
945
+ return connection_endpoints_.remote_address;
946
+ }
947
+
948
+ auto remote_port() const -> std::uint16_t
949
+ {
950
+ return connection_endpoints_.remote.port();
951
+ }
952
+
946
953
  auto local_address() const -> std::string
947
954
  {
948
955
  return connection_endpoints_.local_address_with_port;
@@ -962,6 +969,37 @@ public:
962
969
  bucket_name_ };
963
970
  }
964
971
 
972
+ auto sasl_mechanisms() -> std::vector<std::string>
973
+ {
974
+ auto credentials = origin_.credentials();
975
+ if (const auto user_mechanisms = credentials.allowed_sasl_mechanisms;
976
+ user_mechanisms.has_value()) {
977
+ return user_mechanisms.value();
978
+ }
979
+ if (credentials.uses_jwt()) {
980
+ return { "OAUTHBEARER" };
981
+ }
982
+ if (is_tls_) {
983
+ return { "PLAIN" };
984
+ }
985
+ return { "SCRAM-SHA512", "SCRAM-SHA256", "SCRAM-SHA1" };
986
+ }
987
+
988
+ auto new_sasl_context() -> sasl::ClientContext
989
+ {
990
+ return { [this] {
991
+ return origin_.username();
992
+ },
993
+ [this] {
994
+ auto credentials = origin_.credentials();
995
+ if (credentials.uses_jwt()) {
996
+ return credentials.jwt_token;
997
+ }
998
+ return credentials.password;
999
+ },
1000
+ sasl_mechanisms() };
1001
+ }
1002
+
965
1003
  void ping(const std::shared_ptr<diag::ping_reporter>& handler,
966
1004
  std::optional<std::chrono::milliseconds> timeout)
967
1005
  {
@@ -1028,6 +1066,132 @@ public:
1028
1066
  return { config_, supported_features_ };
1029
1067
  }
1030
1068
 
1069
+ void reauthenticate()
1070
+ {
1071
+ if (!bootstrapped_ || stopped_) {
1072
+ CB_LOG_DEBUG("{} Cannot reauthenticate as trying to reauthenticate on non-bootstrapped or "
1073
+ "stopped session",
1074
+ log_prefix_);
1075
+ return;
1076
+ }
1077
+
1078
+ if (reauth_in_progress_) {
1079
+ CB_LOG_DEBUG("{} Attempted to reauthenticate but reauthentication already in progress",
1080
+ log_prefix_);
1081
+ return;
1082
+ }
1083
+
1084
+ reauth_in_progress_ = true;
1085
+
1086
+ auto sasl = new_sasl_context();
1087
+ protocol::client_request<protocol::sasl_auth_request_body> req;
1088
+ auto [sasl_code, sasl_payload] = sasl.start();
1089
+ req.opaque(next_opaque());
1090
+ req.body().mechanism(sasl.get_name());
1091
+ req.body().sasl_data(sasl_payload);
1092
+
1093
+ CB_LOG_TRACE("{} starting reauthentication (opaque={}).", log_prefix_, req.opaque());
1094
+
1095
+ reauth_deadline_.expires_after(origin_.options().key_value_timeout);
1096
+ reauth_deadline_.async_wait(
1097
+ [self = shared_from_this(), opaque = req.opaque()](std::error_code ec) {
1098
+ if (ec == asio::error::operation_aborted || self->stopped_) {
1099
+ return;
1100
+ }
1101
+ CB_LOG_DEBUG("{} Reauthentication timed out (opaque={}).", self->log_prefix_, opaque);
1102
+ static_cast<void>(
1103
+ self->cancel(opaque, errc::common::ambiguous_timeout, retry_reason::do_not_retry));
1104
+ });
1105
+ initiate_reauthenticate(std::move(req));
1106
+ }
1107
+
1108
+ void initiate_reauthenticate(protocol::client_request<protocol::sasl_auth_request_body> req)
1109
+ {
1110
+ auto opaque = req.opaque();
1111
+ auto data = req.data();
1112
+ write_and_subscribe(
1113
+ opaque,
1114
+ std::move(data),
1115
+ [self = shared_from_this(), req = std::move(req)](
1116
+ std::error_code ec,
1117
+ retry_reason reason,
1118
+ io::mcbp_message&& msg,
1119
+ const std::optional<key_value_error_map_info>& /* error_info */) -> void {
1120
+ if (ec == asio::error::operation_aborted || ec == errc::common::request_canceled) {
1121
+ self->reauth_in_progress_ = false;
1122
+ return;
1123
+ }
1124
+
1125
+ key_value_status_code status = key_value_status_code::invalid;
1126
+ std::optional<key_value_error_map_info> error_code;
1127
+ if (protocol::is_valid_status(msg.header.status())) {
1128
+ status = static_cast<key_value_status_code>(msg.header.status());
1129
+ } else {
1130
+ error_code = self->decode_error_code(msg.header.status());
1131
+ }
1132
+
1133
+ if (status == key_value_status_code::success) {
1134
+ self->reauth_deadline_.cancel();
1135
+ self->reauth_in_progress_ = false;
1136
+ CB_LOG_DEBUG(
1137
+ "{} reauthentication succeeded (opaque={})", self->log_prefix_, req.opaque());
1138
+ return;
1139
+ }
1140
+
1141
+ if (status == key_value_status_code::auth_continue) {
1142
+ self->reauth_deadline_.cancel();
1143
+ self->reauth_in_progress_ = false;
1144
+ CB_LOG_DEBUG("{} reauthentication received unexpected auth_continue (opaque={})",
1145
+ self->log_prefix_,
1146
+ req.opaque());
1147
+ return;
1148
+ }
1149
+
1150
+ if (error_code && error_code.value().has_retry_attribute()) {
1151
+ reason = retry_reason::key_value_error_map_retry_indicated;
1152
+ } else {
1153
+ switch (status) {
1154
+ case key_value_status_code::temporary_failure:
1155
+ reason = retry_reason::key_value_temporary_failure;
1156
+ default:
1157
+ break;
1158
+ }
1159
+ }
1160
+
1161
+ if (reason == retry_reason::do_not_retry || reason == retry_reason::unknown) {
1162
+ CB_LOG_WARNING("{} reauthentication failed (code={}, message={}, reason={}, opaque={})",
1163
+ self->log_prefix_,
1164
+ ec.value(),
1165
+ ec.message(),
1166
+ reason,
1167
+ req.opaque());
1168
+ self->reauth_deadline_.cancel();
1169
+ self->reauth_in_progress_ = false;
1170
+ return;
1171
+ }
1172
+
1173
+ CB_LOG_DEBUG("{} reauthentication failed (code={}, reason={}, opaque={}), scheduling retry",
1174
+ self->log_prefix_,
1175
+ ec.value(),
1176
+ reason,
1177
+ req.opaque());
1178
+
1179
+ auto backoff = std::chrono::milliseconds(300);
1180
+ self->retry_backoff_.expires_after(backoff);
1181
+ self->retry_backoff_.async_wait([self, req = req](std::error_code ec) -> void {
1182
+ if (ec == asio::error::operation_aborted || !self->reauth_in_progress_) {
1183
+ return;
1184
+ }
1185
+ self->initiate_reauthenticate(req);
1186
+ });
1187
+ });
1188
+ }
1189
+
1190
+ void update_credentials(cluster_credentials credentials)
1191
+ {
1192
+ origin_.update_credentials(std::move(credentials));
1193
+ }
1194
+
1031
1195
  void bootstrap(utils::movable_function<void(std::error_code, topology::configuration)>&& callback,
1032
1196
  bool retry_on_bucket_not_found = false)
1033
1197
  {
@@ -1225,6 +1389,7 @@ public:
1225
1389
  bootstrap_deadline_.cancel();
1226
1390
  resolve_deadline_.cancel();
1227
1391
  connection_deadline_.cancel();
1392
+ reauth_deadline_.cancel();
1228
1393
  retry_backoff_.cancel();
1229
1394
  ping_timeout_.cancel();
1230
1395
  resolver_.cancel();
@@ -1533,6 +1698,16 @@ public:
1533
1698
  return bootstrap_port_number_;
1534
1699
  }
1535
1700
 
1701
+ [[nodiscard]] auto canonical_hostname() const -> const std::string&
1702
+ {
1703
+ return canonical_hostname_;
1704
+ }
1705
+
1706
+ [[nodiscard]] auto canonical_port_number() const -> std::uint16_t
1707
+ {
1708
+ return canonical_port_number_;
1709
+ }
1710
+
1536
1711
  [[nodiscard]] auto next_opaque() -> std::uint32_t
1537
1712
  {
1538
1713
  return ++opaque_;
@@ -1743,10 +1918,18 @@ private:
1743
1918
  if (ec) {
1744
1919
  return stop(retry_reason::node_not_available);
1745
1920
  }
1746
- if (node_uuid_.empty() && config_.has_value()) {
1921
+ if (config_.has_value()) {
1747
1922
  for (const auto& node : config_.value().nodes) {
1748
1923
  if (node.this_node) {
1749
- node_uuid_ = node.node_uuid;
1924
+ if (node_uuid_.empty()) {
1925
+ node_uuid_ = node.node_uuid;
1926
+ }
1927
+ if (canonical_hostname_.empty()) {
1928
+ canonical_hostname_ = node.hostname;
1929
+ }
1930
+ if (canonical_port_number_ == 0) {
1931
+ canonical_port_number_ = node.port_or(service_type::key_value, is_tls_, 0);
1932
+ }
1750
1933
  }
1751
1934
  }
1752
1935
  }
@@ -2068,6 +2251,7 @@ private:
2068
2251
  asio::steady_timer bootstrap_deadline_;
2069
2252
  asio::steady_timer resolve_deadline_;
2070
2253
  asio::steady_timer connection_deadline_;
2254
+ asio::steady_timer reauth_deadline_;
2071
2255
  asio::steady_timer retry_backoff_;
2072
2256
  asio::steady_timer ping_timeout_;
2073
2257
  couchbase::core::origin origin_;
@@ -2085,6 +2269,7 @@ private:
2085
2269
 
2086
2270
  std::atomic_bool bootstrapped_{ false };
2087
2271
  std::atomic_bool stopped_{ false };
2272
+ std::atomic_bool reauth_in_progress_{ false };
2088
2273
  bool authenticated_{ false };
2089
2274
  bool bucket_selected_{ false };
2090
2275
  bool supports_gcccp_{ true };
@@ -2112,6 +2297,10 @@ private:
2112
2297
  std::optional<error_map> error_map_;
2113
2298
  collection_cache collection_cache_;
2114
2299
 
2300
+ // Only used for tracing & metrics. They represent the address of the node as given in the config.
2301
+ std::string canonical_hostname_{};
2302
+ std::uint16_t canonical_port_number_{};
2303
+
2115
2304
  const bool is_tls_;
2116
2305
  std::shared_ptr<impl::bootstrap_state_listener> state_listener_{ nullptr };
2117
2306
 
@@ -2153,7 +2342,7 @@ mcbp_session::mcbp_session(const std::string& client_id,
2153
2342
  mcbp_session::mcbp_session(const std::string& client_id,
2154
2343
  const std::string& node_uuid,
2155
2344
  asio::io_context& ctx,
2156
- asio::ssl::context& tls,
2345
+ tls_context_provider& tls,
2157
2346
  core::origin origin,
2158
2347
  std::shared_ptr<impl::bootstrap_state_listener> state_listener,
2159
2348
  std::optional<std::string> bucket_name,
@@ -2241,6 +2430,18 @@ mcbp_session::remote_address() const -> std::string
2241
2430
  return impl_->remote_address();
2242
2431
  }
2243
2432
 
2433
+ auto
2434
+ mcbp_session::remote_hostname() const -> std::string
2435
+ {
2436
+ return impl_->remote_hostname();
2437
+ }
2438
+
2439
+ auto
2440
+ mcbp_session::remote_port() const -> std::uint16_t
2441
+ {
2442
+ return impl_->remote_port();
2443
+ }
2444
+
2244
2445
  auto
2245
2446
  mcbp_session::local_address() const -> std::string
2246
2447
  {
@@ -2277,6 +2478,18 @@ mcbp_session::last_bootstrap_error() const& -> const std::optional<impl::bootstr
2277
2478
  return impl_->last_bootstrap_error();
2278
2479
  }
2279
2480
 
2481
+ auto
2482
+ mcbp_session::canonical_hostname() const -> const std::string&
2483
+ {
2484
+ return impl_->canonical_hostname();
2485
+ }
2486
+
2487
+ auto
2488
+ mcbp_session::canonical_port_number() const -> std::uint16_t
2489
+ {
2490
+ return impl_->canonical_port_number();
2491
+ }
2492
+
2280
2493
  void
2281
2494
  mcbp_session::write_and_subscribe(std::uint32_t opaque,
2282
2495
  std::vector<std::byte>&& data,
@@ -2293,6 +2506,18 @@ mcbp_session::bootstrap(
2293
2506
  return impl_->bootstrap(std::move(handler), retry_on_bucket_not_found);
2294
2507
  }
2295
2508
 
2509
+ void
2510
+ mcbp_session::reauthenticate()
2511
+ {
2512
+ return impl_->reauthenticate();
2513
+ }
2514
+
2515
+ void
2516
+ mcbp_session::update_credentials(cluster_credentials credentials)
2517
+ {
2518
+ return impl_->update_credentials(std::move(credentials));
2519
+ }
2520
+
2296
2521
  void
2297
2522
  mcbp_session::on_stop(utils::movable_function<void()> handler)
2298
2523
  {