couchbase 3.8.1 → 3.9.0

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 (475) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/CMakeLists.txt +16 -1
  4. data/ext/cache/cpm/{CPM_0.42.0.cmake → CPM_0.43.1.cmake} +18 -2
  5. data/ext/cache/extconf_include.rb +6 -6
  6. data/ext/cache/mozilla-ca-bundle.crt +214 -155
  7. data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
  8. data/ext/couchbase/CMakeLists.txt +130 -21
  9. data/ext/couchbase/cmake/APKBUILD.in +25 -4
  10. data/ext/couchbase/cmake/Bundler.cmake +143 -34
  11. data/ext/couchbase/cmake/CPM.cmake +126 -12
  12. data/ext/couchbase/cmake/Cache.cmake +7 -1
  13. data/ext/couchbase/cmake/CompilerOptions.cmake +1 -1
  14. data/ext/couchbase/cmake/CompilerWarnings.cmake +17 -6
  15. data/ext/couchbase/cmake/GrpcProtobuf.cmake +481 -0
  16. data/ext/couchbase/cmake/OpenSSL.cmake +10 -3
  17. data/ext/couchbase/cmake/Packaging.cmake +519 -65
  18. data/ext/couchbase/cmake/Protostellar.cmake +250 -0
  19. data/ext/couchbase/cmake/Sanitizers.cmake +61 -50
  20. data/ext/couchbase/cmake/StaticAnalyzers.cmake +16 -5
  21. data/ext/couchbase/cmake/TestFramework.cmake +283 -0
  22. data/ext/couchbase/cmake/TestFrameworkAddTests.cmake +51 -0
  23. data/ext/couchbase/cmake/Testing.cmake +27 -9
  24. data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +141 -8
  25. data/ext/couchbase/cmake/VersionInfo.cmake +50 -0
  26. data/ext/couchbase/cmake/build_config.hxx.in +2 -1
  27. data/ext/couchbase/cmake/couchbase-cxx-client.spec.in +101 -23
  28. data/ext/couchbase/cmake/couchbase_cxx_client_static-config.cmake.in +7 -0
  29. data/ext/couchbase/cmake/couchbase_cxx_client_static.pc.in +2 -0
  30. data/ext/couchbase/cmake/gRPC_Generate.cmake +58 -0
  31. data/ext/couchbase/cmake/protobuf_Generate.cmake +69 -0
  32. data/ext/couchbase/cmake/require-git-checkout.cmake +25 -0
  33. data/ext/couchbase/cmake/tarball_glob.txt +49 -0
  34. data/ext/couchbase/core/agent_group.cxx +0 -8
  35. data/ext/couchbase/core/agent_group.hxx +0 -4
  36. data/ext/couchbase/core/analytics_stream.cxx +314 -0
  37. data/ext/couchbase/core/analytics_stream.hxx +129 -0
  38. data/ext/couchbase/core/analytics_stream_component.cxx +245 -0
  39. data/ext/couchbase/core/analytics_stream_component.hxx +67 -0
  40. data/ext/couchbase/core/app_telemetry_meter.cxx +25 -3
  41. data/ext/couchbase/core/app_telemetry_meter.hxx +77 -0
  42. data/ext/couchbase/core/app_telemetry_reporter.cxx +7 -6
  43. data/ext/couchbase/core/bucket.cxx +381 -87
  44. data/ext/couchbase/core/bucket.hxx +105 -25
  45. data/ext/couchbase/core/bucket_unit_test_api.hxx +57 -0
  46. data/ext/couchbase/core/capella.hxx +91 -0
  47. data/ext/couchbase/core/cluster.cxx +1554 -398
  48. data/ext/couchbase/core/cluster.hxx +39 -8
  49. data/ext/couchbase/core/cluster_agent.cxx +0 -8
  50. data/ext/couchbase/core/cluster_agent.hxx +0 -4
  51. data/ext/couchbase/core/cluster_options.hxx +26 -3
  52. data/ext/couchbase/core/collections_component.cxx +39 -15
  53. data/ext/couchbase/core/config_profiles.cxx +1 -1
  54. data/ext/couchbase/core/crud_component.cxx +2 -2
  55. data/ext/couchbase/core/crud_options.hxx +34 -0
  56. data/ext/couchbase/core/crypto/cbcrypto.cc +18 -13
  57. data/ext/couchbase/core/document_id_redaction.hxx +81 -0
  58. data/ext/couchbase/core/error_context/base_error_context.hxx +7 -6
  59. data/ext/couchbase/core/error_context/key_value.cxx +25 -2
  60. data/ext/couchbase/core/error_context/key_value.hxx +60 -33
  61. data/ext/couchbase/core/error_context/key_value_error_context.hxx +16 -15
  62. data/ext/couchbase/core/error_context/search.hxx +5 -0
  63. data/ext/couchbase/core/error_context/search_json.hxx +3 -0
  64. data/ext/couchbase/core/error_context/subdocument_error_context.hxx +19 -18
  65. data/ext/couchbase/core/error_context/view.hxx +5 -0
  66. data/ext/couchbase/core/free_form_http_request.cxx +237 -4
  67. data/ext/couchbase/core/free_form_http_request.hxx +41 -8
  68. data/ext/couchbase/core/http_component.cxx +300 -284
  69. data/ext/couchbase/core/http_component.hxx +0 -4
  70. data/ext/couchbase/core/impl/analytics.cxx +38 -5
  71. data/ext/couchbase/core/impl/analytics.hxx +34 -0
  72. data/ext/couchbase/core/impl/bootstrap_error.hxx +0 -3
  73. data/ext/couchbase/core/impl/collection.cxx +215 -202
  74. data/ext/couchbase/core/impl/collection_manager.cxx +1 -1
  75. data/ext/couchbase/core/impl/dns_srv_tracker.cxx +45 -18
  76. data/ext/couchbase/core/impl/error.cxx +22 -2
  77. data/ext/couchbase/core/impl/internal_analytics_stream_result.hxx +111 -0
  78. data/ext/couchbase/core/impl/internal_query_stream_result.hxx +110 -0
  79. data/ext/couchbase/core/impl/invoke_with_node_id.hxx +15 -7
  80. data/ext/couchbase/core/impl/key_value_error_category.cxx +6 -0
  81. data/ext/couchbase/core/impl/lookup_in_replica.cxx +10 -10
  82. data/ext/couchbase/core/impl/lookup_in_replica.hxx +4 -4
  83. data/ext/couchbase/core/impl/node_id.cxx +49 -13
  84. data/ext/couchbase/core/impl/observability_recorder.cxx +12 -2
  85. data/ext/couchbase/core/impl/observe_poll.cxx +63 -23
  86. data/ext/couchbase/core/impl/public_analytics_stream_result.cxx +372 -0
  87. data/ext/couchbase/core/impl/public_bucket.cxx +48 -2
  88. data/ext/couchbase/core/impl/public_cluster.cxx +325 -25
  89. data/ext/couchbase/core/impl/public_query_stream_result.cxx +380 -0
  90. data/ext/couchbase/core/impl/public_transaction_get_multi_replicas_from_preferred_server_group_result.cxx +42 -0
  91. data/ext/couchbase/core/impl/public_transaction_get_multi_result.cxx +42 -0
  92. data/ext/couchbase/core/impl/query.cxx +76 -7
  93. data/ext/couchbase/core/impl/query.hxx +36 -0
  94. data/ext/couchbase/core/impl/query_index_manager.cxx +54 -1
  95. data/ext/couchbase/core/impl/replica_utils.cxx +101 -0
  96. data/ext/couchbase/core/impl/replica_utils.hxx +64 -0
  97. data/ext/couchbase/core/impl/resolve_node_id.hxx +125 -0
  98. data/ext/couchbase/core/impl/scope.cxx +70 -0
  99. data/ext/couchbase/core/impl/search.cxx +31 -1
  100. data/ext/couchbase/core/impl/transactions.cxx +130 -0
  101. data/ext/couchbase/core/impl/wait_until_ready.cxx +439 -0
  102. data/ext/couchbase/core/impl/wait_until_ready.hxx +110 -0
  103. data/ext/couchbase/core/impl/with_bucket_config_or_timeout.hxx +180 -0
  104. data/ext/couchbase/core/impl/with_cancellation.hxx +11 -3
  105. data/ext/couchbase/core/io/configuration_belongs_to_session.hxx +66 -0
  106. data/ext/couchbase/core/io/dns_client.cxx +122 -45
  107. data/ext/couchbase/core/io/dns_codec.hxx +21 -21
  108. data/ext/couchbase/core/io/dns_config.cxx +21 -6
  109. data/ext/couchbase/core/io/http_command.hxx +149 -121
  110. data/ext/couchbase/core/io/http_error.hxx +107 -0
  111. data/ext/couchbase/core/io/http_parser.cxx +4 -0
  112. data/ext/couchbase/core/io/http_session.cxx +606 -154
  113. data/ext/couchbase/core/io/http_session.hxx +147 -30
  114. data/ext/couchbase/core/io/http_session_manager.hxx +329 -382
  115. data/ext/couchbase/core/io/http_streaming_parser.cxx +4 -0
  116. data/ext/couchbase/core/io/http_streaming_response.cxx +328 -43
  117. data/ext/couchbase/core/io/http_streaming_response.hxx +37 -3
  118. data/ext/couchbase/core/io/mcbp_buffer_pool.hxx +122 -0
  119. data/ext/couchbase/core/io/mcbp_command.hxx +150 -51
  120. data/ext/couchbase/core/io/mcbp_command_id.hxx +45 -0
  121. data/ext/couchbase/core/io/mcbp_message.cxx +9 -1
  122. data/ext/couchbase/core/io/mcbp_message.hxx +19 -0
  123. data/ext/couchbase/core/io/mcbp_output_queue.hxx +150 -0
  124. data/ext/couchbase/core/io/mcbp_parser.cxx +24 -7
  125. data/ext/couchbase/core/io/mcbp_session.cxx +316 -317
  126. data/ext/couchbase/core/io/mcbp_session.hxx +27 -18
  127. data/ext/couchbase/core/io/opaque_ring_table.hxx +145 -0
  128. data/ext/couchbase/core/io/retry_orchestrator.hxx +6 -5
  129. data/ext/couchbase/core/io/stream_deadline.hxx +50 -0
  130. data/ext/couchbase/core/io/streams.cxx +275 -14
  131. data/ext/couchbase/core/io/streams.hxx +53 -0
  132. data/ext/couchbase/core/logger/logger.cxx +36 -0
  133. data/ext/couchbase/core/logger/logger.hxx +46 -6
  134. data/ext/couchbase/core/logger/redaction.hxx +503 -0
  135. data/ext/couchbase/core/management/eventing_status.hxx +10 -0
  136. data/ext/couchbase/core/management/eventing_status_json.hxx +4 -0
  137. data/ext/couchbase/core/mcbp/big_endian.cxx +1 -1
  138. data/ext/couchbase/core/mcbp/codec.cxx +27 -18
  139. data/ext/couchbase/core/mcbp/operation_queue.cxx +2 -2
  140. data/ext/couchbase/core/mcbp/packet.hxx +2 -2
  141. data/ext/couchbase/core/mcbp/queue_request.cxx +23 -6
  142. data/ext/couchbase/core/mcbp/queue_request.hxx +21 -0
  143. data/ext/couchbase/core/meta/features.hxx +13 -0
  144. data/ext/couchbase/core/meta/version.cxx +6 -3
  145. data/ext/couchbase/core/metrics/logging_meter.cxx +5 -10
  146. data/ext/couchbase/core/metrics/meter_wrapper.cxx +63 -33
  147. data/ext/couchbase/core/metrics/meter_wrapper.hxx +55 -3
  148. data/ext/couchbase/core/operations/analytics_response_parsing.cxx +177 -0
  149. data/ext/couchbase/core/operations/analytics_response_parsing.hxx +55 -0
  150. data/ext/couchbase/core/operations/document_analytics.cxx +48 -130
  151. data/ext/couchbase/core/operations/document_analytics.hxx +14 -2
  152. data/ext/couchbase/core/operations/document_get_all_replicas.hxx +15 -7
  153. data/ext/couchbase/core/operations/document_get_any_replica.hxx +19 -8
  154. data/ext/couchbase/core/operations/document_get_projected.cxx +1 -1
  155. data/ext/couchbase/core/{impl/get_replica.cxx → operations/document_get_replica.cxx} +21 -3
  156. data/ext/couchbase/core/{impl/get_replica.hxx → operations/document_get_replica.hxx} +31 -4
  157. data/ext/couchbase/core/operations/document_lookup_in.cxx +10 -10
  158. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +228 -198
  159. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +215 -217
  160. data/ext/couchbase/core/operations/document_query.cxx +108 -221
  161. data/ext/couchbase/core/operations/document_query.hxx +18 -4
  162. data/ext/couchbase/core/operations/document_search.cxx +52 -8
  163. data/ext/couchbase/core/operations/document_search.hxx +3 -0
  164. data/ext/couchbase/core/operations/document_view.cxx +3 -3
  165. data/ext/couchbase/core/operations/management/analytics_dataset_create.cxx +15 -8
  166. data/ext/couchbase/core/operations/management/analytics_dataset_create.hxx +4 -0
  167. data/ext/couchbase/core/operations/management/analytics_dataset_drop.cxx +11 -6
  168. data/ext/couchbase/core/operations/management/analytics_dataset_get_all.cxx +3 -2
  169. data/ext/couchbase/core/operations/management/analytics_dataverse_create.cxx +10 -5
  170. data/ext/couchbase/core/operations/management/analytics_dataverse_drop.cxx +10 -5
  171. data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.cxx +2 -1
  172. data/ext/couchbase/core/operations/management/analytics_index_create.cxx +33 -8
  173. data/ext/couchbase/core/operations/management/analytics_index_drop.cxx +12 -7
  174. data/ext/couchbase/core/operations/management/analytics_index_get_all.cxx +3 -2
  175. data/ext/couchbase/core/operations/management/analytics_link_connect.cxx +11 -6
  176. data/ext/couchbase/core/operations/management/analytics_link_create.cxx +3 -3
  177. data/ext/couchbase/core/operations/management/analytics_link_disconnect.cxx +10 -4
  178. data/ext/couchbase/core/operations/management/analytics_link_drop.cxx +6 -4
  179. data/ext/couchbase/core/operations/management/analytics_link_get_all.cxx +4 -3
  180. data/ext/couchbase/core/operations/management/analytics_link_replace.cxx +3 -3
  181. data/ext/couchbase/core/operations/management/analytics_link_utils.hxx +1 -1
  182. data/ext/couchbase/core/operations/management/bucket_create.cxx +37 -38
  183. data/ext/couchbase/core/operations/management/bucket_update.cxx +26 -28
  184. data/ext/couchbase/core/operations/management/change_password.cxx +2 -0
  185. data/ext/couchbase/core/operations/management/collection_drop.cxx +5 -1
  186. data/ext/couchbase/core/operations/management/error_utils.cxx +59 -5
  187. data/ext/couchbase/core/operations/management/error_utils.hxx +29 -1
  188. data/ext/couchbase/core/operations/management/eventing_deploy_function.cxx +9 -3
  189. data/ext/couchbase/core/operations/management/eventing_drop_function.cxx +8 -3
  190. data/ext/couchbase/core/operations/management/eventing_get_all_functions.cxx +4 -2
  191. data/ext/couchbase/core/operations/management/eventing_get_function.cxx +5 -3
  192. data/ext/couchbase/core/operations/management/eventing_get_status.cxx +4 -2
  193. data/ext/couchbase/core/operations/management/eventing_pause_function.cxx +9 -3
  194. data/ext/couchbase/core/operations/management/eventing_resume_function.cxx +9 -3
  195. data/ext/couchbase/core/operations/management/eventing_undeploy_function.cxx +9 -3
  196. data/ext/couchbase/core/operations/management/eventing_upsert_function.cxx +9 -3
  197. data/ext/couchbase/core/operations/management/group_drop.cxx +3 -1
  198. data/ext/couchbase/core/operations/management/group_get.cxx +3 -1
  199. data/ext/couchbase/core/operations/management/group_upsert.cxx +11 -8
  200. data/ext/couchbase/core/operations/management/query_index_build.cxx +5 -2
  201. data/ext/couchbase/core/operations/management/query_index_create.cxx +9 -3
  202. data/ext/couchbase/core/operations/management/query_index_drop.cxx +11 -4
  203. data/ext/couchbase/core/operations/management/query_index_get_all.cxx +1 -1
  204. data/ext/couchbase/core/operations/management/query_index_get_all_deferred.cxx +1 -1
  205. data/ext/couchbase/core/operations/management/scope_drop.cxx +5 -1
  206. data/ext/couchbase/core/operations/management/scope_get_all.cxx +6 -1
  207. data/ext/couchbase/core/operations/management/search_get_stats.cxx +10 -0
  208. data/ext/couchbase/core/operations/management/search_index_analyze_document.cxx +3 -2
  209. data/ext/couchbase/core/operations/management/search_index_control_ingest.cxx +4 -3
  210. data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.cxx +4 -3
  211. data/ext/couchbase/core/operations/management/search_index_control_query.cxx +4 -3
  212. data/ext/couchbase/core/operations/management/search_index_drop.cxx +2 -2
  213. data/ext/couchbase/core/operations/management/search_index_get.cxx +2 -2
  214. data/ext/couchbase/core/operations/management/search_index_get_documents_count.cxx +3 -2
  215. data/ext/couchbase/core/operations/management/search_index_get_stats.cxx +3 -1
  216. data/ext/couchbase/core/operations/management/search_index_upsert.cxx +2 -2
  217. data/ext/couchbase/core/operations/management/user_drop.cxx +3 -1
  218. data/ext/couchbase/core/operations/management/user_get.cxx +3 -1
  219. data/ext/couchbase/core/operations/management/user_upsert.cxx +12 -9
  220. data/ext/couchbase/core/operations/management/view_index_drop.cxx +1 -1
  221. data/ext/couchbase/core/operations/management/view_index_get.cxx +1 -1
  222. data/ext/couchbase/core/operations/management/view_index_upsert.cxx +1 -1
  223. data/ext/couchbase/core/operations/operation_traits.hxx +18 -0
  224. data/ext/couchbase/core/operations/query_response_parsing.cxx +211 -0
  225. data/ext/couchbase/core/operations/query_response_parsing.hxx +60 -0
  226. data/ext/couchbase/core/operations_fwd.hxx +3 -3
  227. data/ext/couchbase/core/origin.cxx +54 -26
  228. data/ext/couchbase/core/origin.hxx +12 -0
  229. data/ext/couchbase/core/orphan_reporter.cxx +2 -1
  230. data/ext/couchbase/core/platform/random.cc +7 -7
  231. data/ext/couchbase/core/protocol/client_request.cxx +2 -2
  232. data/ext/couchbase/core/protocol/client_request.hxx +38 -21
  233. data/ext/couchbase/core/protocol/client_response.cxx +11 -3
  234. data/ext/couchbase/core/protocol/client_response.hxx +27 -6
  235. data/ext/couchbase/core/protocol/cmd_append.cxx +2 -2
  236. data/ext/couchbase/core/protocol/cmd_cluster_map_change_notification.cxx +2 -2
  237. data/ext/couchbase/core/protocol/cmd_decrement.cxx +6 -6
  238. data/ext/couchbase/core/protocol/cmd_get.cxx +1 -1
  239. data/ext/couchbase/core/protocol/cmd_get_and_lock.cxx +2 -2
  240. data/ext/couchbase/core/protocol/cmd_get_and_touch.cxx +2 -2
  241. data/ext/couchbase/core/protocol/cmd_get_cluster_config.cxx +6 -4
  242. data/ext/couchbase/core/protocol/cmd_get_collection_id.cxx +2 -2
  243. data/ext/couchbase/core/protocol/cmd_get_error_map.cxx +1 -1
  244. data/ext/couchbase/core/protocol/cmd_get_meta.cxx +4 -4
  245. data/ext/couchbase/core/protocol/cmd_get_replica.cxx +1 -1
  246. data/ext/couchbase/core/protocol/cmd_hello.cxx +1 -1
  247. data/ext/couchbase/core/protocol/cmd_increment.cxx +6 -6
  248. data/ext/couchbase/core/protocol/cmd_insert.cxx +4 -4
  249. data/ext/couchbase/core/protocol/cmd_lookup_in.cxx +4 -3
  250. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +4 -3
  251. data/ext/couchbase/core/protocol/cmd_mutate_in.cxx +10 -9
  252. data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +10 -10
  253. data/ext/couchbase/core/protocol/cmd_observe_seqno.cxx +7 -7
  254. data/ext/couchbase/core/protocol/cmd_prepend.cxx +2 -2
  255. data/ext/couchbase/core/protocol/cmd_remove.cxx +2 -2
  256. data/ext/couchbase/core/protocol/cmd_replace.cxx +4 -4
  257. data/ext/couchbase/core/protocol/cmd_touch.cxx +1 -1
  258. data/ext/couchbase/core/protocol/cmd_upsert.cxx +4 -4
  259. data/ext/couchbase/core/protocol/datatype.hxx +118 -1
  260. data/ext/couchbase/core/protocol/frame_info_utils.cxx +1 -1
  261. data/ext/couchbase/core/protocol/magic.hxx +4 -0
  262. data/ext/couchbase/core/protocol/magic_fmt.hxx +3 -0
  263. data/ext/couchbase/core/protocol/server_request.hxx +3 -1
  264. data/ext/couchbase/core/protocol/status.cxx +1 -1
  265. data/ext/couchbase/core/protostellar/analytics_converter.hxx +171 -0
  266. data/ext/couchbase/core/protostellar/bucket_admin_converter.hxx +301 -0
  267. data/ext/couchbase/core/protostellar/collection_admin_converter.hxx +92 -0
  268. data/ext/couchbase/core/protostellar/component.cxx +2445 -0
  269. data/ext/couchbase/core/protostellar/component.hxx +391 -0
  270. data/ext/couchbase/core/{columnar/bootstrap_notification_subscriber.hxx → protostellar/compression_settings.hxx} +11 -10
  271. data/ext/couchbase/core/protostellar/credentials.cxx +233 -0
  272. data/ext/couchbase/core/protostellar/credentials.hxx +88 -0
  273. data/ext/couchbase/core/protostellar/dispatcher.cxx +57 -0
  274. data/ext/couchbase/core/protostellar/dispatcher.hxx +482 -0
  275. data/ext/couchbase/core/protostellar/error_utils.cxx +293 -0
  276. data/ext/couchbase/core/protostellar/error_utils.hxx +97 -0
  277. data/ext/couchbase/core/protostellar/json_payload.hxx +49 -0
  278. data/ext/couchbase/core/protostellar/kv_converter.cxx +70 -0
  279. data/ext/couchbase/core/protostellar/kv_converter.hxx +600 -0
  280. data/ext/couchbase/core/protostellar/query_converter.hxx +265 -0
  281. data/ext/couchbase/core/protostellar/query_index_admin_converter.hxx +291 -0
  282. data/ext/couchbase/core/protostellar/query_proto.hxx +73 -0
  283. data/ext/couchbase/core/protostellar/search_converter.hxx +244 -0
  284. data/ext/couchbase/core/protostellar/search_index_admin_converter.hxx +156 -0
  285. data/ext/couchbase/core/protostellar/view_converter.hxx +158 -0
  286. data/ext/couchbase/core/query_stream.cxx +447 -0
  287. data/ext/couchbase/core/query_stream.hxx +141 -0
  288. data/ext/couchbase/core/query_stream_component.cxx +243 -0
  289. data/ext/couchbase/core/query_stream_component.hxx +68 -0
  290. data/ext/couchbase/core/range_scan_load_balancer.cxx +15 -8
  291. data/ext/couchbase/core/range_scan_orchestrator.cxx +15 -3
  292. data/ext/couchbase/core/response_handler.hxx +41 -4
  293. data/ext/couchbase/core/row_streamer.cxx +332 -46
  294. data/ext/couchbase/core/row_streamer.hxx +31 -1
  295. data/ext/couchbase/core/row_streamer_options.hxx +55 -0
  296. data/ext/couchbase/core/sasl/client.h +3 -0
  297. data/ext/couchbase/core/search_scoring.hxx +66 -0
  298. data/ext/couchbase/core/stream_error_details.hxx +69 -0
  299. data/ext/couchbase/core/timeout_defaults.hxx +0 -1
  300. data/ext/couchbase/core/topology/capabilities.hxx +6 -0
  301. data/ext/couchbase/core/topology/capabilities_fmt.hxx +3 -0
  302. data/ext/couchbase/core/topology/configuration.cxx +21 -6
  303. data/ext/couchbase/core/topology/configuration.hxx +29 -8
  304. data/ext/couchbase/core/topology/configuration_json.hxx +3 -0
  305. data/ext/couchbase/core/topology/error_map_json.hxx +3 -1
  306. data/ext/couchbase/core/tracing/threshold_logging_tracer.cxx +70 -4
  307. data/ext/couchbase/core/tracing/threshold_logging_tracer.hxx +10 -0
  308. data/ext/couchbase/core/transactions/active_transaction_record.cxx +0 -34
  309. data/ext/couchbase/core/transactions/attempt_context_impl.cxx +362 -241
  310. data/ext/couchbase/core/transactions/attempt_context_impl.hxx +24 -3
  311. data/ext/couchbase/core/transactions/error_list.hxx +2 -2
  312. data/ext/couchbase/core/transactions/get_multi_fetch.hxx +160 -0
  313. data/ext/couchbase/core/transactions/get_multi_orchestrator.cxx +326 -125
  314. data/ext/couchbase/core/transactions/get_multi_transaction_id.hxx +62 -0
  315. data/ext/couchbase/core/transactions/internal/atr_entry.hxx +22 -2
  316. data/ext/couchbase/core/transactions/internal/transaction_context.hxx +2 -2
  317. data/ext/couchbase/core/transactions/internal/transactions_cleanup.hxx +23 -1
  318. data/ext/couchbase/core/transactions/internal/utils.hxx +50 -14
  319. data/ext/couchbase/core/transactions/staged_mutation.cxx +23 -18
  320. data/ext/couchbase/core/transactions/staged_mutation.hxx +15 -4
  321. data/ext/couchbase/core/transactions/transaction_context.cxx +55 -40
  322. data/ext/couchbase/core/transactions/transaction_get_result.hxx +16 -0
  323. data/ext/couchbase/core/transactions/transactions.cxx +3 -55
  324. data/ext/couchbase/core/transactions/transactions_cleanup.cxx +194 -66
  325. data/ext/couchbase/core/transactions/transactions_config.cxx +0 -11
  326. data/ext/couchbase/core/transactions/utils.cxx +10 -0
  327. data/ext/couchbase/core/transactions/waitable_op_list.hxx +15 -4
  328. data/ext/couchbase/core/transactions.hxx +9 -9
  329. data/ext/couchbase/core/utils/byteswap.hxx +166 -9
  330. data/ext/couchbase/core/utils/connection_string.cxx +50 -85
  331. data/ext/couchbase/core/utils/connection_string.hxx +15 -0
  332. data/ext/couchbase/core/{columnar/backoff_calculator.hxx → utils/deadline.hxx} +13 -13
  333. data/ext/couchbase/core/utils/duration_parser.cxx +1 -1
  334. data/ext/couchbase/core/utils/json_streaming_lexer.cxx +48 -5
  335. data/ext/couchbase/core/utils/json_streaming_lexer.hxx +4 -1
  336. data/ext/couchbase/core/utils/movable_function.hxx +301 -52
  337. data/ext/couchbase/core/utils/name_codec.hxx +154 -11
  338. data/ext/couchbase/core/{columnar/retry_info.hxx → utils/process_id.hxx} +18 -13
  339. data/ext/couchbase/core/utils/url_codec.cxx +12 -51
  340. data/ext/couchbase/core/websocket_codec.cxx +3 -29
  341. data/ext/couchbase/couchbase/analytics_options.hxx +21 -10
  342. data/ext/couchbase/couchbase/analytics_row.hxx +105 -0
  343. data/ext/couchbase/couchbase/analytics_stream_result.hxx +266 -0
  344. data/ext/couchbase/couchbase/boolean_query.hxx +3 -3
  345. data/ext/couchbase/couchbase/bucket.hxx +57 -0
  346. data/ext/couchbase/couchbase/cluster.hxx +216 -5
  347. data/ext/couchbase/{core/columnar/security_options.hxx → couchbase/cluster_state.hxx} +18 -14
  348. data/ext/couchbase/couchbase/codec/lenient_json_transcoder.hxx +69 -0
  349. data/ext/couchbase/couchbase/collection.hxx +234 -14
  350. data/ext/couchbase/couchbase/common_durability_options.hxx +18 -3
  351. data/ext/couchbase/couchbase/conjunction_query.hxx +1 -1
  352. data/ext/couchbase/couchbase/create_dataset_analytics_options.hxx +6 -1
  353. data/ext/couchbase/couchbase/date_range_query.hxx +2 -2
  354. data/ext/couchbase/couchbase/decrement_options.hxx +1 -1
  355. data/ext/couchbase/couchbase/disjunction_query.hxx +1 -1
  356. data/ext/couchbase/couchbase/error.hxx +32 -0
  357. data/ext/couchbase/couchbase/error_codes.hxx +32 -0
  358. data/ext/couchbase/couchbase/geo_bounding_box_query.hxx +1 -1
  359. data/ext/couchbase/couchbase/geo_distance_query.hxx +1 -1
  360. data/ext/couchbase/couchbase/geo_polygon_query.hxx +1 -1
  361. data/ext/couchbase/couchbase/get_replica_options.hxx +68 -0
  362. data/ext/couchbase/couchbase/get_replica_result.hxx +5 -3
  363. data/ext/couchbase/couchbase/get_replica_strategy.hxx +161 -0
  364. data/ext/couchbase/couchbase/get_result.hxx +1 -0
  365. data/ext/couchbase/couchbase/increment_options.hxx +1 -1
  366. data/ext/couchbase/couchbase/insert_options.hxx +1 -1
  367. data/ext/couchbase/couchbase/match_phrase_query.hxx +1 -1
  368. data/ext/couchbase/couchbase/match_query.hxx +1 -1
  369. data/ext/couchbase/couchbase/mutate_in_options.hxx +3 -3
  370. data/ext/couchbase/couchbase/network_options.hxx +1 -1
  371. data/ext/couchbase/couchbase/node_id.hxx +42 -14
  372. data/ext/couchbase/couchbase/node_id_for_options.hxx +7 -1
  373. data/ext/couchbase/couchbase/node_ids_options.hxx +8 -2
  374. data/ext/couchbase/couchbase/numeric_range_query.hxx +1 -1
  375. data/ext/couchbase/couchbase/phrase_query.hxx +1 -1
  376. data/ext/couchbase/couchbase/prefix_query.hxx +1 -1
  377. data/ext/couchbase/couchbase/query_options.hxx +23 -12
  378. data/ext/couchbase/couchbase/query_row.hxx +111 -0
  379. data/ext/couchbase/couchbase/query_stream_result.hxx +302 -0
  380. data/ext/couchbase/couchbase/query_string_query.hxx +3 -3
  381. data/ext/couchbase/couchbase/regexp_query.hxx +1 -1
  382. data/ext/couchbase/couchbase/replace_options.hxx +3 -3
  383. data/ext/couchbase/couchbase/result.hxx +14 -3
  384. data/ext/couchbase/couchbase/scan_result_item.hxx +1 -0
  385. data/ext/couchbase/couchbase/scope.hxx +85 -2
  386. data/ext/couchbase/couchbase/search_options.hxx +58 -8
  387. data/ext/couchbase/couchbase/search_scoring.hxx +94 -0
  388. data/ext/couchbase/couchbase/search_scoring_none.hxx +51 -0
  389. data/ext/couchbase/couchbase/search_scoring_reciprocal_rank_fusion.hxx +88 -0
  390. data/ext/couchbase/couchbase/search_scoring_relative_score_fusion.hxx +70 -0
  391. data/ext/couchbase/couchbase/term_range_query.hxx +1 -1
  392. data/ext/couchbase/couchbase/tracing/request_span.hxx +46 -0
  393. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +23 -21
  394. data/ext/couchbase/couchbase/transactions/transaction_get_multi_result.hxx +24 -19
  395. data/ext/couchbase/couchbase/transactions/transaction_get_result.hxx +17 -3
  396. data/ext/couchbase/couchbase/transactions/transactions_config.hxx +4 -2
  397. data/ext/couchbase/couchbase/transactions.hxx +27 -18
  398. data/ext/couchbase/couchbase/upsert_options.hxx +3 -3
  399. data/ext/couchbase/couchbase/vector_query.hxx +1 -1
  400. data/ext/couchbase/couchbase/wait_until_ready_options.hxx +111 -0
  401. data/ext/couchbase/couchbase/wildcard_query.hxx +1 -1
  402. data/ext/extconf.rb +15 -10
  403. data/ext/rcb_analytics.cxx +82 -102
  404. data/ext/rcb_backend.cxx +42 -36
  405. data/ext/rcb_backend.hxx +2 -0
  406. data/ext/rcb_buckets.cxx +47 -59
  407. data/ext/rcb_collections.cxx +42 -52
  408. data/ext/rcb_crud.cxx +345 -224
  409. data/ext/rcb_diagnostics.cxx +117 -27
  410. data/ext/rcb_exceptions.cxx +152 -99
  411. data/ext/rcb_exceptions.hxx +25 -0
  412. data/ext/rcb_extras.cxx +18 -19
  413. data/ext/rcb_hdr_histogram.cxx +19 -4
  414. data/ext/rcb_logger.cxx +202 -27
  415. data/ext/rcb_logger.hxx +12 -0
  416. data/ext/rcb_multi.cxx +40 -40
  417. data/ext/rcb_observability.cxx +7 -5
  418. data/ext/rcb_query.cxx +99 -142
  419. data/ext/rcb_range_scan.cxx +41 -35
  420. data/ext/rcb_search.cxx +98 -99
  421. data/ext/rcb_users.cxx +36 -56
  422. data/ext/rcb_utils.cxx +100 -37
  423. data/ext/rcb_utils.hxx +287 -33
  424. data/ext/rcb_version.cxx +1 -1
  425. data/ext/rcb_views.cxx +55 -51
  426. data/lib/active_support/cache/couchbase_store.rb +77 -12
  427. data/lib/couchbase/bucket.rb +20 -0
  428. data/lib/couchbase/cluster.rb +33 -14
  429. data/lib/couchbase/collection.rb +36 -1
  430. data/lib/couchbase/errors.rb +18 -0
  431. data/lib/couchbase/fork_hooks.rb +16 -7
  432. data/lib/couchbase/get_replica_strategy.rb +89 -0
  433. data/lib/couchbase/logger.rb +1 -1
  434. data/lib/couchbase/management/analytics_index_manager.rb +15 -15
  435. data/lib/couchbase/management/bucket_manager.rb +6 -6
  436. data/lib/couchbase/management/collection_manager.rb +6 -6
  437. data/lib/couchbase/management/query_index_manager.rb +7 -7
  438. data/lib/couchbase/management/search_index_manager.rb +13 -13
  439. data/lib/couchbase/management/user_manager.rb +10 -10
  440. data/lib/couchbase/management/view_index_manager.rb +5 -5
  441. data/lib/couchbase/options.rb +181 -44
  442. data/lib/couchbase/protostellar/bucket.rb +4 -0
  443. data/lib/couchbase/protostellar/cluster.rb +4 -0
  444. data/lib/couchbase/protostellar/collection.rb +4 -0
  445. data/lib/couchbase/protostellar/error_handling.rb +2 -1
  446. data/lib/couchbase/protostellar/request.rb +1 -0
  447. data/lib/couchbase/protostellar/request_generator/kv.rb +16 -2
  448. data/lib/couchbase/protostellar/request_generator/search.rb +17 -1
  449. data/lib/couchbase/protostellar/retry/orchestrator.rb +3 -2
  450. data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
  451. data/lib/couchbase/protostellar/retry/strategies.rb +1 -0
  452. data/lib/couchbase/search_options.rb +95 -6
  453. data/lib/couchbase/version.rb +1 -1
  454. metadata +92 -33
  455. data/ext/0001-fix-build-for-mingw-w64-ucrt-x86_64-toolchain.patch +0 -40
  456. data/ext/couchbase/core/columnar/agent.hxx +0 -71
  457. data/ext/couchbase/core/columnar/agent_config.hxx +0 -59
  458. data/ext/couchbase/core/columnar/background_bootstrap_listener.hxx +0 -42
  459. data/ext/couchbase/core/columnar/backoff_calculator.cxx +0 -62
  460. data/ext/couchbase/core/columnar/columnar_agent.cxx +0 -147
  461. data/ext/couchbase/core/columnar/columnar_agent_config.cxx +0 -48
  462. data/ext/couchbase/core/columnar/columnar_error.cxx +0 -51
  463. data/ext/couchbase/core/columnar/database_management_options.hxx +0 -56
  464. data/ext/couchbase/core/columnar/error.hxx +0 -51
  465. data/ext/couchbase/core/columnar/error_codes.cxx +0 -107
  466. data/ext/couchbase/core/columnar/error_codes.hxx +0 -75
  467. data/ext/couchbase/core/columnar/management_component.cxx +0 -300
  468. data/ext/couchbase/core/columnar/management_component.hxx +0 -56
  469. data/ext/couchbase/core/columnar/query_component.cxx +0 -523
  470. data/ext/couchbase/core/columnar/query_component.hxx +0 -57
  471. data/ext/couchbase/core/columnar/query_options.hxx +0 -59
  472. data/ext/couchbase/core/columnar/query_result.cxx +0 -130
  473. data/ext/couchbase/core/columnar/query_result.hxx +0 -78
  474. data/ext/couchbase/core/io/config_tracker.cxx +0 -687
  475. data/ext/couchbase/core/io/config_tracker.hxx +0 -123
data/ext/rcb_crud.cxx CHANGED
@@ -26,6 +26,7 @@
26
26
  #include <core/operations/document_get_and_touch.hxx>
27
27
  #include <core/operations/document_get_any_replica.hxx>
28
28
  #include <core/operations/document_get_projected.hxx>
29
+ #include <core/operations/document_get_replica.hxx>
29
30
  #include <core/operations/document_increment.hxx>
30
31
  #include <core/operations/document_insert.hxx>
31
32
  #include <core/operations/document_lookup_in.hxx>
@@ -92,10 +93,10 @@ cb_Backend_document_get(VALUE self,
92
93
  {
93
94
  auto cluster = cb_backend_to_core_api_cluster(self);
94
95
 
95
- Check_Type(bucket, T_STRING);
96
- Check_Type(scope, T_STRING);
97
- Check_Type(collection, T_STRING);
98
- Check_Type(id, T_STRING);
96
+ cb_check_type(bucket, T_STRING);
97
+ cb_check_type(scope, T_STRING);
98
+ cb_check_type(collection, T_STRING);
99
+ cb_check_type(id, T_STRING);
99
100
 
100
101
  try {
101
102
  core::document_id doc_id{
@@ -105,7 +106,8 @@ cb_Backend_document_get(VALUE self,
105
106
  cb_string_new(id),
106
107
  };
107
108
 
108
- core::operations::get_request req{ doc_id };
109
+ auto retry_strategy = cb_extract_retry_strategy(options);
110
+ core::operations::get_request req{ doc_id, {}, {}, {}, { retry_strategy } };
109
111
  cb_extract_timeout(req, options);
110
112
 
111
113
  auto parent_span = cb_create_parent_span(req, self);
@@ -127,10 +129,8 @@ cb_Backend_document_get(VALUE self,
127
129
  rb_hash_aset(res, rb_id2sym(rb_intern("flags")), UINT2NUM(resp.flags));
128
130
  return res;
129
131
  } catch (const std::system_error& se) {
130
- rb_exc_raise(cb_map_error_code(
132
+ throw ruby_exception(cb_map_error_code(
131
133
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
132
- } catch (const ruby_exception& e) {
133
- rb_exc_raise(e.exception_object());
134
134
  }
135
135
  return Qnil;
136
136
  }
@@ -146,10 +146,10 @@ cb_Backend_document_get_any_replica(VALUE self,
146
146
  {
147
147
  auto cluster = cb_backend_to_core_api_cluster(self);
148
148
 
149
- Check_Type(bucket, T_STRING);
150
- Check_Type(scope, T_STRING);
151
- Check_Type(collection, T_STRING);
152
- Check_Type(id, T_STRING);
149
+ cb_check_type(bucket, T_STRING);
150
+ cb_check_type(scope, T_STRING);
151
+ cb_check_type(collection, T_STRING);
152
+ cb_check_type(id, T_STRING);
153
153
 
154
154
  try {
155
155
  core::document_id doc_id{
@@ -180,13 +180,75 @@ cb_Backend_document_get_any_replica(VALUE self,
180
180
  rb_hash_aset(res, rb_id2sym(rb_intern("content")), cb_str_new(resp.value));
181
181
  rb_hash_aset(res, rb_id2sym(rb_intern("cas")), cb_cas_to_num(resp.cas));
182
182
  rb_hash_aset(res, rb_id2sym(rb_intern("flags")), UINT2NUM(resp.flags));
183
- rb_hash_aset(res, rb_id2sym(rb_intern("replica")), resp.replica ? Qtrue : Qfalse);
183
+ rb_hash_aset(res, rb_id2sym(rb_intern("is_replica")), resp.replica ? Qtrue : Qfalse);
184
184
  return res;
185
185
  } catch (const std::system_error& se) {
186
- rb_exc_raise(cb_map_error_code(
186
+ throw ruby_exception(cb_map_error_code(
187
+ se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
188
+ }
189
+ return Qnil;
190
+ }
191
+
192
+ VALUE
193
+ cb_Backend_document_get_replica(VALUE self,
194
+ VALUE bucket,
195
+ VALUE scope,
196
+ VALUE collection,
197
+ VALUE id,
198
+ VALUE strategy,
199
+ VALUE options,
200
+ VALUE observability_handler)
201
+ {
202
+ auto cluster = cb_backend_to_core_api_cluster(self);
203
+
204
+ cb_check_type(bucket, T_STRING);
205
+ cb_check_type(scope, T_STRING);
206
+ cb_check_type(collection, T_STRING);
207
+ cb_check_type(id, T_STRING);
208
+ cb_check_type(strategy, T_HASH);
209
+
210
+ try {
211
+ core::document_id doc_id{
212
+ cb_string_new(bucket),
213
+ cb_string_new(scope),
214
+ cb_string_new(collection),
215
+ cb_string_new(id),
216
+ };
217
+
218
+ auto retry_strategy = cb_extract_retry_strategy(options);
219
+ core::operations::get_replica_request req{ doc_id, {}, {}, {}, { retry_strategy } };
220
+ req.selection.emplace();
221
+ cb_extract_option_number(req.selection->replica_index, strategy, "replica_index");
222
+ cb_extract_option_bool(req.selection->wrap, strategy, "wrap");
223
+ cb_extract_timeout(req, options);
224
+
225
+ auto parent_span = cb_create_parent_span(req, self);
226
+
227
+ std::promise<core::operations::get_replica_response> promise;
228
+ auto f = promise.get_future();
229
+ cluster.execute(req, [promise = std::move(promise)](auto&& resp) mutable {
230
+ promise.set_value(std::forward<decltype(resp)>(resp));
231
+ });
232
+ auto resp = cb_wait_for_future(f);
233
+ cb_add_core_spans(observability_handler, std::move(parent_span), resp.ctx.retry_attempts());
234
+ if (resp.ctx.ec()) {
235
+ // Overriding the code keeps the Hash error context of the other KV bindings.
236
+ // Error::DocumentNotFoundOnReplica subclasses Error::DocumentNotFound, which stands in for
237
+ // the document_not_found cause that core::impl::make_get_replica_error() attaches.
238
+ if (resp.ctx.ec() == errc::key_value::document_not_found) {
239
+ resp.ctx.override_ec(errc::key_value::document_not_found_on_replica);
240
+ }
241
+ cb_throw_error(resp.ctx, "unable to get replica of the document");
242
+ }
243
+
244
+ VALUE res = rb_hash_new();
245
+ rb_hash_aset(res, rb_id2sym(rb_intern("content")), cb_str_new(resp.value));
246
+ rb_hash_aset(res, rb_id2sym(rb_intern("cas")), cb_cas_to_num(resp.cas));
247
+ rb_hash_aset(res, rb_id2sym(rb_intern("flags")), UINT2NUM(resp.flags));
248
+ return res;
249
+ } catch (const std::system_error& se) {
250
+ throw ruby_exception(cb_map_error_code(
187
251
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
188
- } catch (const ruby_exception& e) {
189
- rb_exc_raise(e.exception_object());
190
252
  }
191
253
  return Qnil;
192
254
  }
@@ -202,10 +264,10 @@ cb_Backend_document_get_all_replicas(VALUE self,
202
264
  {
203
265
  auto cluster = cb_backend_to_core_api_cluster(self);
204
266
 
205
- Check_Type(bucket, T_STRING);
206
- Check_Type(scope, T_STRING);
207
- Check_Type(collection, T_STRING);
208
- Check_Type(id, T_STRING);
267
+ cb_check_type(bucket, T_STRING);
268
+ cb_check_type(scope, T_STRING);
269
+ cb_check_type(collection, T_STRING);
270
+ cb_check_type(id, T_STRING);
209
271
 
210
272
  try {
211
273
  core::document_id doc_id{
@@ -239,15 +301,13 @@ cb_Backend_document_get_all_replicas(VALUE self,
239
301
  rb_hash_aset(response, rb_id2sym(rb_intern("content")), cb_str_new(entry.value));
240
302
  rb_hash_aset(response, rb_id2sym(rb_intern("cas")), cb_cas_to_num(entry.cas));
241
303
  rb_hash_aset(response, rb_id2sym(rb_intern("flags")), UINT2NUM(entry.flags));
242
- rb_hash_aset(response, rb_id2sym(rb_intern("replica")), entry.replica ? Qtrue : Qfalse);
304
+ rb_hash_aset(response, rb_id2sym(rb_intern("is_replica")), entry.replica ? Qtrue : Qfalse);
243
305
  rb_ary_push(res, response);
244
306
  }
245
307
  return res;
246
308
  } catch (const std::system_error& se) {
247
- rb_exc_raise(cb_map_error_code(
309
+ throw ruby_exception(cb_map_error_code(
248
310
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
249
- } catch (const ruby_exception& e) {
250
- rb_exc_raise(e.exception_object());
251
311
  }
252
312
  return Qnil;
253
313
  }
@@ -263,12 +323,12 @@ cb_Backend_document_get_projected(VALUE self,
263
323
  {
264
324
  auto cluster = cb_backend_to_core_api_cluster(self);
265
325
 
266
- Check_Type(bucket, T_STRING);
267
- Check_Type(scope, T_STRING);
268
- Check_Type(collection, T_STRING);
269
- Check_Type(id, T_STRING);
326
+ cb_check_type(bucket, T_STRING);
327
+ cb_check_type(scope, T_STRING);
328
+ cb_check_type(collection, T_STRING);
329
+ cb_check_type(id, T_STRING);
270
330
  if (!NIL_P(options)) {
271
- Check_Type(options, T_HASH);
331
+ cb_check_type(options, T_HASH);
272
332
  }
273
333
 
274
334
  try {
@@ -279,7 +339,10 @@ cb_Backend_document_get_projected(VALUE self,
279
339
  cb_string_new(id),
280
340
  };
281
341
 
282
- core::operations::get_projected_request req{ doc_id };
342
+ auto retry_strategy = cb_extract_retry_strategy(options);
343
+ core::operations::get_projected_request req{
344
+ doc_id, {}, {}, {}, false, {}, false, {}, { retry_strategy },
345
+ };
283
346
  cb_extract_timeout(req, options);
284
347
  auto parent_span = cb_create_parent_span(req, self);
285
348
  cb_extract_option_bool(req.with_expiry, options, "with_expiry");
@@ -319,10 +382,8 @@ cb_Backend_document_get_projected(VALUE self,
319
382
  }
320
383
  return res;
321
384
  } catch (const std::system_error& se) {
322
- rb_exc_raise(cb_map_error_code(
385
+ throw ruby_exception(cb_map_error_code(
323
386
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
324
- } catch (const ruby_exception& e) {
325
- rb_exc_raise(e.exception_object());
326
387
  }
327
388
  return Qnil;
328
389
  }
@@ -339,13 +400,13 @@ cb_Backend_document_get_and_lock(VALUE self,
339
400
  {
340
401
  auto cluster = cb_backend_to_core_api_cluster(self);
341
402
 
342
- Check_Type(bucket, T_STRING);
343
- Check_Type(scope, T_STRING);
344
- Check_Type(collection, T_STRING);
345
- Check_Type(id, T_STRING);
346
- Check_Type(lock_time, T_FIXNUM);
403
+ cb_check_type(bucket, T_STRING);
404
+ cb_check_type(scope, T_STRING);
405
+ cb_check_type(collection, T_STRING);
406
+ cb_check_type(id, T_STRING);
407
+ cb_check_type(lock_time, T_FIXNUM);
347
408
  if (!NIL_P(options)) {
348
- Check_Type(options, T_HASH);
409
+ cb_check_type(options, T_HASH);
349
410
  }
350
411
 
351
412
  try {
@@ -356,9 +417,10 @@ cb_Backend_document_get_and_lock(VALUE self,
356
417
  cb_string_new(id),
357
418
  };
358
419
 
359
- core::operations::get_and_lock_request req{ doc_id };
420
+ auto retry_strategy = cb_extract_retry_strategy(options);
421
+ core::operations::get_and_lock_request req{ doc_id, {}, {}, {}, {}, { retry_strategy } };
360
422
  cb_extract_timeout(req, options);
361
- req.lock_time = NUM2UINT(lock_time);
423
+ req.lock_time = cb_num2uint(lock_time);
362
424
 
363
425
  auto parent_span = cb_create_parent_span(req, self);
364
426
 
@@ -379,10 +441,8 @@ cb_Backend_document_get_and_lock(VALUE self,
379
441
  rb_hash_aset(res, rb_id2sym(rb_intern("flags")), UINT2NUM(resp.flags));
380
442
  return res;
381
443
  } catch (const std::system_error& se) {
382
- rb_exc_raise(cb_map_error_code(
444
+ throw ruby_exception(cb_map_error_code(
383
445
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
384
- } catch (const ruby_exception& e) {
385
- rb_exc_raise(e.exception_object());
386
446
  }
387
447
  return Qnil;
388
448
  }
@@ -399,12 +459,12 @@ cb_Backend_document_get_and_touch(VALUE self,
399
459
  {
400
460
  auto cluster = cb_backend_to_core_api_cluster(self);
401
461
 
402
- Check_Type(bucket, T_STRING);
403
- Check_Type(scope, T_STRING);
404
- Check_Type(collection, T_STRING);
405
- Check_Type(id, T_STRING);
462
+ cb_check_type(bucket, T_STRING);
463
+ cb_check_type(scope, T_STRING);
464
+ cb_check_type(collection, T_STRING);
465
+ cb_check_type(id, T_STRING);
406
466
  if (!NIL_P(options)) {
407
- Check_Type(options, T_HASH);
467
+ cb_check_type(options, T_HASH);
408
468
  }
409
469
 
410
470
  try {
@@ -415,7 +475,8 @@ cb_Backend_document_get_and_touch(VALUE self,
415
475
  cb_string_new(id),
416
476
  };
417
477
 
418
- core::operations::get_and_touch_request req{ doc_id };
478
+ auto retry_strategy = cb_extract_retry_strategy(options);
479
+ core::operations::get_and_touch_request req{ doc_id, {}, {}, {}, {}, { retry_strategy } };
419
480
  cb_extract_timeout(req, options);
420
481
  auto [type, duration] = unpack_expiry(expiry, false);
421
482
  req.expiry = static_cast<std::uint32_t>(duration.count());
@@ -439,10 +500,8 @@ cb_Backend_document_get_and_touch(VALUE self,
439
500
  rb_hash_aset(res, rb_id2sym(rb_intern("flags")), UINT2NUM(resp.flags));
440
501
  return res;
441
502
  } catch (const std::system_error& se) {
442
- rb_exc_raise(cb_map_error_code(
503
+ throw ruby_exception(cb_map_error_code(
443
504
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
444
- } catch (const ruby_exception& e) {
445
- rb_exc_raise(e.exception_object());
446
505
  }
447
506
  return Qnil;
448
507
  }
@@ -459,12 +518,12 @@ cb_Backend_document_touch(VALUE self,
459
518
  {
460
519
  auto cluster = cb_backend_to_core_api_cluster(self);
461
520
 
462
- Check_Type(bucket, T_STRING);
463
- Check_Type(scope, T_STRING);
464
- Check_Type(collection, T_STRING);
465
- Check_Type(id, T_STRING);
521
+ cb_check_type(bucket, T_STRING);
522
+ cb_check_type(scope, T_STRING);
523
+ cb_check_type(collection, T_STRING);
524
+ cb_check_type(id, T_STRING);
466
525
  if (!NIL_P(options)) {
467
- Check_Type(options, T_HASH);
526
+ cb_check_type(options, T_HASH);
468
527
  }
469
528
 
470
529
  try {
@@ -475,7 +534,8 @@ cb_Backend_document_touch(VALUE self,
475
534
  cb_string_new(id),
476
535
  };
477
536
 
478
- core::operations::touch_request req{ doc_id };
537
+ auto retry_strategy = cb_extract_retry_strategy(options);
538
+ core::operations::touch_request req{ doc_id, {}, {}, {}, {}, { retry_strategy } };
479
539
  cb_extract_timeout(req, options);
480
540
  auto [type, duration] = unpack_expiry(expiry, false);
481
541
  req.expiry = static_cast<std::uint32_t>(duration.count());
@@ -497,10 +557,8 @@ cb_Backend_document_touch(VALUE self,
497
557
  rb_hash_aset(res, rb_id2sym(rb_intern("cas")), cb_cas_to_num(resp.cas));
498
558
  return res;
499
559
  } catch (const std::system_error& se) {
500
- rb_exc_raise(cb_map_error_code(
560
+ throw ruby_exception(cb_map_error_code(
501
561
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
502
- } catch (const ruby_exception& e) {
503
- rb_exc_raise(e.exception_object());
504
562
  }
505
563
  return Qnil;
506
564
  }
@@ -516,12 +574,12 @@ cb_Backend_document_exists(VALUE self,
516
574
  {
517
575
  auto cluster = cb_backend_to_core_api_cluster(self);
518
576
 
519
- Check_Type(bucket, T_STRING);
520
- Check_Type(scope, T_STRING);
521
- Check_Type(collection, T_STRING);
522
- Check_Type(id, T_STRING);
577
+ cb_check_type(bucket, T_STRING);
578
+ cb_check_type(scope, T_STRING);
579
+ cb_check_type(collection, T_STRING);
580
+ cb_check_type(id, T_STRING);
523
581
  if (!NIL_P(options)) {
524
- Check_Type(options, T_HASH);
582
+ cb_check_type(options, T_HASH);
525
583
  }
526
584
 
527
585
  try {
@@ -532,7 +590,8 @@ cb_Backend_document_exists(VALUE self,
532
590
  cb_string_new(id),
533
591
  };
534
592
 
535
- core::operations::exists_request req{ doc_id };
593
+ auto retry_strategy = cb_extract_retry_strategy(options);
594
+ core::operations::exists_request req{ doc_id, {}, {}, {}, { retry_strategy } };
536
595
  cb_extract_timeout(req, options);
537
596
 
538
597
  auto parent_span = cb_create_parent_span(req, self);
@@ -558,10 +617,8 @@ cb_Backend_document_exists(VALUE self,
558
617
  rb_hash_aset(res, rb_id2sym(rb_intern("datatype")), UINT2NUM(resp.datatype));
559
618
  return res;
560
619
  } catch (const std::system_error& se) {
561
- rb_exc_raise(cb_map_error_code(
620
+ throw ruby_exception(cb_map_error_code(
562
621
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
563
- } catch (const ruby_exception& e) {
564
- rb_exc_raise(e.exception_object());
565
622
  }
566
623
  return Qnil;
567
624
  }
@@ -578,12 +635,12 @@ cb_Backend_document_unlock(VALUE self,
578
635
  {
579
636
  auto cluster = cb_backend_to_core_api_cluster(self);
580
637
 
581
- Check_Type(bucket, T_STRING);
582
- Check_Type(scope, T_STRING);
583
- Check_Type(collection, T_STRING);
584
- Check_Type(id, T_STRING);
638
+ cb_check_type(bucket, T_STRING);
639
+ cb_check_type(scope, T_STRING);
640
+ cb_check_type(collection, T_STRING);
641
+ cb_check_type(id, T_STRING);
585
642
  if (!NIL_P(options)) {
586
- Check_Type(options, T_HASH);
643
+ cb_check_type(options, T_HASH);
587
644
  }
588
645
 
589
646
  try {
@@ -594,7 +651,8 @@ cb_Backend_document_unlock(VALUE self,
594
651
  cb_string_new(id),
595
652
  };
596
653
 
597
- core::operations::unlock_request req{ doc_id };
654
+ auto retry_strategy = cb_extract_retry_strategy(options);
655
+ core::operations::unlock_request req{ doc_id, {}, {}, {}, {}, { retry_strategy } };
598
656
  cb_extract_timeout(req, options);
599
657
  cb_extract_cas(req.cas, cas);
600
658
 
@@ -615,10 +673,8 @@ cb_Backend_document_unlock(VALUE self,
615
673
  rb_hash_aset(res, rb_id2sym(rb_intern("cas")), cb_cas_to_num(resp.cas));
616
674
  return res;
617
675
  } catch (const std::system_error& se) {
618
- rb_exc_raise(cb_map_error_code(
676
+ throw ruby_exception(cb_map_error_code(
619
677
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
620
- } catch (const ruby_exception& e) {
621
- rb_exc_raise(e.exception_object());
622
678
  }
623
679
  return Qnil;
624
680
  }
@@ -636,14 +692,14 @@ cb_Backend_document_upsert(VALUE self,
636
692
  {
637
693
  auto cluster = cb_backend_to_core_api_cluster(self);
638
694
 
639
- Check_Type(bucket, T_STRING);
640
- Check_Type(scope, T_STRING);
641
- Check_Type(collection, T_STRING);
642
- Check_Type(id, T_STRING);
643
- Check_Type(content, T_STRING);
644
- Check_Type(flags, T_FIXNUM);
695
+ cb_check_type(bucket, T_STRING);
696
+ cb_check_type(scope, T_STRING);
697
+ cb_check_type(collection, T_STRING);
698
+ cb_check_type(id, T_STRING);
699
+ cb_check_type(content, T_STRING);
700
+ cb_check_type(flags, T_FIXNUM);
645
701
  if (!NIL_P(options)) {
646
- Check_Type(options, T_HASH);
702
+ cb_check_type(options, T_HASH);
647
703
  }
648
704
 
649
705
  try {
@@ -654,6 +710,14 @@ cb_Backend_document_upsert(VALUE self,
654
710
  cb_string_new(collection),
655
711
  cb_string_new(id),
656
712
  },
713
+ {},
714
+ {},
715
+ {},
716
+ 0,
717
+ 0,
718
+ couchbase::durability_level::none,
719
+ {},
720
+ { cb_extract_retry_strategy(options) },
657
721
  };
658
722
  cb_extract_content(req, content);
659
723
  cb_extract_flags(req, flags);
@@ -693,10 +757,8 @@ cb_Backend_document_upsert(VALUE self,
693
757
  return cb_create_mutation_result(resp);
694
758
 
695
759
  } catch (const std::system_error& se) {
696
- rb_exc_raise(cb_map_error_code(
760
+ throw ruby_exception(cb_map_error_code(
697
761
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
698
- } catch (const ruby_exception& e) {
699
- rb_exc_raise(e.exception_object());
700
762
  }
701
763
  return Qnil;
702
764
  }
@@ -713,13 +775,13 @@ cb_Backend_document_append(VALUE self,
713
775
  {
714
776
  auto cluster = cb_backend_to_core_api_cluster(self);
715
777
 
716
- Check_Type(bucket, T_STRING);
717
- Check_Type(scope, T_STRING);
718
- Check_Type(collection, T_STRING);
719
- Check_Type(id, T_STRING);
720
- Check_Type(content, T_STRING);
778
+ cb_check_type(bucket, T_STRING);
779
+ cb_check_type(scope, T_STRING);
780
+ cb_check_type(collection, T_STRING);
781
+ cb_check_type(id, T_STRING);
782
+ cb_check_type(content, T_STRING);
721
783
  if (!NIL_P(options)) {
722
- Check_Type(options, T_HASH);
784
+ cb_check_type(options, T_HASH);
723
785
  }
724
786
 
725
787
  try {
@@ -730,6 +792,13 @@ cb_Backend_document_append(VALUE self,
730
792
  cb_string_new(collection),
731
793
  cb_string_new(id),
732
794
  },
795
+ {},
796
+ {},
797
+ {},
798
+ {},
799
+ couchbase::durability_level::none,
800
+ {},
801
+ { cb_extract_retry_strategy(options) },
733
802
  };
734
803
  cb_extract_content(req, content);
735
804
  cb_extract_timeout(req, options);
@@ -767,10 +836,8 @@ cb_Backend_document_append(VALUE self,
767
836
  return cb_create_mutation_result(resp);
768
837
 
769
838
  } catch (const std::system_error& se) {
770
- rb_exc_raise(cb_map_error_code(
839
+ throw ruby_exception(cb_map_error_code(
771
840
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
772
- } catch (const ruby_exception& e) {
773
- rb_exc_raise(e.exception_object());
774
841
  }
775
842
  return Qnil;
776
843
  }
@@ -787,13 +854,13 @@ cb_Backend_document_prepend(VALUE self,
787
854
  {
788
855
  auto cluster = cb_backend_to_core_api_cluster(self);
789
856
 
790
- Check_Type(bucket, T_STRING);
791
- Check_Type(scope, T_STRING);
792
- Check_Type(collection, T_STRING);
793
- Check_Type(id, T_STRING);
794
- Check_Type(content, T_STRING);
857
+ cb_check_type(bucket, T_STRING);
858
+ cb_check_type(scope, T_STRING);
859
+ cb_check_type(collection, T_STRING);
860
+ cb_check_type(id, T_STRING);
861
+ cb_check_type(content, T_STRING);
795
862
  if (!NIL_P(options)) {
796
- Check_Type(options, T_HASH);
863
+ cb_check_type(options, T_HASH);
797
864
  }
798
865
 
799
866
  try {
@@ -804,6 +871,13 @@ cb_Backend_document_prepend(VALUE self,
804
871
  cb_string_new(collection),
805
872
  cb_string_new(id),
806
873
  },
874
+ {},
875
+ {},
876
+ {},
877
+ {},
878
+ couchbase::durability_level::none,
879
+ {},
880
+ { cb_extract_retry_strategy(options) },
807
881
  };
808
882
  cb_extract_content(req, content);
809
883
  cb_extract_timeout(req, options);
@@ -840,10 +914,8 @@ cb_Backend_document_prepend(VALUE self,
840
914
 
841
915
  return cb_create_mutation_result(resp);
842
916
  } catch (const std::system_error& se) {
843
- rb_exc_raise(cb_map_error_code(
917
+ throw ruby_exception(cb_map_error_code(
844
918
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
845
- } catch (const ruby_exception& e) {
846
- rb_exc_raise(e.exception_object());
847
919
  }
848
920
  return Qnil;
849
921
  }
@@ -861,14 +933,14 @@ cb_Backend_document_replace(VALUE self,
861
933
  {
862
934
  auto cluster = cb_backend_to_core_api_cluster(self);
863
935
 
864
- Check_Type(bucket, T_STRING);
865
- Check_Type(scope, T_STRING);
866
- Check_Type(collection, T_STRING);
867
- Check_Type(id, T_STRING);
868
- Check_Type(content, T_STRING);
869
- Check_Type(flags, T_FIXNUM);
936
+ cb_check_type(bucket, T_STRING);
937
+ cb_check_type(scope, T_STRING);
938
+ cb_check_type(collection, T_STRING);
939
+ cb_check_type(id, T_STRING);
940
+ cb_check_type(content, T_STRING);
941
+ cb_check_type(flags, T_FIXNUM);
870
942
  if (!NIL_P(options)) {
871
- Check_Type(options, T_HASH);
943
+ cb_check_type(options, T_HASH);
872
944
  }
873
945
 
874
946
  try {
@@ -879,6 +951,15 @@ cb_Backend_document_replace(VALUE self,
879
951
  cb_string_new(collection),
880
952
  cb_string_new(id),
881
953
  },
954
+ {},
955
+ {},
956
+ {},
957
+ 0,
958
+ 0,
959
+ {},
960
+ couchbase::durability_level::none,
961
+ {},
962
+ { cb_extract_retry_strategy(options) },
882
963
  };
883
964
  cb_extract_content(req, content);
884
965
  cb_extract_flags(req, flags);
@@ -918,10 +999,8 @@ cb_Backend_document_replace(VALUE self,
918
999
  return cb_create_mutation_result(resp);
919
1000
 
920
1001
  } catch (const std::system_error& se) {
921
- rb_exc_raise(cb_map_error_code(
1002
+ throw ruby_exception(cb_map_error_code(
922
1003
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
923
- } catch (const ruby_exception& e) {
924
- rb_exc_raise(e.exception_object());
925
1004
  }
926
1005
  return Qnil;
927
1006
  }
@@ -939,14 +1018,14 @@ cb_Backend_document_insert(VALUE self,
939
1018
  {
940
1019
  auto cluster = cb_backend_to_core_api_cluster(self);
941
1020
 
942
- Check_Type(bucket, T_STRING);
943
- Check_Type(scope, T_STRING);
944
- Check_Type(collection, T_STRING);
945
- Check_Type(id, T_STRING);
946
- Check_Type(content, T_STRING);
947
- Check_Type(flags, T_FIXNUM);
1021
+ cb_check_type(bucket, T_STRING);
1022
+ cb_check_type(scope, T_STRING);
1023
+ cb_check_type(collection, T_STRING);
1024
+ cb_check_type(id, T_STRING);
1025
+ cb_check_type(content, T_STRING);
1026
+ cb_check_type(flags, T_FIXNUM);
948
1027
  if (!NIL_P(options)) {
949
- Check_Type(options, T_HASH);
1028
+ cb_check_type(options, T_HASH);
950
1029
  }
951
1030
 
952
1031
  try {
@@ -957,6 +1036,14 @@ cb_Backend_document_insert(VALUE self,
957
1036
  cb_string_new(collection),
958
1037
  cb_string_new(id),
959
1038
  },
1039
+ {},
1040
+ {},
1041
+ {},
1042
+ 0,
1043
+ 0,
1044
+ couchbase::durability_level::none,
1045
+ {},
1046
+ { cb_extract_retry_strategy(options) },
960
1047
  };
961
1048
  cb_extract_content(req, content);
962
1049
  cb_extract_flags(req, flags);
@@ -993,10 +1080,8 @@ cb_Backend_document_insert(VALUE self,
993
1080
  return cb_create_mutation_result(resp);
994
1081
 
995
1082
  } catch (const std::system_error& se) {
996
- rb_exc_raise(cb_map_error_code(
1083
+ throw ruby_exception(cb_map_error_code(
997
1084
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
998
- } catch (const ruby_exception& e) {
999
- rb_exc_raise(e.exception_object());
1000
1085
  }
1001
1086
  return Qnil;
1002
1087
  }
@@ -1012,12 +1097,12 @@ cb_Backend_document_remove(VALUE self,
1012
1097
  {
1013
1098
  auto cluster = cb_backend_to_core_api_cluster(self);
1014
1099
 
1015
- Check_Type(bucket, T_STRING);
1016
- Check_Type(scope, T_STRING);
1017
- Check_Type(collection, T_STRING);
1018
- Check_Type(id, T_STRING);
1100
+ cb_check_type(bucket, T_STRING);
1101
+ cb_check_type(scope, T_STRING);
1102
+ cb_check_type(collection, T_STRING);
1103
+ cb_check_type(id, T_STRING);
1019
1104
  if (!NIL_P(options)) {
1020
- Check_Type(options, T_HASH);
1105
+ cb_check_type(options, T_HASH);
1021
1106
  }
1022
1107
 
1023
1108
  try {
@@ -1028,6 +1113,12 @@ cb_Backend_document_remove(VALUE self,
1028
1113
  cb_string_new(collection),
1029
1114
  cb_string_new(id),
1030
1115
  },
1116
+ {},
1117
+ {},
1118
+ {},
1119
+ couchbase::durability_level::none,
1120
+ {},
1121
+ { cb_extract_retry_strategy(options) },
1031
1122
  };
1032
1123
  cb_extract_timeout(req, options);
1033
1124
  cb_extract_durability_level(req, options);
@@ -1062,10 +1153,8 @@ cb_Backend_document_remove(VALUE self,
1062
1153
  }
1063
1154
  return cb_create_mutation_result(resp);
1064
1155
  } catch (const std::system_error& se) {
1065
- rb_exc_raise(cb_map_error_code(
1156
+ throw ruby_exception(cb_map_error_code(
1066
1157
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1067
- } catch (const ruby_exception& e) {
1068
- rb_exc_raise(e.exception_object());
1069
1158
  }
1070
1159
  return Qnil;
1071
1160
  }
@@ -1081,12 +1170,12 @@ cb_Backend_document_increment(VALUE self,
1081
1170
  {
1082
1171
  auto cluster = cb_backend_to_core_api_cluster(self);
1083
1172
 
1084
- Check_Type(bucket, T_STRING);
1085
- Check_Type(scope, T_STRING);
1086
- Check_Type(collection, T_STRING);
1087
- Check_Type(id, T_STRING);
1173
+ cb_check_type(bucket, T_STRING);
1174
+ cb_check_type(scope, T_STRING);
1175
+ cb_check_type(collection, T_STRING);
1176
+ cb_check_type(id, T_STRING);
1088
1177
  if (!NIL_P(options)) {
1089
- Check_Type(options, T_HASH);
1178
+ cb_check_type(options, T_HASH);
1090
1179
  }
1091
1180
 
1092
1181
  try {
@@ -1097,6 +1186,14 @@ cb_Backend_document_increment(VALUE self,
1097
1186
  cb_string_new(collection),
1098
1187
  cb_string_new(id),
1099
1188
  },
1189
+ {},
1190
+ {},
1191
+ 0,
1192
+ 1,
1193
+ {},
1194
+ couchbase::durability_level::none,
1195
+ {},
1196
+ { cb_extract_retry_strategy(options) },
1100
1197
  };
1101
1198
 
1102
1199
  cb_extract_timeout(req, options);
@@ -1138,10 +1235,8 @@ cb_Backend_document_increment(VALUE self,
1138
1235
  return res;
1139
1236
 
1140
1237
  } catch (const std::system_error& se) {
1141
- rb_exc_raise(cb_map_error_code(
1238
+ throw ruby_exception(cb_map_error_code(
1142
1239
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1143
- } catch (const ruby_exception& e) {
1144
- rb_exc_raise(e.exception_object());
1145
1240
  }
1146
1241
  return Qnil;
1147
1242
  }
@@ -1157,12 +1252,12 @@ cb_Backend_document_decrement(VALUE self,
1157
1252
  {
1158
1253
  auto cluster = cb_backend_to_core_api_cluster(self);
1159
1254
 
1160
- Check_Type(bucket, T_STRING);
1161
- Check_Type(scope, T_STRING);
1162
- Check_Type(collection, T_STRING);
1163
- Check_Type(id, T_STRING);
1255
+ cb_check_type(bucket, T_STRING);
1256
+ cb_check_type(scope, T_STRING);
1257
+ cb_check_type(collection, T_STRING);
1258
+ cb_check_type(id, T_STRING);
1164
1259
  if (!NIL_P(options)) {
1165
- Check_Type(options, T_HASH);
1260
+ cb_check_type(options, T_HASH);
1166
1261
  }
1167
1262
 
1168
1263
  try {
@@ -1173,6 +1268,14 @@ cb_Backend_document_decrement(VALUE self,
1173
1268
  cb_string_new(collection),
1174
1269
  cb_string_new(id),
1175
1270
  },
1271
+ {},
1272
+ {},
1273
+ 0,
1274
+ 1,
1275
+ {},
1276
+ couchbase::durability_level::none,
1277
+ {},
1278
+ { cb_extract_retry_strategy(options) },
1176
1279
  };
1177
1280
 
1178
1281
  cb_extract_timeout(req, options);
@@ -1214,10 +1317,8 @@ cb_Backend_document_decrement(VALUE self,
1214
1317
  return res;
1215
1318
 
1216
1319
  } catch (const std::system_error& se) {
1217
- rb_exc_raise(cb_map_error_code(
1320
+ throw ruby_exception(cb_map_error_code(
1218
1321
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1219
- } catch (const ruby_exception& e) {
1220
- rb_exc_raise(e.exception_object());
1221
1322
  }
1222
1323
  return Qnil;
1223
1324
  }
@@ -1234,17 +1335,16 @@ cb_Backend_document_lookup_in(VALUE self,
1234
1335
  {
1235
1336
  auto cluster = cb_backend_to_core_api_cluster(self);
1236
1337
 
1237
- Check_Type(bucket, T_STRING);
1238
- Check_Type(scope, T_STRING);
1239
- Check_Type(collection, T_STRING);
1240
- Check_Type(id, T_STRING);
1241
- Check_Type(specs, T_ARRAY);
1338
+ cb_check_type(bucket, T_STRING);
1339
+ cb_check_type(scope, T_STRING);
1340
+ cb_check_type(collection, T_STRING);
1341
+ cb_check_type(id, T_STRING);
1342
+ cb_check_type(specs, T_ARRAY);
1242
1343
  if (RARRAY_LEN(specs) <= 0) {
1243
- rb_raise(rb_eArgError, "Array with specs cannot be empty");
1244
- return Qnil;
1344
+ throw ruby_exception(rb_eArgError, "Array with specs cannot be empty");
1245
1345
  }
1246
1346
  if (!NIL_P(options)) {
1247
- Check_Type(options, T_HASH);
1347
+ cb_check_type(options, T_HASH);
1248
1348
  }
1249
1349
 
1250
1350
  try {
@@ -1255,7 +1355,8 @@ cb_Backend_document_lookup_in(VALUE self,
1255
1355
  cb_string_new(id),
1256
1356
  };
1257
1357
 
1258
- core::operations::lookup_in_request req{ doc_id };
1358
+ auto retry_strategy = cb_extract_retry_strategy(options);
1359
+ core::operations::lookup_in_request req{ doc_id, {}, {}, false, {}, {}, { retry_strategy } };
1259
1360
  cb_extract_timeout(req, options);
1260
1361
  cb_extract_option_bool(req.access_deleted, options, "access_deleted");
1261
1362
 
@@ -1284,7 +1385,7 @@ cb_Backend_document_lookup_in(VALUE self,
1284
1385
  } else {
1285
1386
  throw ruby_exception(
1286
1387
  exc_invalid_argument(),
1287
- rb_sprintf("unsupported operation for subdocument lookup: %+" PRIsVALUE, operation));
1388
+ cb_sprintf("unsupported operation for subdocument lookup: %+" PRIsVALUE, operation));
1288
1389
  }
1289
1390
  cb_check_type(path, T_STRING);
1290
1391
 
@@ -1344,10 +1445,8 @@ cb_Backend_document_lookup_in(VALUE self,
1344
1445
  }
1345
1446
  return res;
1346
1447
  } catch (const std::system_error& se) {
1347
- rb_exc_raise(cb_map_error_code(
1448
+ throw ruby_exception(cb_map_error_code(
1348
1449
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1349
- } catch (const ruby_exception& e) {
1350
- rb_exc_raise(e.exception_object());
1351
1450
  }
1352
1451
  return Qnil;
1353
1452
  }
@@ -1365,17 +1464,16 @@ cb_Backend_document_lookup_in_any_replica(VALUE self,
1365
1464
 
1366
1465
  auto cluster = cb_backend_to_core_api_cluster(self);
1367
1466
 
1368
- Check_Type(bucket, T_STRING);
1369
- Check_Type(scope, T_STRING);
1370
- Check_Type(collection, T_STRING);
1371
- Check_Type(id, T_STRING);
1372
- Check_Type(specs, T_ARRAY);
1467
+ cb_check_type(bucket, T_STRING);
1468
+ cb_check_type(scope, T_STRING);
1469
+ cb_check_type(collection, T_STRING);
1470
+ cb_check_type(id, T_STRING);
1471
+ cb_check_type(specs, T_ARRAY);
1373
1472
  if (RARRAY_LEN(specs) <= 0) {
1374
- rb_raise(rb_eArgError, "Array with specs cannot be empty");
1375
- return Qnil;
1473
+ throw ruby_exception(rb_eArgError, "Array with specs cannot be empty");
1376
1474
  }
1377
1475
  if (!NIL_P(options)) {
1378
- Check_Type(options, T_HASH);
1476
+ cb_check_type(options, T_HASH);
1379
1477
  }
1380
1478
 
1381
1479
  try {
@@ -1415,7 +1513,7 @@ cb_Backend_document_lookup_in_any_replica(VALUE self,
1415
1513
  } else {
1416
1514
  throw ruby_exception(
1417
1515
  exc_invalid_argument(),
1418
- rb_sprintf("unsupported operation for subdocument lookup: %+" PRIsVALUE, operation));
1516
+ cb_sprintf("unsupported operation for subdocument lookup: %+" PRIsVALUE, operation));
1419
1517
  }
1420
1518
  cb_check_type(path, T_STRING);
1421
1519
  req.specs.emplace_back(core::impl::subdoc::command{
@@ -1477,10 +1575,8 @@ cb_Backend_document_lookup_in_any_replica(VALUE self,
1477
1575
 
1478
1576
  return res;
1479
1577
  } catch (const std::system_error& se) {
1480
- rb_exc_raise(cb_map_error_code(
1578
+ throw ruby_exception(cb_map_error_code(
1481
1579
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1482
- } catch (const ruby_exception& e) {
1483
- rb_exc_raise(e.exception_object());
1484
1580
  }
1485
1581
  return Qnil;
1486
1582
  }
@@ -1497,17 +1593,16 @@ cb_Backend_document_lookup_in_all_replicas(VALUE self,
1497
1593
  {
1498
1594
  auto cluster = cb_backend_to_core_api_cluster(self);
1499
1595
 
1500
- Check_Type(bucket, T_STRING);
1501
- Check_Type(scope, T_STRING);
1502
- Check_Type(collection, T_STRING);
1503
- Check_Type(id, T_STRING);
1504
- Check_Type(specs, T_ARRAY);
1596
+ cb_check_type(bucket, T_STRING);
1597
+ cb_check_type(scope, T_STRING);
1598
+ cb_check_type(collection, T_STRING);
1599
+ cb_check_type(id, T_STRING);
1600
+ cb_check_type(specs, T_ARRAY);
1505
1601
  if (RARRAY_LEN(specs) <= 0) {
1506
- rb_raise(rb_eArgError, "Array with specs cannot be empty");
1507
- return Qnil;
1602
+ throw ruby_exception(rb_eArgError, "Array with specs cannot be empty");
1508
1603
  }
1509
1604
  if (!NIL_P(options)) {
1510
- Check_Type(options, T_HASH);
1605
+ cb_check_type(options, T_HASH);
1511
1606
  }
1512
1607
 
1513
1608
  try {
@@ -1548,7 +1643,7 @@ cb_Backend_document_lookup_in_all_replicas(VALUE self,
1548
1643
  } else {
1549
1644
  throw ruby_exception(
1550
1645
  exc_invalid_argument(),
1551
- rb_sprintf("unsupported operation for subdocument lookup: %+" PRIsVALUE, operation));
1646
+ cb_sprintf("unsupported operation for subdocument lookup: %+" PRIsVALUE, operation));
1552
1647
  }
1553
1648
  cb_check_type(path, T_STRING);
1554
1649
 
@@ -1620,10 +1715,8 @@ cb_Backend_document_lookup_in_all_replicas(VALUE self,
1620
1715
 
1621
1716
  return res;
1622
1717
  } catch (const std::system_error& se) {
1623
- rb_exc_raise(cb_map_error_code(
1718
+ throw ruby_exception(cb_map_error_code(
1624
1719
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1625
- } catch (const ruby_exception& e) {
1626
- rb_exc_raise(e.exception_object());
1627
1720
  }
1628
1721
  return Qnil;
1629
1722
  }
@@ -1640,18 +1733,17 @@ cb_Backend_document_mutate_in(VALUE self,
1640
1733
  {
1641
1734
  auto cluster = cb_backend_to_core_api_cluster(self);
1642
1735
 
1643
- Check_Type(bucket, T_STRING);
1644
- Check_Type(scope, T_STRING);
1645
- Check_Type(collection, T_STRING);
1646
- Check_Type(id, T_STRING);
1736
+ cb_check_type(bucket, T_STRING);
1737
+ cb_check_type(scope, T_STRING);
1738
+ cb_check_type(collection, T_STRING);
1739
+ cb_check_type(id, T_STRING);
1647
1740
 
1648
- Check_Type(specs, T_ARRAY);
1741
+ cb_check_type(specs, T_ARRAY);
1649
1742
  if (RARRAY_LEN(specs) <= 0) {
1650
- rb_raise(rb_eArgError, "Array with specs cannot be empty");
1651
- return Qnil;
1743
+ throw ruby_exception(rb_eArgError, "Array with specs cannot be empty");
1652
1744
  }
1653
1745
  if (!NIL_P(options)) {
1654
- Check_Type(options, T_HASH);
1746
+ cb_check_type(options, T_HASH);
1655
1747
  }
1656
1748
 
1657
1749
  try {
@@ -1662,6 +1754,18 @@ cb_Backend_document_mutate_in(VALUE self,
1662
1754
  cb_string_new(collection),
1663
1755
  cb_string_new(id),
1664
1756
  },
1757
+ {},
1758
+ {},
1759
+ {},
1760
+ false,
1761
+ false,
1762
+ false,
1763
+ {},
1764
+ couchbase::store_semantics::replace,
1765
+ {},
1766
+ couchbase::durability_level::none,
1767
+ {},
1768
+ { cb_extract_retry_strategy(options) },
1665
1769
  };
1666
1770
  cb_extract_timeout(req, options);
1667
1771
  cb_extract_durability_level(req, options);
@@ -1739,7 +1843,7 @@ cb_Backend_document_mutate_in(VALUE self,
1739
1843
  .create_path(create_path));
1740
1844
  } else if (operation_id == rb_intern("counter")) {
1741
1845
  if (TYPE(param) == T_FIXNUM || TYPE(param) == T_BIGNUM) {
1742
- if (std::int64_t num = NUM2LL(param); num < 0) {
1846
+ if (std::int64_t num = cb_num2ll(param); num < 0) {
1743
1847
  cxx_specs.push_back(
1744
1848
  couchbase::mutate_in_specs::decrement(cb_string_new(path), -1 * num)
1745
1849
  .xattr(xattr)
@@ -1752,7 +1856,7 @@ cb_Backend_document_mutate_in(VALUE self,
1752
1856
  } else {
1753
1857
  throw ruby_exception(
1754
1858
  exc_invalid_argument(),
1755
- rb_sprintf("subdocument counter operation expects number, but given: %+" PRIsVALUE,
1859
+ cb_sprintf("subdocument counter operation expects number, but given: %+" PRIsVALUE,
1756
1860
  param));
1757
1861
  }
1758
1862
  } else if (operation_id == rb_intern("set_doc")) {
@@ -1765,7 +1869,7 @@ cb_Backend_document_mutate_in(VALUE self,
1765
1869
  } else {
1766
1870
  throw ruby_exception(
1767
1871
  exc_invalid_argument(),
1768
- rb_sprintf("unsupported operation for subdocument mutation: %+" PRIsVALUE, operation));
1872
+ cb_sprintf("unsupported operation for subdocument mutation: %+" PRIsVALUE, operation));
1769
1873
  }
1770
1874
  }
1771
1875
  }
@@ -1822,10 +1926,8 @@ cb_Backend_document_mutate_in(VALUE self,
1822
1926
  return res;
1823
1927
 
1824
1928
  } catch (const std::system_error& se) {
1825
- rb_exc_raise(cb_map_error_code(
1929
+ throw ruby_exception(cb_map_error_code(
1826
1930
  se.code(), fmt::format("failed to perform {}: {}", __func__, se.what()), false));
1827
- } catch (const ruby_exception& e) {
1828
- rb_exc_raise(e.exception_object());
1829
1931
  }
1830
1932
  return Qnil;
1831
1933
  }
@@ -1835,28 +1937,47 @@ cb_Backend_document_mutate_in(VALUE self,
1835
1937
  void
1836
1938
  init_crud(VALUE cBackend)
1837
1939
  {
1838
- rb_define_method(cBackend, "document_get", cb_Backend_document_get, 6);
1839
- rb_define_method(cBackend, "document_get_any_replica", cb_Backend_document_get_any_replica, 6);
1840
- rb_define_method(cBackend, "document_get_all_replicas", cb_Backend_document_get_all_replicas, 6);
1841
- rb_define_method(cBackend, "document_get_projected", cb_Backend_document_get_projected, 6);
1842
- rb_define_method(cBackend, "document_get_and_lock", cb_Backend_document_get_and_lock, 7);
1843
- rb_define_method(cBackend, "document_get_and_touch", cb_Backend_document_get_and_touch, 7);
1844
- rb_define_method(cBackend, "document_insert", cb_Backend_document_insert, 8);
1845
- rb_define_method(cBackend, "document_replace", cb_Backend_document_replace, 8);
1846
- rb_define_method(cBackend, "document_upsert", cb_Backend_document_upsert, 8);
1847
- rb_define_method(cBackend, "document_append", cb_Backend_document_append, 7);
1848
- rb_define_method(cBackend, "document_prepend", cb_Backend_document_prepend, 7);
1849
- rb_define_method(cBackend, "document_remove", cb_Backend_document_remove, 6);
1850
- rb_define_method(cBackend, "document_lookup_in", cb_Backend_document_lookup_in, 7);
1940
+ rb_define_method(cBackend, "document_get", cb_method<cb_Backend_document_get>::invoke, 6);
1941
+ rb_define_method(cBackend,
1942
+ "document_get_any_replica",
1943
+ cb_method<cb_Backend_document_get_any_replica>::invoke,
1944
+ 6);
1945
+ rb_define_method(cBackend,
1946
+ "document_get_all_replicas",
1947
+ cb_method<cb_Backend_document_get_all_replicas>::invoke,
1948
+ 6);
1949
+ rb_define_method(
1950
+ cBackend, "document_get_replica", cb_method<cb_Backend_document_get_replica>::invoke, 7);
1951
+ rb_define_method(
1952
+ cBackend, "document_get_projected", cb_method<cb_Backend_document_get_projected>::invoke, 6);
1953
+ rb_define_method(
1954
+ cBackend, "document_get_and_lock", cb_method<cb_Backend_document_get_and_lock>::invoke, 7);
1955
+ rb_define_method(
1956
+ cBackend, "document_get_and_touch", cb_method<cb_Backend_document_get_and_touch>::invoke, 7);
1957
+ rb_define_method(cBackend, "document_insert", cb_method<cb_Backend_document_insert>::invoke, 8);
1958
+ rb_define_method(cBackend, "document_replace", cb_method<cb_Backend_document_replace>::invoke, 8);
1959
+ rb_define_method(cBackend, "document_upsert", cb_method<cb_Backend_document_upsert>::invoke, 8);
1960
+ rb_define_method(cBackend, "document_append", cb_method<cb_Backend_document_append>::invoke, 7);
1961
+ rb_define_method(cBackend, "document_prepend", cb_method<cb_Backend_document_prepend>::invoke, 7);
1962
+ rb_define_method(cBackend, "document_remove", cb_method<cb_Backend_document_remove>::invoke, 6);
1963
+ rb_define_method(
1964
+ cBackend, "document_lookup_in", cb_method<cb_Backend_document_lookup_in>::invoke, 7);
1965
+ rb_define_method(cBackend,
1966
+ "document_lookup_in_any_replica",
1967
+ cb_method<cb_Backend_document_lookup_in_any_replica>::invoke,
1968
+ 7);
1969
+ rb_define_method(cBackend,
1970
+ "document_lookup_in_all_replicas",
1971
+ cb_method<cb_Backend_document_lookup_in_all_replicas>::invoke,
1972
+ 7);
1973
+ rb_define_method(
1974
+ cBackend, "document_mutate_in", cb_method<cb_Backend_document_mutate_in>::invoke, 7);
1975
+ rb_define_method(cBackend, "document_touch", cb_method<cb_Backend_document_touch>::invoke, 7);
1976
+ rb_define_method(cBackend, "document_exists", cb_method<cb_Backend_document_exists>::invoke, 6);
1977
+ rb_define_method(cBackend, "document_unlock", cb_method<cb_Backend_document_unlock>::invoke, 7);
1851
1978
  rb_define_method(
1852
- cBackend, "document_lookup_in_any_replica", cb_Backend_document_lookup_in_any_replica, 7);
1979
+ cBackend, "document_increment", cb_method<cb_Backend_document_increment>::invoke, 6);
1853
1980
  rb_define_method(
1854
- cBackend, "document_lookup_in_all_replicas", cb_Backend_document_lookup_in_all_replicas, 7);
1855
- rb_define_method(cBackend, "document_mutate_in", cb_Backend_document_mutate_in, 7);
1856
- rb_define_method(cBackend, "document_touch", cb_Backend_document_touch, 7);
1857
- rb_define_method(cBackend, "document_exists", cb_Backend_document_exists, 6);
1858
- rb_define_method(cBackend, "document_unlock", cb_Backend_document_unlock, 7);
1859
- rb_define_method(cBackend, "document_increment", cb_Backend_document_increment, 6);
1860
- rb_define_method(cBackend, "document_decrement", cb_Backend_document_decrement, 6);
1981
+ cBackend, "document_decrement", cb_method<cb_Backend_document_decrement>::invoke, 6);
1861
1982
  }
1862
1983
  } // namespace couchbase::ruby