couchbase 4.2.8 → 4.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (370) hide show
  1. package/CMakeLists.txt +1 -1
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +139 -56
  3. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  4. package/deps/couchbase-cxx-client/CMakeLists.txt +401 -424
  5. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  6. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  7. package/deps/couchbase-cxx-client/core/agent_config.hxx +1 -1
  8. package/deps/couchbase-cxx-client/core/agent_group.cxx +0 -1
  9. package/deps/couchbase-cxx-client/core/agent_group.hxx +9 -0
  10. package/deps/couchbase-cxx-client/core/agent_group_config.hxx +1 -1
  11. package/deps/couchbase-cxx-client/core/bucket.cxx +74 -10
  12. package/deps/couchbase-cxx-client/core/bucket.hxx +4 -2
  13. package/deps/couchbase-cxx-client/core/cluster.cxx +1491 -108
  14. package/deps/couchbase-cxx-client/core/cluster.hxx +183 -473
  15. package/deps/couchbase-cxx-client/core/cluster_agent_config.hxx +1 -1
  16. package/deps/couchbase-cxx-client/core/cluster_options.cxx +12 -2
  17. package/deps/couchbase-cxx-client/core/cluster_options.hxx +9 -8
  18. package/deps/couchbase-cxx-client/core/config_profiles.cxx +2 -2
  19. package/deps/couchbase-cxx-client/core/config_profiles.hxx +1 -1
  20. package/deps/couchbase-cxx-client/core/core_sdk_shim.cxx +1 -2
  21. package/deps/couchbase-cxx-client/core/core_sdk_shim.hxx +3 -2
  22. package/deps/couchbase-cxx-client/core/diagnostics.hxx +0 -1
  23. package/deps/couchbase-cxx-client/core/dispatcher.cxx +2 -2
  24. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +38 -76
  25. package/deps/couchbase-cxx-client/core/impl/analytics.hxx +40 -0
  26. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +820 -0
  27. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +403 -0
  28. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +102 -0
  29. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +433 -0
  30. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +299 -44
  31. package/deps/couchbase-cxx-client/core/impl/collection.cxx +1384 -0
  32. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +306 -0
  33. package/deps/couchbase-cxx-client/core/impl/configuration_profiles_registry.cxx +3 -1
  34. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  35. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  36. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +2 -0
  37. package/deps/couchbase-cxx-client/core/{operations/mcbp_noop.cxx → impl/doc_id_query.cxx} +19 -15
  38. package/deps/couchbase-cxx-client/core/impl/key_value_error_category.cxx +4 -2
  39. package/deps/couchbase-cxx-client/core/impl/lookup_in_all_replicas.hxx +0 -10
  40. package/deps/couchbase-cxx-client/core/impl/lookup_in_any_replica.hxx +0 -10
  41. package/deps/couchbase-cxx-client/core/impl/observe_poll.cxx +24 -17
  42. package/deps/couchbase-cxx-client/core/impl/observe_poll.hxx +1 -1
  43. package/deps/couchbase-cxx-client/core/impl/query.cxx +45 -68
  44. package/deps/couchbase-cxx-client/core/impl/query.hxx +34 -0
  45. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +628 -0
  46. package/deps/couchbase-cxx-client/core/impl/scope.cxx +187 -0
  47. package/deps/couchbase-cxx-client/core/impl/search.cxx +81 -57
  48. package/deps/couchbase-cxx-client/core/impl/search.hxx +45 -0
  49. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +712 -0
  50. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  51. package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +12 -0
  52. package/deps/couchbase-cxx-client/core/impl/search_sort_geo_distance.cxx +87 -0
  53. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  54. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  55. package/deps/couchbase-cxx-client/core/impl/with_legacy_durability.hxx +23 -25
  56. package/deps/couchbase-cxx-client/core/io/dns_config.cxx +28 -0
  57. package/deps/couchbase-cxx-client/core/io/dns_config.hxx +6 -25
  58. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  59. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +9 -1
  60. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +1 -1
  61. package/deps/couchbase-cxx-client/core/io/mcbp_message.hxx +3 -2
  62. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +75 -53
  63. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +3 -1
  64. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  65. package/deps/couchbase-cxx-client/core/logger/logger.hxx +4 -4
  66. package/deps/couchbase-cxx-client/core/management/bucket_settings.hxx +1 -1
  67. package/deps/couchbase-cxx-client/core/mcbp/packet.cxx +1 -1
  68. package/deps/couchbase-cxx-client/core/mcbp/queue_callback.hxx +1 -1
  69. package/deps/couchbase-cxx-client/core/meta/features.hxx +38 -0
  70. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +23 -2
  71. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -1
  72. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  73. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  74. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.cxx +2 -0
  75. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.cxx +2 -0
  76. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.cxx +2 -0
  77. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.cxx +2 -0
  78. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.cxx +2 -0
  79. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.cxx +2 -0
  80. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.cxx +2 -0
  81. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.cxx +2 -0
  82. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.cxx +2 -0
  83. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.cxx +2 -0
  84. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.cxx +1 -1
  85. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.cxx +2 -0
  86. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.cxx +2 -0
  87. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.cxx +2 -0
  88. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.cxx +2 -0
  89. package/deps/couchbase-cxx-client/core/operations/management/change_password.cxx +3 -1
  90. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +9 -6
  91. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  92. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +2 -0
  93. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +9 -8
  94. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  95. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +9 -5
  96. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.cxx +2 -0
  97. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.cxx +2 -0
  98. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.cxx +2 -0
  99. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.cxx +2 -0
  100. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.cxx +2 -0
  101. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.cxx +2 -0
  102. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.cxx +2 -0
  103. package/deps/couchbase-cxx-client/core/operations/management/group_drop.cxx +2 -0
  104. package/deps/couchbase-cxx-client/core/operations/management/group_get.cxx +2 -0
  105. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.cxx +1 -1
  106. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +2 -2
  107. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +4 -1
  108. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +4 -1
  109. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.cxx +1 -1
  110. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +1 -1
  111. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +2 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +2 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.cxx +2 -0
  114. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.cxx +4 -4
  115. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +4 -4
  116. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +19 -1
  117. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  118. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +23 -1
  119. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  120. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +23 -1
  121. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  122. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +23 -1
  123. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  124. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +19 -1
  125. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +19 -1
  127. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  129. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +20 -1
  131. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  132. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.cxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +19 -1
  134. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  135. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.cxx +2 -0
  136. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.cxx +2 -0
  137. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.cxx +2 -0
  138. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.cxx +2 -0
  139. package/deps/couchbase-cxx-client/core/operations.hxx +0 -1
  140. package/deps/couchbase-cxx-client/core/operations_fwd.hxx +260 -0
  141. package/deps/couchbase-cxx-client/core/origin.cxx +146 -5
  142. package/deps/couchbase-cxx-client/core/origin.hxx +30 -140
  143. package/deps/couchbase-cxx-client/core/protocol/cmd_cluster_map_change_notification.hxx +3 -3
  144. package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +5 -0
  145. package/deps/couchbase-cxx-client/core/protocol/cmd_observe_seqno.hxx +4 -4
  146. package/deps/couchbase-cxx-client/core/protocol/hello_feature.hxx +6 -0
  147. package/deps/couchbase-cxx-client/core/protocol/hello_feature_fmt.hxx +3 -0
  148. package/deps/couchbase-cxx-client/core/protocol/status.cxx +6 -0
  149. package/deps/couchbase-cxx-client/core/protocol/status.hxx +1 -0
  150. package/deps/couchbase-cxx-client/core/query_context.hxx +11 -7
  151. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +1 -1
  152. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  153. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  154. package/deps/couchbase-cxx-client/core/topology/configuration.cxx +23 -0
  155. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +8 -12
  156. package/deps/couchbase-cxx-client/core/topology/configuration_fmt.hxx +3 -3
  157. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +2 -0
  158. package/deps/couchbase-cxx-client/core/topology/error_map.hxx +2 -2
  159. package/deps/couchbase-cxx-client/core/topology/error_map_json.hxx +4 -0
  160. package/deps/couchbase-cxx-client/core/transactions/active_transaction_record.cxx +58 -0
  161. package/deps/couchbase-cxx-client/core/transactions/active_transaction_record.hxx +5 -40
  162. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.cxx +30 -0
  163. package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +18 -18
  164. package/deps/couchbase-cxx-client/core/transactions/attempt_context.cxx +36 -0
  165. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +39 -41
  166. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +2 -2
  167. package/deps/couchbase-cxx-client/core/transactions/internal/atr_cleanup_entry.hxx +3 -1
  168. package/deps/couchbase-cxx-client/core/transactions/internal/atr_entry.hxx +2 -0
  169. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.cxx +32 -0
  170. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +4 -30
  171. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record_fmt.hxx +41 -0
  172. package/deps/couchbase-cxx-client/core/transactions/internal/logging.hxx +17 -15
  173. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +1 -1
  174. package/deps/couchbase-cxx-client/core/transactions/internal/transactions_cleanup.hxx +4 -4
  175. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +5 -13
  176. package/deps/couchbase-cxx-client/core/transactions/result.hxx +0 -26
  177. package/deps/couchbase-cxx-client/core/transactions/result_fmt.hxx +46 -0
  178. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +16 -14
  179. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +6 -6
  180. package/deps/couchbase-cxx-client/core/transactions/transaction_keyspace.cxx +48 -0
  181. package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +1 -0
  182. package/deps/couchbase-cxx-client/core/transactions/transaction_options.cxx +61 -4
  183. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +9 -8
  184. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +9 -16
  185. package/deps/couchbase-cxx-client/core/transactions/transactions_config.cxx +7 -6
  186. package/deps/couchbase-cxx-client/core/transactions.hxx +6 -5
  187. package/deps/couchbase-cxx-client/core/utils/join_strings.hxx +4 -3
  188. package/deps/couchbase-cxx-client/core/utils/keyspace.hxx +4 -4
  189. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  190. package/deps/couchbase-cxx-client/couchbase/allow_querying_search_index_options.hxx +44 -0
  191. package/deps/couchbase-cxx-client/couchbase/analytics_index_manager.hxx +463 -0
  192. package/deps/couchbase-cxx-client/couchbase/analyze_document_options.hxx +44 -0
  193. package/deps/couchbase-cxx-client/couchbase/append_options.hxx +0 -24
  194. package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +1 -1
  195. package/deps/couchbase-cxx-client/couchbase/binary_collection.hxx +19 -115
  196. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +42 -30
  197. package/deps/couchbase-cxx-client/couchbase/bucket_manager.hxx +8 -7
  198. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +0 -1
  199. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +151 -73
  200. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +1 -27
  201. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  202. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  203. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  204. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  205. package/deps/couchbase-cxx-client/couchbase/collection.hxx +176 -386
  206. package/deps/couchbase-cxx-client/couchbase/collection_manager.hxx +8 -9
  207. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +21 -24
  208. package/deps/couchbase-cxx-client/couchbase/connect_link_analytics_options.hxx +116 -0
  209. package/deps/couchbase-cxx-client/couchbase/create_bucket_options.hxx +3 -3
  210. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +32 -3
  211. package/deps/couchbase-cxx-client/couchbase/create_dataset_analytics_options.hxx +120 -0
  212. package/deps/couchbase-cxx-client/couchbase/create_dataverse_analytics_options.hxx +85 -0
  213. package/deps/couchbase-cxx-client/couchbase/create_index_analytics_options.hxx +103 -0
  214. package/deps/couchbase-cxx-client/couchbase/create_link_analytics_options.hxx +63 -0
  215. package/deps/couchbase-cxx-client/couchbase/decrement_options.hxx +0 -23
  216. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  217. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  218. package/deps/couchbase-cxx-client/couchbase/disallow_querying_search_index_options.hxx +43 -0
  219. package/deps/couchbase-cxx-client/couchbase/disconnect_link_analytics_options.hxx +105 -0
  220. package/deps/couchbase-cxx-client/couchbase/drop_dataset_analytics_options.hxx +103 -0
  221. package/deps/couchbase-cxx-client/couchbase/drop_dataverse_analytics_options.hxx +84 -0
  222. package/deps/couchbase-cxx-client/couchbase/drop_index_analytics_options.hxx +103 -0
  223. package/deps/couchbase-cxx-client/couchbase/drop_link_analytics_options.hxx +63 -0
  224. package/deps/couchbase-cxx-client/couchbase/drop_search_index_options.hxx +43 -0
  225. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  226. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  227. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +22 -1
  228. package/deps/couchbase-cxx-client/couchbase/exists_options.hxx +0 -23
  229. package/deps/couchbase-cxx-client/couchbase/fmt/key_value_error_map_attribute.hxx +6 -0
  230. package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -0
  231. package/deps/couchbase-cxx-client/couchbase/fmt/transaction_keyspace.hxx +37 -0
  232. package/deps/couchbase-cxx-client/couchbase/freeze_plan_search_index_options.hxx +43 -0
  233. package/deps/couchbase-cxx-client/couchbase/get_all_datasets_analytics_options.hxx +66 -0
  234. package/deps/couchbase-cxx-client/couchbase/get_all_indexes_analytics_options.hxx +65 -0
  235. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +1 -4
  236. package/deps/couchbase-cxx-client/couchbase/get_all_replicas_options.hxx +0 -23
  237. package/deps/couchbase-cxx-client/couchbase/get_all_search_indexes_options.hxx +45 -0
  238. package/deps/couchbase-cxx-client/couchbase/get_and_lock_options.hxx +0 -24
  239. package/deps/couchbase-cxx-client/couchbase/get_and_touch_options.hxx +0 -24
  240. package/deps/couchbase-cxx-client/couchbase/get_any_replica_options.hxx +0 -23
  241. package/deps/couchbase-cxx-client/couchbase/get_indexed_search_index_options.hxx +43 -0
  242. package/deps/couchbase-cxx-client/couchbase/get_links_analytics_options.hxx +121 -0
  243. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -29
  244. package/deps/couchbase-cxx-client/couchbase/get_pending_mutations_analytics_options.hxx +67 -0
  245. package/deps/couchbase-cxx-client/couchbase/get_search_index_options.hxx +44 -0
  246. package/deps/couchbase-cxx-client/couchbase/increment_options.hxx +0 -23
  247. package/deps/couchbase-cxx-client/couchbase/insert_options.hxx +0 -24
  248. package/deps/couchbase-cxx-client/couchbase/key_value_error_map_attribute.hxx +12 -0
  249. package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
  250. package/deps/couchbase-cxx-client/couchbase/lookup_in_options.hxx +0 -24
  251. package/deps/couchbase-cxx-client/couchbase/management/analytics_dataset.hxx +48 -0
  252. package/deps/couchbase-cxx-client/couchbase/management/analytics_index.hxx +48 -0
  253. package/deps/couchbase-cxx-client/couchbase/management/analytics_link.hxx +239 -0
  254. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  255. package/deps/couchbase-cxx-client/couchbase/management/query_index.hxx +3 -3
  256. package/deps/couchbase-cxx-client/couchbase/management/search_index.hxx +40 -0
  257. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +0 -1
  258. package/deps/couchbase-cxx-client/couchbase/mutate_in_options.hxx +0 -24
  259. package/deps/couchbase-cxx-client/couchbase/network_options.hxx +1 -1
  260. package/deps/couchbase-cxx-client/couchbase/pause_ingest_search_index_options.hxx +43 -0
  261. package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +19 -0
  262. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  263. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  264. package/deps/couchbase-cxx-client/couchbase/prepend_options.hxx +0 -24
  265. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +99 -20
  266. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +0 -21
  267. package/deps/couchbase-cxx-client/couchbase/remove_options.hxx +0 -23
  268. package/deps/couchbase-cxx-client/couchbase/replace_link_analytics_options.hxx +63 -0
  269. package/deps/couchbase-cxx-client/couchbase/replace_options.hxx +0 -24
  270. package/deps/couchbase-cxx-client/couchbase/resume_ingest_search_index_options.hxx +43 -0
  271. package/deps/couchbase-cxx-client/couchbase/scope.hxx +37 -53
  272. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  273. package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +1 -7
  274. package/deps/couchbase-cxx-client/couchbase/search_geo_distance_units.hxx +26 -0
  275. package/deps/couchbase-cxx-client/couchbase/search_index_manager.hxx +292 -0
  276. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  277. package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +10 -0
  278. package/deps/couchbase-cxx-client/couchbase/search_sort_geo_distance.hxx +84 -0
  279. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +1 -1
  280. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  281. package/deps/couchbase-cxx-client/couchbase/touch_options.hxx +0 -24
  282. package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +1 -1
  283. package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +10 -7
  284. package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +10 -10
  285. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +8 -58
  286. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +28 -70
  287. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +7 -2
  288. package/deps/couchbase-cxx-client/couchbase/transactions/transactions_cleanup_config.hxx +2 -1
  289. package/deps/couchbase-cxx-client/couchbase/transactions/transactions_config.hxx +11 -38
  290. package/deps/couchbase-cxx-client/couchbase/unfreeze_plan_search_index_options.hxx +43 -0
  291. package/deps/couchbase-cxx-client/couchbase/unlock_options.hxx +0 -24
  292. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  293. package/deps/couchbase-cxx-client/couchbase/upsert_options.hxx +0 -24
  294. package/deps/couchbase-cxx-client/couchbase/upsert_search_index_options.hxx +41 -0
  295. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  296. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  297. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  298. package/dist/binding.d.ts +16 -9
  299. package/dist/binding.js +4 -1
  300. package/dist/bindingutilities.d.ts +6 -1
  301. package/dist/bindingutilities.js +17 -1
  302. package/dist/cluster.d.ts +12 -1
  303. package/dist/cluster.js +22 -0
  304. package/dist/collection.js +3 -3
  305. package/dist/couchbase.d.ts +1 -0
  306. package/dist/couchbase.js +1 -0
  307. package/dist/errors.d.ts +9 -0
  308. package/dist/errors.js +14 -2
  309. package/dist/searchexecutor.d.ts +2 -2
  310. package/dist/searchexecutor.js +19 -3
  311. package/dist/searchtypes.d.ts +46 -0
  312. package/dist/searchtypes.js +81 -1
  313. package/dist/transactions.d.ts +2 -0
  314. package/dist/transactions.js +2 -3
  315. package/dist/usermanager.js +1 -1
  316. package/dist/vectorsearch.d.ts +99 -0
  317. package/dist/vectorsearch.js +132 -0
  318. package/package.json +7 -7
  319. package/src/binding.cpp +1 -0
  320. package/src/connection.cpp +12 -9
  321. package/src/connection.hpp +3 -3
  322. package/src/connection_autogen.cpp +7 -5
  323. package/src/constants.cpp +14 -0
  324. package/src/instance.cpp +2 -2
  325. package/src/instance.hpp +1 -1
  326. package/src/jstocbpp_autogen.hpp +45 -45
  327. package/src/jstocbpp_basic.hpp +2 -0
  328. package/src/jstocbpp_errors.hpp +1 -0
  329. package/src/jstocbpp_transactions.hpp +6 -22
  330. package/src/mutationtoken.hpp +1 -0
  331. package/tools/gen-bindings-json.py +41 -16
  332. package/deps/couchbase-cxx-client/core/impl/append.cxx +0 -87
  333. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +0 -157
  334. package/deps/couchbase-cxx-client/core/impl/create_bucket.cxx +0 -158
  335. package/deps/couchbase-cxx-client/core/impl/create_collection.cxx +0 -83
  336. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +0 -232
  337. package/deps/couchbase-cxx-client/core/impl/create_scope.cxx +0 -69
  338. package/deps/couchbase-cxx-client/core/impl/decrement.cxx +0 -96
  339. package/deps/couchbase-cxx-client/core/impl/drop_bucket.cxx +0 -66
  340. package/deps/couchbase-cxx-client/core/impl/drop_collection.cxx +0 -76
  341. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +0 -187
  342. package/deps/couchbase-cxx-client/core/impl/drop_scope.cxx +0 -68
  343. package/deps/couchbase-cxx-client/core/impl/exists.cxx +0 -47
  344. package/deps/couchbase-cxx-client/core/impl/flush_bucket.cxx +0 -66
  345. package/deps/couchbase-cxx-client/core/impl/get.cxx +0 -68
  346. package/deps/couchbase-cxx-client/core/impl/get_all_buckets.cxx +0 -178
  347. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +0 -106
  348. package/deps/couchbase-cxx-client/core/impl/get_all_replicas.cxx +0 -145
  349. package/deps/couchbase-cxx-client/core/impl/get_all_scopes.cxx +0 -94
  350. package/deps/couchbase-cxx-client/core/impl/get_and_lock.cxx +0 -49
  351. package/deps/couchbase-cxx-client/core/impl/get_and_touch.cxx +0 -49
  352. package/deps/couchbase-cxx-client/core/impl/get_any_replica.cxx +0 -134
  353. package/deps/couchbase-cxx-client/core/impl/get_bucket.cxx +0 -168
  354. package/deps/couchbase-cxx-client/core/impl/increment.cxx +0 -96
  355. package/deps/couchbase-cxx-client/core/impl/insert.cxx +0 -90
  356. package/deps/couchbase-cxx-client/core/impl/lookup_in.cxx +0 -69
  357. package/deps/couchbase-cxx-client/core/impl/lookup_in_all_replicas.cxx +0 -178
  358. package/deps/couchbase-cxx-client/core/impl/lookup_in_any_replica.cxx +0 -169
  359. package/deps/couchbase-cxx-client/core/impl/mutate_in.cxx +0 -125
  360. package/deps/couchbase-cxx-client/core/impl/prepend.cxx +0 -87
  361. package/deps/couchbase-cxx-client/core/impl/remove.cxx +0 -86
  362. package/deps/couchbase-cxx-client/core/impl/replace.cxx +0 -102
  363. package/deps/couchbase-cxx-client/core/impl/touch.cxx +0 -49
  364. package/deps/couchbase-cxx-client/core/impl/unlock.cxx +0 -47
  365. package/deps/couchbase-cxx-client/core/impl/update_bucket.cxx +0 -133
  366. package/deps/couchbase-cxx-client/core/impl/update_collection.cxx +0 -83
  367. package/deps/couchbase-cxx-client/core/impl/upsert.cxx +0 -100
  368. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +0 -196
  369. package/deps/couchbase-cxx-client/core/operations/mcbp_noop.hxx +0 -49
  370. /package/deps/couchbase-cxx-client/core/impl/{streaming_json_lexter_error_category.cxx → streaming_json_lexer_error_category.cxx} +0 -0
@@ -0,0 +1,1384 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "core/cluster.hxx"
19
+ #include "core/operations/document_append.hxx"
20
+ #include "core/operations/document_decrement.hxx"
21
+ #include "core/operations/document_exists.hxx"
22
+ #include "core/operations/document_get.hxx"
23
+ #include "core/operations/document_get_and_lock.hxx"
24
+ #include "core/operations/document_get_and_touch.hxx"
25
+ #include "core/operations/document_get_projected.hxx"
26
+ #include "core/operations/document_increment.hxx"
27
+ #include "core/operations/document_insert.hxx"
28
+ #include "core/operations/document_lookup_in.hxx"
29
+ #include "core/operations/document_mutate_in.hxx"
30
+ #include "core/operations/document_prepend.hxx"
31
+ #include "core/operations/document_remove.hxx"
32
+ #include "core/operations/document_replace.hxx"
33
+ #include "core/operations/document_touch.hxx"
34
+ #include "core/operations/document_unlock.hxx"
35
+ #include "core/operations/document_upsert.hxx"
36
+ #include "get_all_replicas.hxx"
37
+ #include "get_any_replica.hxx"
38
+ #include "get_replica.hxx"
39
+ #include "lookup_in_all_replicas.hxx"
40
+ #include "lookup_in_any_replica.hxx"
41
+ #include "lookup_in_replica.hxx"
42
+ #include "observe_poll.hxx"
43
+
44
+ #include <couchbase/collection.hxx>
45
+
46
+ #include <memory>
47
+
48
+ namespace couchbase
49
+ {
50
+ class collection_impl : public std::enable_shared_from_this<collection_impl>
51
+ {
52
+ public:
53
+ collection_impl(core::cluster core, std::string_view bucket_name, std::string_view scope_name, std::string_view name)
54
+ : core_{ std::move(core) }
55
+ , bucket_name_{ bucket_name }
56
+ , scope_name_{ scope_name }
57
+ , name_{ name }
58
+ {
59
+ }
60
+
61
+ [[nodiscard]] auto bucket_name() const -> const std::string&
62
+ {
63
+ return bucket_name_;
64
+ }
65
+
66
+ [[nodiscard]] auto scope_name() const -> const std::string&
67
+ {
68
+ return scope_name_;
69
+ }
70
+
71
+ [[nodiscard]] auto name() const -> const std::string&
72
+ {
73
+ return name_;
74
+ }
75
+
76
+ [[nodiscard]] auto core() const -> const core::cluster&
77
+ {
78
+ return core_;
79
+ }
80
+
81
+ void get(std::string document_key, get_options::built options, get_handler&& handler) const
82
+ {
83
+ if (!options.with_expiry && options.projections.empty()) {
84
+ return core_.execute(
85
+ core::operations::get_request{
86
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
87
+ {},
88
+ {},
89
+ options.timeout,
90
+ { options.retry_strategy },
91
+ },
92
+ [handler = std::move(handler)](auto resp) mutable {
93
+ return handler(std::move(resp.ctx), get_result{ resp.cas, { std::move(resp.value), resp.flags }, {} });
94
+ });
95
+ }
96
+ return core_.execute(
97
+ core::operations::get_projected_request{
98
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
99
+ {},
100
+ {},
101
+ options.projections,
102
+ options.with_expiry,
103
+ {},
104
+ false,
105
+ options.timeout,
106
+ { options.retry_strategy },
107
+ },
108
+ [handler = std::move(handler)](auto resp) mutable {
109
+ std::optional<std::chrono::system_clock::time_point> expiry_time{};
110
+ if (resp.expiry && resp.expiry.value() > 0) {
111
+ expiry_time.emplace(std::chrono::seconds{ resp.expiry.value() });
112
+ }
113
+ return handler(std::move(resp.ctx), get_result{ resp.cas, { std::move(resp.value), resp.flags }, expiry_time });
114
+ });
115
+ }
116
+
117
+ void get_and_touch(std::string document_key,
118
+ std::uint32_t expiry,
119
+ get_and_touch_options::built options,
120
+ get_and_touch_handler&& handler) const
121
+ {
122
+ return core_.execute(
123
+ core::operations::get_and_touch_request{
124
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
125
+ {},
126
+ {},
127
+ expiry,
128
+ options.timeout,
129
+ { options.retry_strategy },
130
+ },
131
+ [handler = std::move(handler)](auto resp) mutable {
132
+ return handler(std::move(resp.ctx), get_result{ resp.cas, { std::move(resp.value), resp.flags }, {} });
133
+ });
134
+ }
135
+
136
+ void touch(std::string document_key, std::uint32_t expiry, touch_options::built options, touch_handler&& handler) const
137
+ {
138
+ return core_.execute(
139
+ core::operations::touch_request{
140
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
141
+ {},
142
+ {},
143
+ expiry,
144
+ options.timeout,
145
+ { options.retry_strategy },
146
+ },
147
+ [handler = std::move(handler)](auto resp) mutable { return handler(std::move(resp.ctx), result{ resp.cas }); });
148
+ }
149
+
150
+ void get_any_replica(std::string document_key,
151
+ const get_any_replica_options::built& options,
152
+ core::impl::movable_get_any_replica_handler&& handler) const
153
+ {
154
+ auto request =
155
+ std::make_shared<core::impl::get_any_replica_request>(bucket_name_, scope_name_, name_, std::move(document_key), options.timeout);
156
+ core_.with_bucket_configuration(
157
+ bucket_name_,
158
+ [core = core_, r = std::move(request), h = std::move(handler)](std::error_code ec,
159
+ const core::topology::configuration& config) mutable {
160
+ if (ec) {
161
+ return h(make_key_value_error_context(ec, r->id()), get_replica_result{});
162
+ }
163
+ struct replica_context {
164
+ replica_context(core::impl::movable_get_any_replica_handler&& handler, std::uint32_t expected_responses)
165
+ : handler_(std::move(handler))
166
+ , expected_responses_(expected_responses)
167
+ {
168
+ }
169
+
170
+ core::impl::movable_get_any_replica_handler handler_;
171
+ std::uint32_t expected_responses_;
172
+ bool done_{ false };
173
+ std::mutex mutex_{};
174
+ };
175
+ auto ctx = std::make_shared<replica_context>(std::move(h), config.num_replicas.value_or(0U) + 1U);
176
+
177
+ for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
178
+ core::document_id replica_id{ r->id() };
179
+ replica_id.node_index(idx);
180
+ core.execute(core::impl::get_replica_request{ std::move(replica_id), r->timeout() }, [ctx](auto&& resp) {
181
+ core::impl::movable_get_any_replica_handler local_handler;
182
+ {
183
+ const std::scoped_lock lock(ctx->mutex_);
184
+ if (ctx->done_) {
185
+ return;
186
+ }
187
+ --ctx->expected_responses_;
188
+ if (resp.ctx.ec()) {
189
+ if (ctx->expected_responses_ > 0) {
190
+ // just ignore the response
191
+ return;
192
+ }
193
+ // consider document irretrievable and give up
194
+ resp.ctx.override_ec(errc::key_value::document_irretrievable);
195
+ }
196
+ ctx->done_ = true;
197
+ std::swap(local_handler, ctx->handler_);
198
+ }
199
+ if (local_handler) {
200
+ return local_handler(std::move(resp.ctx),
201
+ get_replica_result{ resp.cas, true /* replica */, { std::move(resp.value), resp.flags } });
202
+ }
203
+ });
204
+ }
205
+
206
+ core::operations::get_request active{ core::document_id{ r->id() } };
207
+ active.timeout = r->timeout();
208
+ core.execute(active, [ctx](auto resp) {
209
+ core::impl::movable_get_any_replica_handler local_handler{};
210
+ {
211
+ const std::scoped_lock lock(ctx->mutex_);
212
+ if (ctx->done_) {
213
+ return;
214
+ }
215
+ --ctx->expected_responses_;
216
+ if (resp.ctx.ec()) {
217
+ if (ctx->expected_responses_ > 0) {
218
+ // just ignore the response
219
+ return;
220
+ }
221
+ // consider document irretrievable and give up
222
+ resp.ctx.override_ec(errc::key_value::document_irretrievable);
223
+ }
224
+ ctx->done_ = true;
225
+ std::swap(local_handler, ctx->handler_);
226
+ }
227
+ if (local_handler) {
228
+ return local_handler(std::move(resp.ctx),
229
+ get_replica_result{ resp.cas, false /* active */, { std::move(resp.value), resp.flags } });
230
+ }
231
+ });
232
+ });
233
+ }
234
+
235
+ void get_all_replicas(std::string document_key,
236
+ const get_all_replicas_options::built& options,
237
+ core::impl::movable_get_all_replicas_handler&& handler) const
238
+ {
239
+ auto request = std::make_shared<core::impl::get_all_replicas_request>(
240
+ bucket_name_, scope_name_, name_, std::move(document_key), options.timeout);
241
+ core_.with_bucket_configuration(
242
+ bucket_name_,
243
+ [core = core_, r = std::move(request), h = std::move(handler)](std::error_code ec,
244
+ const core::topology::configuration& config) mutable {
245
+ if (ec) {
246
+ return h(make_key_value_error_context(ec, r->id()), get_all_replicas_result{});
247
+ }
248
+ struct replica_context {
249
+ replica_context(core::impl::movable_get_all_replicas_handler handler, std::uint32_t expected_responses)
250
+ : handler_(std::move(handler))
251
+ , expected_responses_(expected_responses)
252
+ {
253
+ }
254
+
255
+ core::impl::movable_get_all_replicas_handler handler_;
256
+ std::uint32_t expected_responses_;
257
+ bool done_{ false };
258
+ std::mutex mutex_{};
259
+ get_all_replicas_result result_{};
260
+ };
261
+ auto ctx = std::make_shared<replica_context>(std::move(h), config.num_replicas.value_or(0U) + 1U);
262
+
263
+ for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
264
+ core::document_id replica_id{ r->id() };
265
+ replica_id.node_index(idx);
266
+ core.execute(core::impl::get_replica_request{ std::move(replica_id), r->timeout() }, [ctx](auto resp) {
267
+ core::impl::movable_get_all_replicas_handler local_handler{};
268
+ {
269
+ const std::scoped_lock lock(ctx->mutex_);
270
+ if (ctx->done_) {
271
+ return;
272
+ }
273
+ --ctx->expected_responses_;
274
+ if (resp.ctx.ec()) {
275
+ if (ctx->expected_responses_ > 0) {
276
+ // just ignore the response
277
+ return;
278
+ }
279
+ } else {
280
+ ctx->result_.emplace_back(
281
+ get_replica_result{ resp.cas, true /* replica */, { std::move(resp.value), resp.flags } });
282
+ }
283
+ if (ctx->expected_responses_ == 0) {
284
+ ctx->done_ = true;
285
+ std::swap(local_handler, ctx->handler_);
286
+ }
287
+ }
288
+ if (local_handler) {
289
+ if (!ctx->result_.empty()) {
290
+ resp.ctx.override_ec({});
291
+ }
292
+ return local_handler(std::move(resp.ctx), std::move(ctx->result_));
293
+ }
294
+ });
295
+ }
296
+
297
+ core::operations::get_request active{ core::document_id{ r->id() } };
298
+ active.timeout = r->timeout();
299
+ core.execute(active, [ctx](auto resp) {
300
+ core::impl::movable_get_all_replicas_handler local_handler{};
301
+ {
302
+ const std::scoped_lock lock(ctx->mutex_);
303
+ if (ctx->done_) {
304
+ return;
305
+ }
306
+ --ctx->expected_responses_;
307
+ if (resp.ctx.ec()) {
308
+ if (ctx->expected_responses_ > 0) {
309
+ // just ignore the response
310
+ return;
311
+ }
312
+ } else {
313
+ ctx->result_.emplace_back(
314
+ get_replica_result{ resp.cas, false /* active */, { std::move(resp.value), resp.flags } });
315
+ }
316
+ if (ctx->expected_responses_ == 0) {
317
+ ctx->done_ = true;
318
+ std::swap(local_handler, ctx->handler_);
319
+ }
320
+ }
321
+ if (local_handler) {
322
+ if (!ctx->result_.empty()) {
323
+ resp.ctx.override_ec({});
324
+ }
325
+ return local_handler(std::move(resp.ctx), std::move(ctx->result_));
326
+ }
327
+ });
328
+ });
329
+ }
330
+
331
+ void remove(std::string document_key, remove_options::built options, remove_handler&& handler) const
332
+ {
333
+ auto id = core::document_id{
334
+ bucket_name_,
335
+ scope_name_,
336
+ name_,
337
+ std::move(document_key),
338
+ };
339
+ if (options.persist_to == persist_to::none && options.replicate_to == replicate_to::none) {
340
+ return core_.execute(
341
+ core::operations::remove_request{
342
+ std::move(id),
343
+ {},
344
+ {},
345
+ options.cas,
346
+ options.durability_level,
347
+ options.timeout,
348
+ { options.retry_strategy },
349
+ },
350
+ [handler = std::move(handler)](auto resp) mutable {
351
+ if (resp.ctx.ec()) {
352
+ return handler(std::move(resp.ctx), mutation_result{});
353
+ }
354
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
355
+ });
356
+ }
357
+
358
+ core::operations::remove_request request{
359
+ id, {}, {}, options.cas, durability_level::none, options.timeout, { options.retry_strategy },
360
+ };
361
+ return core_.execute(
362
+ std::move(request), [core = core_, id = std::move(id), options, handler = std::move(handler)](auto&& resp) mutable {
363
+ if (resp.ctx.ec()) {
364
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
365
+ }
366
+ auto token = resp.token;
367
+ core::impl::initiate_observe_poll(core,
368
+ std::move(id),
369
+ token,
370
+ options.timeout,
371
+ options.persist_to,
372
+ options.replicate_to,
373
+ [resp, handler = std::move(handler)](std::error_code ec) mutable {
374
+ if (ec) {
375
+ resp.ctx.override_ec(ec);
376
+ return handler(std::move(resp.ctx), mutation_result{});
377
+ }
378
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
379
+ });
380
+ });
381
+ }
382
+
383
+ void get_and_lock(std::string document_key,
384
+ std::chrono::seconds lock_duration,
385
+ get_and_lock_options::built options,
386
+ get_and_lock_handler&& handler) const
387
+ {
388
+ core_.execute(
389
+ core::operations::get_and_lock_request{
390
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
391
+ {},
392
+ {},
393
+ static_cast<uint32_t>(lock_duration.count()),
394
+ options.timeout,
395
+ { options.retry_strategy },
396
+ },
397
+ [handler = std::move(handler)](auto&& resp) mutable {
398
+ return handler(std::move(resp.ctx), get_result{ resp.cas, { std::move(resp.value), resp.flags }, {} });
399
+ });
400
+ }
401
+
402
+ void unlock(std::string document_key, couchbase::cas cas, unlock_options::built options, unlock_handler&& handler) const
403
+ {
404
+ core_.execute(
405
+ core::operations::unlock_request{
406
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
407
+ {},
408
+ {},
409
+ cas,
410
+ options.timeout,
411
+ { options.retry_strategy },
412
+ },
413
+ [handler = std::move(handler)](auto&& resp) mutable { return handler(std::move(resp.ctx)); });
414
+ }
415
+
416
+ void exists(std::string document_key, exists_options::built options, exists_handler&& handler) const
417
+ {
418
+ core_.execute(
419
+ core::operations::exists_request{
420
+ core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
421
+ {},
422
+ {},
423
+ options.timeout,
424
+ { options.retry_strategy },
425
+ },
426
+ [handler = std::move(handler)](auto&& resp) mutable {
427
+ return handler(std::move(resp.ctx), exists_result{ resp.cas, resp.exists() });
428
+ });
429
+ }
430
+
431
+ void lookup_in(std::string document_key,
432
+ const std::vector<core::impl::subdoc::command>& specs,
433
+ lookup_in_options::built options,
434
+ lookup_in_handler&& handler) const
435
+ {
436
+ return core_.execute(
437
+ core::operations::lookup_in_request{
438
+ core::document_id{
439
+ bucket_name_,
440
+ scope_name_,
441
+ name_,
442
+ std::move(document_key),
443
+ },
444
+ {},
445
+ {},
446
+ options.access_deleted,
447
+ specs,
448
+ options.timeout,
449
+ { options.retry_strategy },
450
+ },
451
+ [handler = std::move(handler)](auto resp) mutable {
452
+ if (resp.ctx.ec()) {
453
+ return handler(std::move(resp.ctx), lookup_in_result{});
454
+ }
455
+
456
+ std::vector<lookup_in_result::entry> entries{};
457
+ entries.reserve(resp.fields.size());
458
+ for (auto& entry : resp.fields) {
459
+ entries.emplace_back(lookup_in_result::entry{
460
+ std::move(entry.path),
461
+ std::move(entry.value),
462
+ entry.original_index,
463
+ entry.exists,
464
+ entry.ec,
465
+ });
466
+ }
467
+ return handler(std::move(resp.ctx), lookup_in_result{ resp.cas, std::move(entries), resp.deleted });
468
+ });
469
+ }
470
+
471
+ void lookup_in_all_replicas(std::string document_key,
472
+ const std::vector<core::impl::subdoc::command>& specs,
473
+ const lookup_in_all_replicas_options::built& options,
474
+ lookup_in_all_replicas_handler&& handler) const
475
+ {
476
+ auto request = std::make_shared<couchbase::core::impl::lookup_in_all_replicas_request>(
477
+ bucket_name_, scope_name_, name_, std::move(document_key), specs, options.timeout);
478
+ core_.with_bucket_configuration(
479
+ bucket_name_,
480
+ [core = core_, r = std::move(request), h = std::move(handler)](std::error_code ec,
481
+ const core::topology::configuration& config) mutable {
482
+ if (!config.supports_subdoc_read_replica()) {
483
+ ec = errc::common::feature_not_available;
484
+ }
485
+
486
+ if (ec) {
487
+ return h(core::make_subdocument_error_context(make_key_value_error_context(ec, r->id()), ec, {}, {}, false),
488
+ lookup_in_all_replicas_result{});
489
+ }
490
+ struct replica_context {
491
+ replica_context(core::impl::movable_lookup_in_all_replicas_handler handler, std::uint32_t expected_responses)
492
+ : handler_(std::move(handler))
493
+ , expected_responses_(expected_responses)
494
+ {
495
+ }
496
+
497
+ core::impl::movable_lookup_in_all_replicas_handler handler_;
498
+ std::uint32_t expected_responses_;
499
+ bool done_{ false };
500
+ std::mutex mutex_{};
501
+ lookup_in_all_replicas_result result_{};
502
+ };
503
+ auto ctx = std::make_shared<replica_context>(std::move(h), config.num_replicas.value_or(0U) + 1U);
504
+
505
+ for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
506
+ core::document_id replica_id{ r->id() };
507
+ replica_id.node_index(idx);
508
+ core.execute(core::impl::lookup_in_replica_request{ std::move(replica_id), r->specs(), r->timeout() },
509
+ [ctx](core::impl::lookup_in_replica_response&& resp) {
510
+ core::impl::movable_lookup_in_all_replicas_handler local_handler{};
511
+ {
512
+ const std::scoped_lock lock(ctx->mutex_);
513
+ if (ctx->done_) {
514
+ return;
515
+ }
516
+ --ctx->expected_responses_;
517
+ if (resp.ctx.ec()) {
518
+ if (ctx->expected_responses_ > 0) {
519
+ // just ignore the response
520
+ return;
521
+ }
522
+ } else {
523
+ std::vector<lookup_in_replica_result::entry> entries{};
524
+ for (const auto& field : resp.fields) {
525
+ lookup_in_replica_result::entry lookup_in_entry{};
526
+ lookup_in_entry.path = field.path;
527
+ lookup_in_entry.value = field.value;
528
+ lookup_in_entry.exists = field.exists;
529
+ lookup_in_entry.original_index = field.original_index;
530
+ lookup_in_entry.ec = field.ec;
531
+ entries.emplace_back(lookup_in_entry);
532
+ }
533
+ ctx->result_.emplace_back(resp.cas, entries, resp.deleted, true /* replica */);
534
+ }
535
+ if (ctx->expected_responses_ == 0) {
536
+ ctx->done_ = true;
537
+ std::swap(local_handler, ctx->handler_);
538
+ }
539
+ }
540
+ if (local_handler) {
541
+ if (!ctx->result_.empty()) {
542
+ resp.ctx.override_ec({});
543
+ }
544
+ return local_handler(std::move(resp.ctx), std::move(ctx->result_));
545
+ }
546
+ });
547
+ }
548
+
549
+ core::operations::lookup_in_request active{ core::document_id{ r->id() } };
550
+ active.specs = r->specs();
551
+ active.timeout = r->timeout();
552
+ core.execute(active, [ctx](core::operations::lookup_in_response&& resp) {
553
+ core::impl::movable_lookup_in_all_replicas_handler local_handler{};
554
+ {
555
+ const std::scoped_lock lock(ctx->mutex_);
556
+ if (ctx->done_) {
557
+ return;
558
+ }
559
+ --ctx->expected_responses_;
560
+ if (resp.ctx.ec()) {
561
+ if (ctx->expected_responses_ > 0) {
562
+ // just ignore the response
563
+ return;
564
+ }
565
+ } else {
566
+ std::vector<lookup_in_replica_result::entry> entries{};
567
+ for (const auto& field : resp.fields) {
568
+ lookup_in_replica_result::entry lookup_in_entry{};
569
+ lookup_in_entry.path = field.path;
570
+ lookup_in_entry.value = field.value;
571
+ lookup_in_entry.exists = field.exists;
572
+ lookup_in_entry.original_index = field.original_index;
573
+ lookup_in_entry.ec = field.ec;
574
+ entries.emplace_back(lookup_in_entry);
575
+ }
576
+ ctx->result_.emplace_back(resp.cas, entries, resp.deleted, false /* active */);
577
+ }
578
+ if (ctx->expected_responses_ == 0) {
579
+ ctx->done_ = true;
580
+ std::swap(local_handler, ctx->handler_);
581
+ }
582
+ }
583
+ if (local_handler) {
584
+ if (!ctx->result_.empty()) {
585
+ resp.ctx.override_ec({});
586
+ }
587
+ return local_handler(std::move(resp.ctx), std::move(ctx->result_));
588
+ }
589
+ });
590
+ });
591
+ }
592
+
593
+ void lookup_in_any_replica(std::string document_key,
594
+ const std::vector<core::impl::subdoc::command>& specs,
595
+ const lookup_in_any_replica_options::built& options,
596
+ lookup_in_any_replica_handler&& handler) const
597
+ {
598
+ auto request = std::make_shared<couchbase::core::impl::lookup_in_any_replica_request>(
599
+ bucket_name_, scope_name_, name_, std::move(document_key), specs, options.timeout);
600
+ core_.with_bucket_configuration(
601
+ bucket_name_,
602
+ [core = core_, r = std::move(request), h = std::move(handler)](std::error_code ec,
603
+ const core::topology::configuration& config) mutable {
604
+ if (!config.supports_subdoc_read_replica()) {
605
+ ec = errc::common::feature_not_available;
606
+ }
607
+ if (r->specs().size() > 16) {
608
+ ec = errc::common::invalid_argument;
609
+ }
610
+ if (ec) {
611
+ return h(core::make_subdocument_error_context(make_key_value_error_context(ec, r->id()), ec, {}, {}, false),
612
+ lookup_in_replica_result{});
613
+ }
614
+ struct replica_context {
615
+ replica_context(core::impl::movable_lookup_in_any_replica_handler handler, std::uint32_t expected_responses)
616
+ : handler_(std::move(handler))
617
+ , expected_responses_(expected_responses)
618
+ {
619
+ }
620
+
621
+ core::impl::movable_lookup_in_any_replica_handler handler_;
622
+ std::uint32_t expected_responses_;
623
+ bool done_{ false };
624
+ std::mutex mutex_{};
625
+ };
626
+ auto ctx = std::make_shared<replica_context>(std::move(h), config.num_replicas.value_or(0U) + 1U);
627
+
628
+ for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
629
+ core::document_id replica_id{ r->id() };
630
+ replica_id.node_index(idx);
631
+ core.execute(core::impl::lookup_in_replica_request{ std::move(replica_id), r->specs(), r->timeout() },
632
+ [ctx](core::impl::lookup_in_replica_response&& resp) {
633
+ core::impl::movable_lookup_in_any_replica_handler local_handler;
634
+ {
635
+ const std::scoped_lock lock(ctx->mutex_);
636
+ if (ctx->done_) {
637
+ return;
638
+ }
639
+ --ctx->expected_responses_;
640
+ if (resp.ctx.ec()) {
641
+ if (ctx->expected_responses_ > 0) {
642
+ // just ignore the response
643
+ return;
644
+ }
645
+ // consider document irretrievable and give up
646
+ resp.ctx.override_ec(errc::key_value::document_irretrievable);
647
+ }
648
+ ctx->done_ = true;
649
+ std::swap(local_handler, ctx->handler_);
650
+ }
651
+ if (local_handler) {
652
+ std::vector<lookup_in_replica_result::entry> entries;
653
+ for (const auto& field : resp.fields) {
654
+ lookup_in_replica_result::entry entry{};
655
+ entry.path = field.path;
656
+ entry.original_index = field.original_index;
657
+ entry.exists = field.exists;
658
+ entry.value = field.value;
659
+ entry.ec = field.ec;
660
+ entries.emplace_back(entry);
661
+ }
662
+ return local_handler(
663
+ std::move(resp.ctx),
664
+ lookup_in_replica_result{ resp.cas, entries, resp.deleted, true /* replica */ });
665
+ }
666
+ });
667
+ }
668
+
669
+ core::operations::lookup_in_request active{ core::document_id{ r->id() } };
670
+ active.specs = r->specs();
671
+ active.timeout = r->timeout();
672
+ core.execute(active, [ctx](core::operations::lookup_in_response&& resp) {
673
+ core::impl::movable_lookup_in_any_replica_handler local_handler{};
674
+ {
675
+ const std::scoped_lock lock(ctx->mutex_);
676
+ if (ctx->done_) {
677
+ return;
678
+ }
679
+ --ctx->expected_responses_;
680
+ if (resp.ctx.ec()) {
681
+ if (ctx->expected_responses_ > 0) {
682
+ // just ignore the response
683
+ return;
684
+ }
685
+ // consider document irretrievable and give up
686
+ resp.ctx.override_ec(errc::key_value::document_irretrievable);
687
+ }
688
+ ctx->done_ = true;
689
+ std::swap(local_handler, ctx->handler_);
690
+ }
691
+ if (local_handler) {
692
+ std::vector<lookup_in_replica_result::entry> entries;
693
+ for (const auto& field : resp.fields) {
694
+ lookup_in_replica_result::entry entry{};
695
+ entry.path = field.path;
696
+ entry.original_index = field.original_index;
697
+ entry.exists = field.exists;
698
+ entry.value = field.value;
699
+ entry.ec = field.ec;
700
+ entries.emplace_back(entry);
701
+ }
702
+ return local_handler(std::move(resp.ctx),
703
+ lookup_in_replica_result{ resp.cas, entries, resp.deleted, false /* active */ });
704
+ }
705
+ });
706
+ });
707
+ }
708
+
709
+ void mutate_in(std::string document_key,
710
+ const std::vector<core::impl::subdoc::command>& specs,
711
+ mutate_in_options::built options,
712
+ mutate_in_handler&& handler) const
713
+ {
714
+ auto id = core::document_id{
715
+ bucket_name_,
716
+ scope_name_,
717
+ name_,
718
+ std::move(document_key),
719
+ };
720
+ if (options.persist_to == persist_to::none && options.replicate_to == replicate_to::none) {
721
+ return core_.execute(
722
+ core::operations::mutate_in_request{
723
+ std::move(id),
724
+ {},
725
+ {},
726
+ options.cas,
727
+ options.access_deleted,
728
+ options.create_as_deleted,
729
+ options.expiry,
730
+ options.store_semantics,
731
+ specs,
732
+ options.durability_level,
733
+ options.timeout,
734
+ { options.retry_strategy },
735
+ options.preserve_expiry,
736
+ },
737
+ [handler = std::move(handler)](auto resp) mutable {
738
+ if (resp.ctx.ec()) {
739
+ return handler(std::move(resp.ctx), mutate_in_result{});
740
+ }
741
+ std::vector<mutate_in_result::entry> entries{};
742
+ entries.reserve(resp.fields.size());
743
+ for (auto& entry : resp.fields) {
744
+ entries.emplace_back(mutate_in_result::entry{
745
+ std::move(entry.path),
746
+ std::move(entry.value),
747
+ entry.original_index,
748
+ });
749
+ }
750
+ return handler(std::move(resp.ctx),
751
+ mutate_in_result{ resp.cas, std::move(resp.token), std::move(entries), resp.deleted });
752
+ });
753
+ }
754
+
755
+ core::operations::mutate_in_request request{
756
+ id,
757
+ {},
758
+ {},
759
+ options.cas,
760
+ options.access_deleted,
761
+ options.create_as_deleted,
762
+ options.expiry,
763
+ options.store_semantics,
764
+ specs,
765
+ durability_level::none,
766
+ options.timeout,
767
+ { options.retry_strategy },
768
+ options.preserve_expiry,
769
+ };
770
+ return core_.execute(
771
+ std::move(request), [core = core_, id = std::move(id), options, handler = std::move(handler)](auto&& resp) mutable {
772
+ if (resp.ctx.ec()) {
773
+ return handler(std::move(resp.ctx), mutate_in_result{});
774
+ }
775
+
776
+ auto token = resp.token;
777
+ core::impl::initiate_observe_poll(
778
+ core,
779
+ std::move(id),
780
+ token,
781
+ options.timeout,
782
+ options.persist_to,
783
+ options.replicate_to,
784
+ [resp, handler = std::move(handler)](std::error_code ec) mutable {
785
+ if (ec) {
786
+ resp.ctx.override_ec(ec);
787
+ return handler(std::move(resp.ctx), mutate_in_result{});
788
+ }
789
+ std::vector<mutate_in_result::entry> entries{};
790
+ entries.reserve(resp.fields.size());
791
+ for (auto& entry : resp.fields) {
792
+ entries.emplace_back(mutate_in_result::entry{
793
+ std::move(entry.path),
794
+ std::move(entry.value),
795
+ entry.original_index,
796
+ });
797
+ }
798
+ return handler(std::move(resp.ctx),
799
+ mutate_in_result{ resp.cas, std::move(resp.token), std::move(entries), resp.deleted });
800
+ });
801
+ });
802
+ }
803
+
804
+ void upsert(std::string document_key, codec::encoded_value encoded, upsert_options::built options, upsert_handler&& handler) const
805
+ {
806
+ auto value = std::move(encoded);
807
+ auto id = core::document_id{
808
+ bucket_name_,
809
+ scope_name_,
810
+ name_,
811
+ std::move(document_key),
812
+ };
813
+ if (options.persist_to == persist_to::none && options.replicate_to == replicate_to::none) {
814
+ return core_.execute(
815
+ core::operations::upsert_request{
816
+ std::move(id),
817
+ std::move(value.data),
818
+ {},
819
+ {},
820
+ value.flags,
821
+ options.expiry,
822
+ options.durability_level,
823
+ options.timeout,
824
+ { options.retry_strategy },
825
+ options.preserve_expiry,
826
+ },
827
+ [handler = std::move(handler)](auto resp) mutable {
828
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
829
+ });
830
+ }
831
+
832
+ core::operations::upsert_request request{
833
+ id,
834
+ std::move(value.data),
835
+ {},
836
+ {},
837
+ value.flags,
838
+ options.expiry,
839
+ durability_level::none,
840
+ options.timeout,
841
+ { options.retry_strategy },
842
+ options.preserve_expiry,
843
+ };
844
+ return core_.execute(
845
+ std::move(request), [core = core_, id = std::move(id), options, handler = std::move(handler)](auto resp) mutable {
846
+ if (resp.ctx.ec()) {
847
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
848
+ }
849
+
850
+ auto token = resp.token;
851
+ core::impl::initiate_observe_poll(core,
852
+ std::move(id),
853
+ token,
854
+ options.timeout,
855
+ options.persist_to,
856
+ options.replicate_to,
857
+ [resp, handler = std::move(handler)](std::error_code ec) mutable {
858
+ if (ec) {
859
+ resp.ctx.override_ec(ec);
860
+ return handler(std::move(resp.ctx), mutation_result{});
861
+ }
862
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
863
+ });
864
+ });
865
+ }
866
+
867
+ void insert(std::string document_key, codec::encoded_value encoded, insert_options::built options, insert_handler&& handler) const
868
+ {
869
+ auto value = std::move(encoded);
870
+ auto id = core::document_id{
871
+ bucket_name_,
872
+ scope_name_,
873
+ name_,
874
+ std::move(document_key),
875
+ };
876
+ if (options.persist_to == persist_to::none && options.replicate_to == replicate_to::none) {
877
+ return core_.execute(
878
+ core::operations::insert_request{
879
+ std::move(id),
880
+ std::move(value.data),
881
+ {},
882
+ {},
883
+ value.flags,
884
+ options.expiry,
885
+ options.durability_level,
886
+ options.timeout,
887
+ { options.retry_strategy },
888
+ },
889
+ [handler = std::move(handler)](auto&& resp) mutable {
890
+ if (resp.ctx.ec()) {
891
+ return handler(std::move(resp.ctx), mutation_result{});
892
+ }
893
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
894
+ });
895
+ }
896
+
897
+ core::operations::insert_request request{
898
+ id,
899
+ std::move(value.data),
900
+ {},
901
+ {},
902
+ value.flags,
903
+ options.expiry,
904
+ durability_level::none,
905
+ options.timeout,
906
+ { options.retry_strategy },
907
+ };
908
+ return core_.execute(
909
+ std::move(request), [core = core_, id = std::move(id), options, handler = std::move(handler)](auto resp) mutable {
910
+ if (resp.ctx.ec()) {
911
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
912
+ }
913
+
914
+ auto token = resp.token;
915
+ core::impl::initiate_observe_poll(core,
916
+ std::move(id),
917
+ token,
918
+ options.timeout,
919
+ options.persist_to,
920
+ options.replicate_to,
921
+ [resp, handler = std::move(handler)](std::error_code ec) mutable {
922
+ if (ec) {
923
+ resp.ctx.override_ec(ec);
924
+ return handler(std::move(resp.ctx), mutation_result{});
925
+ }
926
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
927
+ });
928
+ });
929
+ }
930
+ void replace(std::string document_key, codec::encoded_value encoded, replace_options::built options, replace_handler&& handler) const
931
+ {
932
+ auto value = std::move(encoded);
933
+ auto id = core::document_id{
934
+ bucket_name_,
935
+ scope_name_,
936
+ name_,
937
+ std::move(document_key),
938
+ };
939
+ if (options.persist_to == persist_to::none && options.replicate_to == replicate_to::none) {
940
+ return core_.execute(
941
+ core::operations::replace_request{
942
+ std::move(id),
943
+ std::move(value.data),
944
+ {},
945
+ {},
946
+ value.flags,
947
+ options.expiry,
948
+ options.cas,
949
+ options.durability_level,
950
+ options.timeout,
951
+ { options.retry_strategy },
952
+ options.preserve_expiry,
953
+ },
954
+ [handler = std::move(handler)](auto resp) mutable {
955
+ if (resp.ctx.ec()) {
956
+ return handler(std::move(resp.ctx), mutation_result{});
957
+ }
958
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
959
+ });
960
+ }
961
+
962
+ core::operations::replace_request request{
963
+ id,
964
+ std::move(value.data),
965
+ {},
966
+ {},
967
+ value.flags,
968
+ options.expiry,
969
+ options.cas,
970
+ durability_level::none,
971
+ options.timeout,
972
+ { options.retry_strategy },
973
+ options.preserve_expiry,
974
+ };
975
+ return core_.execute(
976
+ std::move(request), [core = core_, id = std::move(id), options, handler = std::move(handler)](auto&& resp) mutable {
977
+ if (resp.ctx.ec()) {
978
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
979
+ }
980
+
981
+ auto token = resp.token;
982
+ core::impl::initiate_observe_poll(core,
983
+ std::move(id),
984
+ token,
985
+ options.timeout,
986
+ options.persist_to,
987
+ options.replicate_to,
988
+ [resp, handler = std::move(handler)](std::error_code ec) mutable {
989
+ if (ec) {
990
+ resp.ctx.override_ec(ec);
991
+ return handler(std::move(resp.ctx), mutation_result{});
992
+ }
993
+ return handler(std::move(resp.ctx), mutation_result{ resp.cas, std::move(resp.token) });
994
+ });
995
+ });
996
+ }
997
+
998
+ private:
999
+ core::cluster core_;
1000
+ std::string bucket_name_;
1001
+ std::string scope_name_;
1002
+ std::string name_;
1003
+ };
1004
+
1005
+ collection::collection(core::cluster core, std::string_view bucket_name, std::string_view scope_name, std::string_view name)
1006
+ : impl_(std::make_shared<collection_impl>(std::move(core), bucket_name, scope_name, name))
1007
+ {
1008
+ }
1009
+
1010
+ auto
1011
+ collection::bucket_name() const -> const std::string&
1012
+ {
1013
+ return impl_->bucket_name();
1014
+ }
1015
+
1016
+ auto
1017
+ collection::scope_name() const -> const std::string&
1018
+ {
1019
+ return impl_->scope_name();
1020
+ }
1021
+
1022
+ auto
1023
+ collection::name() const -> const std::string&
1024
+ {
1025
+ return impl_->name();
1026
+ }
1027
+
1028
+ auto
1029
+ collection::query_indexes() const -> collection_query_index_manager
1030
+ {
1031
+ return { impl_->core(), impl_->bucket_name(), impl_->scope_name(), impl_->name() };
1032
+ }
1033
+
1034
+ auto
1035
+ collection::binary() const -> binary_collection
1036
+ {
1037
+ return { impl_->core(), impl_->bucket_name(), impl_->scope_name(), impl_->name() };
1038
+ }
1039
+
1040
+ void
1041
+ collection::get(std::string document_id, const get_options& options, get_handler&& handler) const
1042
+ {
1043
+ return impl_->get(std::move(document_id), options.build(), std::move(handler));
1044
+ }
1045
+
1046
+ auto
1047
+ collection::get(std::string document_id, const get_options& options) const -> std::future<std::pair<key_value_error_context, get_result>>
1048
+ {
1049
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, get_result>>>();
1050
+ auto future = barrier->get_future();
1051
+ get(std::move(document_id), options, [barrier](auto ctx, auto result) { barrier->set_value({ std::move(ctx), std::move(result) }); });
1052
+ return future;
1053
+ }
1054
+
1055
+ void
1056
+ collection::get_and_touch(std::string document_id,
1057
+ std::chrono::seconds duration,
1058
+ const get_and_touch_options& options,
1059
+ get_and_touch_handler&& handler) const
1060
+ {
1061
+ return impl_->get_and_touch(std::move(document_id), core::impl::expiry_relative(duration), options.build(), std::move(handler));
1062
+ }
1063
+
1064
+ auto
1065
+ collection::get_and_touch(std::string document_id, std::chrono::seconds duration, const get_and_touch_options& options) const
1066
+ -> std::future<std::pair<key_value_error_context, get_result>>
1067
+ {
1068
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, get_result>>>();
1069
+ auto future = barrier->get_future();
1070
+ get_and_touch(std::move(document_id), duration, options, [barrier](auto ctx, auto result) {
1071
+ barrier->set_value({ std::move(ctx), std::move(result) });
1072
+ });
1073
+ return future;
1074
+ }
1075
+
1076
+ void
1077
+ collection::get_and_touch(std::string document_id,
1078
+ std::chrono::system_clock::time_point time_point,
1079
+ const get_and_touch_options& options,
1080
+ get_and_touch_handler&& handler) const
1081
+ {
1082
+ return impl_->get_and_touch(std::move(document_id), core::impl::expiry_absolute(time_point), options.build(), std::move(handler));
1083
+ }
1084
+
1085
+ auto
1086
+ collection::get_and_touch(std::string document_id,
1087
+ std::chrono::system_clock::time_point time_point,
1088
+ const get_and_touch_options& options) const -> std::future<std::pair<key_value_error_context, get_result>>
1089
+ {
1090
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, get_result>>>();
1091
+ auto future = barrier->get_future();
1092
+ get_and_touch(std::move(document_id), time_point, options, [barrier](auto ctx, auto result) {
1093
+ barrier->set_value({ std::move(ctx), std::move(result) });
1094
+ });
1095
+ return future;
1096
+ }
1097
+
1098
+ void
1099
+ collection::touch(std::string document_id, std::chrono::seconds duration, const touch_options& options, touch_handler&& handler) const
1100
+ {
1101
+ return impl_->touch(std::move(document_id), core::impl::expiry_relative(duration), options.build(), std::move(handler));
1102
+ }
1103
+
1104
+ auto
1105
+ collection::touch(std::string document_id, std::chrono::seconds duration, const touch_options& options) const
1106
+ -> std::future<std::pair<key_value_error_context, result>>
1107
+ {
1108
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, result>>>();
1109
+ auto future = barrier->get_future();
1110
+ touch(std::move(document_id), duration, options, [barrier](auto ctx, auto result) {
1111
+ barrier->set_value({ std::move(ctx), std::move(result) });
1112
+ });
1113
+ return future;
1114
+ }
1115
+
1116
+ void
1117
+ collection::touch(std::string document_id,
1118
+ std::chrono::system_clock::time_point time_point,
1119
+ const touch_options& options,
1120
+ touch_handler&& handler) const
1121
+ {
1122
+ return impl_->touch(std::move(document_id), core::impl::expiry_absolute(time_point), options.build(), std::move(handler));
1123
+ }
1124
+
1125
+ auto
1126
+ collection::touch(std::string document_id, std::chrono::system_clock::time_point time_point, const touch_options& options) const
1127
+ -> std::future<std::pair<key_value_error_context, result>>
1128
+ {
1129
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, result>>>();
1130
+ auto future = barrier->get_future();
1131
+ touch(std::move(document_id), time_point, options, [barrier](auto ctx, auto result) {
1132
+ barrier->set_value({ std::move(ctx), std::move(result) });
1133
+ });
1134
+ return future;
1135
+ }
1136
+
1137
+ void
1138
+ collection::get_any_replica(std::string document_id, const get_any_replica_options& options, get_any_replica_handler&& handler) const
1139
+ {
1140
+ return impl_->get_any_replica(std::move(document_id), options.build(), std::move(handler));
1141
+ }
1142
+
1143
+ auto
1144
+ collection::get_any_replica(std::string document_id, const get_any_replica_options& options) const
1145
+ -> std::future<std::pair<key_value_error_context, get_replica_result>>
1146
+ {
1147
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, get_replica_result>>>();
1148
+ auto future = barrier->get_future();
1149
+ get_any_replica(std::move(document_id), options, [barrier](auto ctx, auto result) {
1150
+ barrier->set_value({ std::move(ctx), std::move(result) });
1151
+ });
1152
+ return future;
1153
+ }
1154
+
1155
+ void
1156
+ collection::get_all_replicas(std::string document_id, const get_all_replicas_options& options, get_all_replicas_handler&& handler) const
1157
+ {
1158
+ return impl_->get_all_replicas(std::move(document_id), options.build(), std::move(handler));
1159
+ }
1160
+
1161
+ auto
1162
+ collection::get_all_replicas(std::string document_id, const get_all_replicas_options& options) const
1163
+ -> std::future<std::pair<key_value_error_context, get_all_replicas_result>>
1164
+ {
1165
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, get_all_replicas_result>>>();
1166
+ auto future = barrier->get_future();
1167
+ get_all_replicas(std::move(document_id), options, [barrier](auto ctx, auto result) {
1168
+ barrier->set_value({ std::move(ctx), std::move(result) });
1169
+ });
1170
+ return future;
1171
+ }
1172
+
1173
+ void
1174
+ collection::remove(std::string document_id, const remove_options& options, remove_handler&& handler) const
1175
+ {
1176
+ return impl_->remove(std::move(document_id), options.build(), std::move(handler));
1177
+ }
1178
+
1179
+ auto
1180
+ collection::remove(std::string document_id, const remove_options& options) const
1181
+ -> std::future<std::pair<key_value_error_context, mutation_result>>
1182
+ {
1183
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, mutation_result>>>();
1184
+ auto future = barrier->get_future();
1185
+ remove(std::move(document_id), options, [barrier](auto ctx, auto result) {
1186
+ barrier->set_value({ std::move(ctx), std::move(result) });
1187
+ });
1188
+ return future;
1189
+ }
1190
+
1191
+ void
1192
+ collection::mutate_in(std::string document_id,
1193
+ const mutate_in_specs& specs,
1194
+ const mutate_in_options& options,
1195
+ mutate_in_handler&& handler) const
1196
+ {
1197
+ return impl_->mutate_in(std::move(document_id), specs.specs(), options.build(), std::move(handler));
1198
+ }
1199
+
1200
+ auto
1201
+ collection::mutate_in(std::string document_id, const mutate_in_specs& specs, const mutate_in_options& options) const
1202
+ -> std::future<std::pair<subdocument_error_context, mutate_in_result>>
1203
+ {
1204
+ auto barrier = std::make_shared<std::promise<std::pair<subdocument_error_context, mutate_in_result>>>();
1205
+ auto future = barrier->get_future();
1206
+ mutate_in(std::move(document_id), specs, options, [barrier](auto ctx, auto result) {
1207
+ barrier->set_value({ std::move(ctx), std::move(result) });
1208
+ });
1209
+ return future;
1210
+ }
1211
+
1212
+ void
1213
+ collection::lookup_in(std::string document_id,
1214
+ const lookup_in_specs& specs,
1215
+ const lookup_in_options& options,
1216
+ lookup_in_handler&& handler) const
1217
+ {
1218
+ return impl_->lookup_in(std::move(document_id), specs.specs(), options.build(), std::move(handler));
1219
+ }
1220
+
1221
+ auto
1222
+ collection::lookup_in(std::string document_id, const lookup_in_specs& specs, const lookup_in_options& options) const
1223
+ -> std::future<std::pair<subdocument_error_context, lookup_in_result>>
1224
+ {
1225
+ auto barrier = std::make_shared<std::promise<std::pair<subdocument_error_context, lookup_in_result>>>();
1226
+ auto future = barrier->get_future();
1227
+ lookup_in(std::move(document_id), specs, options, [barrier](auto ctx, auto result) {
1228
+ barrier->set_value({ std::move(ctx), std::move(result) });
1229
+ });
1230
+ return future;
1231
+ }
1232
+
1233
+ void
1234
+ collection::lookup_in_all_replicas(std::string document_id,
1235
+ const lookup_in_specs& specs,
1236
+ const lookup_in_all_replicas_options& options,
1237
+ lookup_in_all_replicas_handler&& handler) const
1238
+ {
1239
+ return impl_->lookup_in_all_replicas(std::move(document_id), specs.specs(), options.build(), std::move(handler));
1240
+ }
1241
+
1242
+ auto
1243
+ collection::lookup_in_all_replicas(std::string document_id,
1244
+ const lookup_in_specs& specs,
1245
+ const lookup_in_all_replicas_options& options) const
1246
+ -> std::future<std::pair<subdocument_error_context, lookup_in_all_replicas_result>>
1247
+ {
1248
+ auto barrier = std::make_shared<std::promise<std::pair<subdocument_error_context, lookup_in_all_replicas_result>>>();
1249
+ auto future = barrier->get_future();
1250
+ lookup_in_all_replicas(std::move(document_id), specs, options, [barrier](auto ctx, auto result) {
1251
+ barrier->set_value({ std::move(ctx), std::move(result) });
1252
+ });
1253
+ return future;
1254
+ }
1255
+
1256
+ void
1257
+ collection::lookup_in_any_replica(std::string document_id,
1258
+ const lookup_in_specs& specs,
1259
+ const lookup_in_any_replica_options& options,
1260
+ lookup_in_any_replica_handler&& handler) const
1261
+ {
1262
+ return impl_->lookup_in_any_replica(std::move(document_id), specs.specs(), options.build(), std::move(handler));
1263
+ }
1264
+
1265
+ auto
1266
+ collection::lookup_in_any_replica(std::string document_id, const lookup_in_specs& specs, const lookup_in_any_replica_options& options) const
1267
+ -> std::future<std::pair<subdocument_error_context, lookup_in_replica_result>>
1268
+ {
1269
+ auto barrier = std::make_shared<std::promise<std::pair<subdocument_error_context, lookup_in_replica_result>>>();
1270
+ auto future = barrier->get_future();
1271
+ lookup_in_any_replica(std::move(document_id), specs, options, [barrier](auto ctx, auto result) {
1272
+ barrier->set_value({ std::move(ctx), std::move(result) });
1273
+ });
1274
+ return future;
1275
+ }
1276
+
1277
+ void
1278
+ collection::get_and_lock(std::string document_id,
1279
+ std::chrono::seconds lock_duration,
1280
+ const get_and_lock_options& options,
1281
+ get_and_lock_handler&& handler) const
1282
+ {
1283
+ return impl_->get_and_lock(std::move(document_id), lock_duration, options.build(), std::move(handler));
1284
+ }
1285
+
1286
+ auto
1287
+ collection::get_and_lock(std::string document_id, std::chrono::seconds lock_duration, const get_and_lock_options& options) const
1288
+ -> std::future<std::pair<key_value_error_context, get_result>>
1289
+ {
1290
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, get_result>>>();
1291
+ auto future = barrier->get_future();
1292
+ get_and_lock(std::move(document_id), lock_duration, options, [barrier](auto ctx, auto result) {
1293
+ barrier->set_value({ std::move(ctx), std::move(result) });
1294
+ });
1295
+ return future;
1296
+ }
1297
+
1298
+ void
1299
+ collection::unlock(std::string document_id, couchbase::cas cas, const unlock_options& options, unlock_handler&& handler) const
1300
+ {
1301
+ return impl_->unlock(std::move(document_id), cas, options.build(), std::move(handler));
1302
+ }
1303
+
1304
+ auto
1305
+ collection::unlock(std::string document_id, couchbase::cas cas, const unlock_options& options) const -> std::future<key_value_error_context>
1306
+ {
1307
+ auto barrier = std::make_shared<std::promise<key_value_error_context>>();
1308
+ auto future = barrier->get_future();
1309
+ unlock(std::move(document_id), cas, options, [barrier](auto ctx) { barrier->set_value({ std::move(ctx) }); });
1310
+ return future;
1311
+ }
1312
+
1313
+ void
1314
+ collection::exists(std::string document_id, const exists_options& options, exists_handler&& handler) const
1315
+ {
1316
+ return impl_->exists(std::move(document_id), options.build(), std::move(handler));
1317
+ }
1318
+
1319
+ auto
1320
+ collection::exists(std::string document_id, const exists_options& options) const
1321
+ -> std::future<std::pair<key_value_error_context, exists_result>>
1322
+ {
1323
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, exists_result>>>();
1324
+ auto future = barrier->get_future();
1325
+ exists(std::move(document_id), options, [barrier](auto ctx, auto result) {
1326
+ barrier->set_value({ std::move(ctx), std::move(result) });
1327
+ });
1328
+ return future;
1329
+ }
1330
+
1331
+ void
1332
+ collection::upsert(std::string document_id, codec::encoded_value document, const upsert_options& options, upsert_handler&& handler) const
1333
+ {
1334
+ return impl_->upsert(std::move(document_id), std::move(document), options.build(), std::move(handler));
1335
+ }
1336
+
1337
+ auto
1338
+ collection::upsert(std::string document_id, codec::encoded_value document, const upsert_options& options) const
1339
+ -> std::future<std::pair<key_value_error_context, mutation_result>>
1340
+ {
1341
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, mutation_result>>>();
1342
+ auto future = barrier->get_future();
1343
+ upsert(std::move(document_id), std::move(document), options, [barrier](auto ctx, auto result) {
1344
+ barrier->set_value({ std::move(ctx), std::move(result) });
1345
+ });
1346
+ return future;
1347
+ }
1348
+
1349
+ void
1350
+ collection::insert(std::string document_id, codec::encoded_value document, const insert_options& options, insert_handler&& handler) const
1351
+ {
1352
+ return impl_->insert(std::move(document_id), std::move(document), options.build(), std::move(handler));
1353
+ }
1354
+
1355
+ auto
1356
+ collection::insert(std::string document_id, codec::encoded_value document, const insert_options& options) const
1357
+ -> std::future<std::pair<key_value_error_context, mutation_result>>
1358
+ {
1359
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, mutation_result>>>();
1360
+ auto future = barrier->get_future();
1361
+ insert(std::move(document_id), std::move(document), options, [barrier](auto ctx, auto result) {
1362
+ barrier->set_value({ std::move(ctx), std::move(result) });
1363
+ });
1364
+ return future;
1365
+ }
1366
+
1367
+ void
1368
+ collection::replace(std::string document_id, codec::encoded_value document, const replace_options& options, replace_handler&& handler) const
1369
+ {
1370
+ return impl_->replace(std::move(document_id), std::move(document), options.build(), std::move(handler));
1371
+ }
1372
+
1373
+ auto
1374
+ collection::replace(std::string document_id, codec::encoded_value document, const replace_options& options) const
1375
+ -> std::future<std::pair<key_value_error_context, mutation_result>>
1376
+ {
1377
+ auto barrier = std::make_shared<std::promise<std::pair<key_value_error_context, mutation_result>>>();
1378
+ auto future = barrier->get_future();
1379
+ replace(std::move(document_id), std::move(document), options, [barrier](auto ctx, auto result) {
1380
+ barrier->set_value({ std::move(ctx), std::move(result) });
1381
+ });
1382
+ return future;
1383
+ }
1384
+ } // namespace couchbase