couchbase 3.1.1-universal-darwin-20 → 3.2.0-universal-darwin-20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/CMakeLists.txt +3 -1
  4. data/ext/build_version.hxx.in +1 -1
  5. data/ext/cmake/Testing.cmake +1 -0
  6. data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
  7. data/ext/cmake/VersionInfo.cmake +3 -0
  8. data/ext/couchbase/bucket.hxx +47 -28
  9. data/ext/couchbase/cbsasl/client.h +1 -1
  10. data/ext/couchbase/cbsasl/context.cc +1 -1
  11. data/ext/couchbase/cbsasl/context.h +3 -3
  12. data/ext/couchbase/cbsasl/mechanism.cc +5 -8
  13. data/ext/couchbase/cbsasl/mechanism.h +1 -4
  14. data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
  15. data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
  16. data/ext/couchbase/cluster.hxx +40 -22
  17. data/ext/couchbase/cluster_options.hxx +7 -1
  18. data/ext/couchbase/configuration.hxx +37 -16
  19. data/ext/couchbase/couchbase.cxx +1145 -291
  20. data/ext/couchbase/error_map.hxx +1 -1
  21. data/ext/couchbase/errors.hxx +25 -17
  22. data/ext/couchbase/io/dns_client.hxx +3 -3
  23. data/ext/couchbase/io/dns_codec.hxx +4 -5
  24. data/ext/couchbase/io/dns_config.hxx +5 -6
  25. data/ext/couchbase/io/dns_message.hxx +3 -3
  26. data/ext/couchbase/io/http_command.hxx +70 -35
  27. data/ext/couchbase/io/http_session.hxx +4 -3
  28. data/ext/couchbase/io/http_session_manager.hxx +28 -19
  29. data/ext/couchbase/io/mcbp_command.hxx +51 -19
  30. data/ext/couchbase/io/mcbp_context.hxx +1 -1
  31. data/ext/couchbase/io/mcbp_parser.hxx +4 -4
  32. data/ext/couchbase/io/mcbp_session.hxx +91 -101
  33. data/ext/couchbase/io/query_cache.hxx +2 -2
  34. data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
  35. data/ext/couchbase/io/retry_reason.hxx +2 -2
  36. data/ext/couchbase/io/retry_strategy.hxx +1 -6
  37. data/ext/couchbase/io/streams.hxx +7 -7
  38. data/ext/couchbase/metrics/logging_meter.hxx +228 -0
  39. data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
  40. data/ext/couchbase/metrics/meter.hxx +49 -0
  41. data/ext/couchbase/metrics/noop_meter.hxx +43 -0
  42. data/ext/couchbase/operations.hxx +4 -0
  43. data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
  44. data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
  45. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
  46. data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
  47. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
  48. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
  49. data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
  50. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
  51. data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
  52. data/ext/couchbase/operations/analytics_link.hxx +39 -0
  53. data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
  54. data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
  55. data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
  56. data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
  57. data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
  58. data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
  59. data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
  60. data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
  61. data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
  62. data/ext/couchbase/operations/bucket_create.hxx +8 -8
  63. data/ext/couchbase/operations/bucket_drop.hxx +5 -5
  64. data/ext/couchbase/operations/bucket_flush.hxx +5 -5
  65. data/ext/couchbase/operations/bucket_get.hxx +7 -7
  66. data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
  67. data/ext/couchbase/operations/bucket_settings.hxx +40 -49
  68. data/ext/couchbase/operations/bucket_update.hxx +8 -8
  69. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
  70. data/ext/couchbase/operations/collection_create.hxx +11 -11
  71. data/ext/couchbase/operations/collection_drop.hxx +12 -10
  72. data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
  73. data/ext/couchbase/operations/design_document.hxx +2 -2
  74. data/ext/couchbase/operations/document_analytics.hxx +29 -36
  75. data/ext/couchbase/operations/document_append.hxx +3 -3
  76. data/ext/couchbase/operations/document_decrement.hxx +3 -3
  77. data/ext/couchbase/operations/document_exists.hxx +2 -2
  78. data/ext/couchbase/operations/document_get.hxx +3 -3
  79. data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
  80. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
  81. data/ext/couchbase/operations/document_get_projected.hxx +10 -11
  82. data/ext/couchbase/operations/document_increment.hxx +3 -3
  83. data/ext/couchbase/operations/document_insert.hxx +3 -3
  84. data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
  85. data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
  86. data/ext/couchbase/operations/document_prepend.hxx +3 -3
  87. data/ext/couchbase/operations/document_query.hxx +39 -41
  88. data/ext/couchbase/operations/document_remove.hxx +3 -3
  89. data/ext/couchbase/operations/document_replace.hxx +3 -3
  90. data/ext/couchbase/operations/document_search.hxx +56 -61
  91. data/ext/couchbase/operations/document_touch.hxx +3 -3
  92. data/ext/couchbase/operations/document_unlock.hxx +3 -3
  93. data/ext/couchbase/operations/document_upsert.hxx +3 -3
  94. data/ext/couchbase/operations/document_view.hxx +23 -23
  95. data/ext/couchbase/operations/group_drop.hxx +5 -5
  96. data/ext/couchbase/operations/group_get.hxx +7 -7
  97. data/ext/couchbase/operations/group_get_all.hxx +6 -6
  98. data/ext/couchbase/operations/group_upsert.hxx +11 -11
  99. data/ext/couchbase/operations/http_noop.hxx +6 -6
  100. data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
  101. data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
  102. data/ext/couchbase/operations/query_index_create.hxx +10 -8
  103. data/ext/couchbase/operations/query_index_drop.hxx +8 -8
  104. data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
  105. data/ext/couchbase/operations/rbac.hxx +40 -63
  106. data/ext/couchbase/operations/role_get_all.hxx +6 -6
  107. data/ext/couchbase/operations/scope_create.hxx +10 -10
  108. data/ext/couchbase/operations/scope_drop.hxx +9 -9
  109. data/ext/couchbase/operations/scope_get_all.hxx +8 -8
  110. data/ext/couchbase/operations/search_get_stats.hxx +5 -3
  111. data/ext/couchbase/operations/search_index.hxx +6 -15
  112. data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
  113. data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
  114. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
  115. data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
  116. data/ext/couchbase/operations/search_index_drop.hxx +11 -9
  117. data/ext/couchbase/operations/search_index_get.hxx +11 -9
  118. data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
  119. data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
  120. data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
  121. data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
  122. data/ext/couchbase/operations/user_drop.hxx +5 -5
  123. data/ext/couchbase/operations/user_get.hxx +7 -7
  124. data/ext/couchbase/operations/user_get_all.hxx +6 -6
  125. data/ext/couchbase/operations/user_upsert.hxx +9 -9
  126. data/ext/couchbase/operations/view_index_drop.hxx +10 -10
  127. data/ext/couchbase/operations/view_index_get.hxx +13 -15
  128. data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
  129. data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
  130. data/ext/couchbase/origin.hxx +14 -10
  131. data/ext/couchbase/platform/backtrace.c +1 -1
  132. data/ext/couchbase/platform/base64.cc +5 -5
  133. data/ext/couchbase/platform/base64.h +2 -5
  134. data/ext/couchbase/protocol/client_opcode.hxx +7 -4
  135. data/ext/couchbase/protocol/client_request.hxx +2 -2
  136. data/ext/couchbase/protocol/client_response.hxx +41 -16
  137. data/ext/couchbase/protocol/cmd_append.hxx +17 -16
  138. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
  139. data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
  140. data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
  141. data/ext/couchbase/protocol/cmd_get.hxx +11 -14
  142. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
  143. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
  144. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
  145. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
  146. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
  147. data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
  148. data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
  149. data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
  150. data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
  151. data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
  152. data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
  153. data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
  154. data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
  155. data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
  156. data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
  157. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
  158. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
  159. data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
  160. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
  161. data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
  162. data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
  163. data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
  164. data/ext/couchbase/protocol/datatype.hxx +3 -3
  165. data/ext/couchbase/protocol/durability_level.hxx +2 -2
  166. data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
  167. data/ext/couchbase/protocol/hello_feature.hxx +2 -2
  168. data/ext/couchbase/protocol/magic.hxx +2 -2
  169. data/ext/couchbase/protocol/server_opcode.hxx +2 -2
  170. data/ext/couchbase/protocol/server_request.hxx +1 -1
  171. data/ext/couchbase/protocol/status.hxx +4 -7
  172. data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
  173. data/ext/couchbase/service_type.hxx +4 -4
  174. data/ext/couchbase/tracing/constants.hxx +261 -0
  175. data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
  176. data/ext/couchbase/tracing/request_tracer.hxx +77 -0
  177. data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
  178. data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
  179. data/ext/couchbase/utils/byteswap.hxx +1 -1
  180. data/ext/couchbase/utils/connection_string.hxx +21 -1
  181. data/ext/couchbase/utils/name_codec.hxx +41 -0
  182. data/ext/couchbase/utils/url_codec.hxx +236 -0
  183. data/ext/couchbase/version.hxx +1 -1
  184. data/ext/test/CMakeLists.txt +1 -0
  185. data/ext/test/test_native_trivial_query.cxx +60 -0
  186. data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
  187. data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
  188. data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
  189. data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
  190. data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
  191. data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
  192. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
  193. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
  194. data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
  195. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
  196. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
  197. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
  198. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
  199. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
  200. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
  201. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
  202. data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
  203. data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
  204. data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
  205. data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
  206. data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
  207. data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
  208. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
  209. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
  210. data/lib/couchbase/cluster.rb +1 -0
  211. data/lib/couchbase/errors.rb +3 -0
  212. data/lib/couchbase/libcouchbase.bundle +0 -0
  213. data/lib/couchbase/management/analytics_index_manager.rb +920 -226
  214. data/lib/couchbase/management/bucket_manager.rb +207 -69
  215. data/lib/couchbase/management/collection_manager.rb +173 -61
  216. data/lib/couchbase/management/query_index_manager.rb +357 -169
  217. data/lib/couchbase/options.rb +75 -3
  218. data/lib/couchbase/scope.rb +102 -0
  219. data/lib/couchbase/utils/time.rb +4 -0
  220. data/lib/couchbase/version.rb +6 -6
  221. metadata +48 -5
@@ -43,7 +43,7 @@ struct remove_request {
43
43
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
44
44
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
45
45
 
46
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
46
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
47
47
  {
48
48
  encoded.opaque(opaque);
49
49
  encoded.partition(partition);
@@ -57,9 +57,9 @@ struct remove_request {
57
57
  };
58
58
 
59
59
  remove_response
60
- make_response(error_context::key_value&& ctx, remove_request& request, remove_request::encoded_response_type&& encoded)
60
+ make_response(error_context::key_value&& ctx, const remove_request& request, remove_request::encoded_response_type&& encoded)
61
61
  {
62
- remove_response response{ ctx };
62
+ remove_response response{ std::move(ctx) };
63
63
  if (!response.ctx.ec) {
64
64
  response.cas = encoded.cas();
65
65
  response.token = encoded.body().token();
@@ -48,7 +48,7 @@ struct replace_request {
48
48
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
49
49
  bool preserve_expiry{ false };
50
50
 
51
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
51
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
52
52
  {
53
53
  encoded.opaque(opaque);
54
54
  encoded.partition(partition);
@@ -68,9 +68,9 @@ struct replace_request {
68
68
  };
69
69
 
70
70
  replace_response
71
- make_response(error_context::key_value&& ctx, replace_request& request, replace_request::encoded_response_type&& encoded)
71
+ make_response(error_context::key_value&& ctx, const replace_request& request, replace_request::encoded_response_type&& encoded)
72
72
  {
73
- replace_response response{ ctx };
73
+ replace_response response{ std::move(ctx) };
74
74
  if (!response.ctx.ec) {
75
75
  response.cas = encoded.cas();
76
76
  response.token = encoded.body().token();
@@ -119,6 +119,8 @@ struct search_request {
119
119
  std::optional<highlight_style_type> highlight_style{};
120
120
  std::vector<std::string> highlight_fields{};
121
121
  std::vector<std::string> fields{};
122
+ std::optional<std::string> scope_name{};
123
+ std::vector<std::string> collections{};
122
124
 
123
125
  enum class scan_consistency_type { not_bounded };
124
126
  std::optional<scan_consistency_type> scan_consistency{};
@@ -175,8 +177,8 @@ struct search_request {
175
177
  }
176
178
  if (!facets.empty()) {
177
179
  body["facets"] = tao::json::empty_object;
178
- for (const auto& facet : facets) {
179
- body["facets"][facet.first] = tao::json::from_string(facet.second);
180
+ for (const auto& [name, facet] : facets) {
181
+ body["facets"][name] = tao::json::from_string(facet);
180
182
  }
181
183
  }
182
184
  if (!mutation_state.empty()) {
@@ -193,6 +195,10 @@ struct search_request {
193
195
  { "vectors", { { index_name, scan_vectors } } },
194
196
  };
195
197
  }
198
+ if (scope_name) {
199
+ body["scope"] = scope_name.value();
200
+ body["collections"] = collections;
201
+ }
196
202
 
197
203
  encoded.type = type;
198
204
  encoded.headers["content-type"] = "application/json";
@@ -210,9 +216,9 @@ struct search_request {
210
216
  };
211
217
 
212
218
  search_response
213
- make_response(error_context::search&& ctx, search_request& request, search_request::encoded_response_type&& encoded)
219
+ make_response(error_context::search&& ctx, const search_request& request, search_request::encoded_response_type&& encoded)
214
220
  {
215
- search_response response{ ctx };
221
+ search_response response{ std::move(ctx) };
216
222
  response.meta_data.client_context_id = request.client_context_id;
217
223
  response.ctx.index_name = request.index_name;
218
224
  response.ctx.query = tao::json::to_string(request.query);
@@ -222,15 +228,15 @@ make_response(error_context::search&& ctx, search_request& request, search_reque
222
228
  tao::json::value payload{};
223
229
  try {
224
230
  payload = tao::json::from_string(encoded.body);
225
- } catch (tao::json::pegtl::parse_error& e) {
226
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
231
+ } catch (const tao::json::pegtl::parse_error& e) {
232
+ response.ctx.ec = error::common_errc::parsing_failure;
227
233
  return response;
228
234
  }
229
235
  response.meta_data.metrics.took = std::chrono::nanoseconds(payload.at("took").get_unsigned());
230
236
  response.meta_data.metrics.max_score = payload.at("max_score").as<double>();
231
237
  response.meta_data.metrics.total_rows = payload.at("total_hits").get_unsigned();
232
- auto status_prop = payload.at("status");
233
- if (status_prop.is_string()) {
238
+
239
+ if (auto& status_prop = payload.at("status"); status_prop.is_string()) {
234
240
  response.status = status_prop.get_string();
235
241
  if (response.status == "ok") {
236
242
  return response;
@@ -238,36 +244,33 @@ make_response(error_context::search&& ctx, search_request& request, search_reque
238
244
  } else if (status_prop.is_object()) {
239
245
  response.meta_data.metrics.error_partition_count = status_prop.at("failed").get_unsigned();
240
246
  response.meta_data.metrics.success_partition_count = status_prop.at("successful").get_unsigned();
241
- const auto* errors = status_prop.find("errors");
242
- if (errors != nullptr && errors->is_object()) {
243
- for (const auto& error : errors->get_object()) {
244
- response.meta_data.errors.emplace(error.first, error.second.get_string());
247
+ if (const auto* errors = status_prop.find("errors"); errors != nullptr && errors->is_object()) {
248
+ for (const auto& [location, message] : errors->get_object()) {
249
+ response.meta_data.errors.try_emplace(location, message.get_string());
245
250
  }
246
251
  }
247
252
  } else {
248
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
253
+ response.ctx.ec = error::common_errc::internal_server_failure;
249
254
  return response;
250
255
  }
251
- const auto* rows = payload.find("hits");
252
- if (rows != nullptr && rows->is_array()) {
256
+
257
+ if (const auto* rows = payload.find("hits"); rows != nullptr && rows->is_array()) {
253
258
  for (const auto& entry : rows->get_array()) {
254
259
  search_response::search_row row{};
255
260
  row.index = entry.at("index").get_string();
256
261
  row.id = entry.at("id").get_string();
257
262
  row.score = entry.at("score").as<double>();
258
- const auto* locations = entry.find("locations");
259
- if (locations != nullptr && locations->is_object()) {
260
- for (const auto& field : locations->get_object()) {
261
- for (const auto& term : field.second.get_object()) {
262
- for (const auto& loc : term.second.get_array()) {
263
+ if (const auto* locations_map = entry.find("locations"); locations_map != nullptr && locations_map->is_object()) {
264
+ for (const auto& [field, terms] : locations_map->get_object()) {
265
+ for (const auto& [term, locations] : terms.get_object()) {
266
+ for (const auto& loc : locations.get_array()) {
263
267
  search_response::search_location location{};
264
- location.field = field.first;
265
- location.term = term.first;
268
+ location.field = field;
269
+ location.term = term;
266
270
  location.position = loc.at("pos").get_unsigned();
267
271
  location.start_offset = loc.at("start").get_unsigned();
268
272
  location.end_offset = loc.at("end").get_unsigned();
269
- const auto* ap = loc.find("array_positions");
270
- if (ap != nullptr && ap->is_array()) {
273
+ if (const auto* ap = loc.find("array_positions"); ap != nullptr && ap->is_array()) {
271
274
  location.array_positions.emplace(ap->as<std::vector<std::uint64_t>>());
272
275
  }
273
276
  row.locations.emplace_back(location);
@@ -275,67 +278,60 @@ make_response(error_context::search&& ctx, search_request& request, search_reque
275
278
  }
276
279
  }
277
280
  }
278
- const auto* fragments_map = entry.find("fragments");
279
- if (fragments_map != nullptr && fragments_map->is_object()) {
280
- for (const auto& field : fragments_map->get_object()) {
281
- row.fragments.emplace(field.first, field.second.as<std::vector<std::string>>());
281
+
282
+ if (const auto* fragments_map = entry.find("fragments"); fragments_map != nullptr && fragments_map->is_object()) {
283
+ for (const auto& [field, fragments] : fragments_map->get_object()) {
284
+ row.fragments.emplace(field, fragments.as<std::vector<std::string>>());
282
285
  }
283
286
  }
284
- const auto* fields = entry.find("fields");
285
- if (fields != nullptr && fields->is_object()) {
287
+ if (const auto* fields = entry.find("fields"); fields != nullptr && fields->is_object()) {
286
288
  row.fields = tao::json::to_string(*fields);
287
289
  }
288
- const auto* explanation = entry.find("explanation");
289
- if (explanation != nullptr && explanation->is_object()) {
290
+ if (const auto* explanation = entry.find("explanation"); explanation != nullptr && explanation->is_object()) {
290
291
  row.explanation = tao::json::to_string(*explanation);
291
292
  }
292
293
  response.rows.emplace_back(row);
293
294
  }
294
295
  }
295
- const auto* facets = payload.find("facets");
296
- if (facets != nullptr && facets->is_object()) {
297
- for (const auto& entry : facets->get_object()) {
296
+
297
+ if (const auto* facets = payload.find("facets"); facets != nullptr && facets->is_object()) {
298
+ for (const auto& [name, object] : facets->get_object()) {
298
299
  search_response::search_facet facet;
299
- facet.name = entry.first;
300
- facet.field = entry.second.at("field").get_string();
301
- facet.total = entry.second.at("total").get_unsigned();
302
- facet.missing = entry.second.at("missing").get_unsigned();
303
- facet.other = entry.second.at("other").get_unsigned();
304
-
305
- const auto& date_ranges = entry.second.find("date_ranges");
306
- if (date_ranges != nullptr && date_ranges->is_array()) {
300
+ facet.name = name;
301
+ facet.field = object.at("field").get_string();
302
+ facet.total = object.at("total").get_unsigned();
303
+ facet.missing = object.at("missing").get_unsigned();
304
+ facet.other = object.at("other").get_unsigned();
305
+
306
+ if (const auto* date_ranges = object.find("date_ranges"); date_ranges != nullptr && date_ranges->is_array()) {
307
307
  for (const auto& date_range : date_ranges->get_array()) {
308
308
  search_response::search_facet::date_range_facet drf;
309
309
  drf.name = date_range.at("name").get_string();
310
310
  drf.count = date_range.at("count").get_unsigned();
311
- const auto* start = date_range.find("start");
312
- if (start != nullptr && start->is_string()) {
311
+ if (const auto* start = date_range.find("start"); start != nullptr && start->is_string()) {
313
312
  drf.start = start->get_string();
314
313
  }
315
- const auto* end = date_range.find("end");
316
- if (end != nullptr && end->is_string()) {
314
+ if (const auto* end = date_range.find("end"); end != nullptr && end->is_string()) {
317
315
  drf.end = end->get_string();
318
316
  }
319
317
  facet.date_ranges.emplace_back(drf);
320
318
  }
321
319
  }
322
320
 
323
- const auto& numeric_ranges = entry.second.find("numeric_ranges");
324
- if (numeric_ranges != nullptr && numeric_ranges->is_array()) {
321
+ if (const auto& numeric_ranges = object.find("numeric_ranges");
322
+ numeric_ranges != nullptr && numeric_ranges->is_array()) {
325
323
  for (const auto& numeric_range : numeric_ranges->get_array()) {
326
324
  search_response::search_facet::numeric_range_facet nrf;
327
325
  nrf.name = numeric_range.at("name").get_string();
328
326
  nrf.count = numeric_range.at("count").get_unsigned();
329
- const auto* min = numeric_range.find("min");
330
- if (min != nullptr) {
327
+ if (const auto* min = numeric_range.find("min"); min != nullptr) {
331
328
  if (min->is_double()) {
332
329
  nrf.min = min->as<double>();
333
330
  } else if (min->is_integer()) {
334
331
  nrf.min = min->get_unsigned();
335
332
  }
336
333
  }
337
- const auto* max = numeric_range.find("max");
338
- if (max != nullptr) {
334
+ if (const auto* max = numeric_range.find("max"); max != nullptr) {
339
335
  if (max->is_double()) {
340
336
  nrf.max = max->as<double>();
341
337
  } else if (max->is_integer()) {
@@ -346,8 +342,7 @@ make_response(error_context::search&& ctx, search_request& request, search_reque
346
342
  }
347
343
  }
348
344
 
349
- const auto& terms = entry.second.find("terms");
350
- if (terms != nullptr && terms->is_array()) {
345
+ if (const auto* terms = object.find("terms"); terms != nullptr && terms->is_array()) {
351
346
  for (const auto& term : terms->get_array()) {
352
347
  search_response::search_facet::term_facet tf;
353
348
  tf.term = term.at("term").get_string();
@@ -365,26 +360,26 @@ make_response(error_context::search&& ctx, search_request& request, search_reque
365
360
  tao::json::value payload{};
366
361
  try {
367
362
  payload = tao::json::from_string(encoded.body);
368
- } catch (tao::json::pegtl::parse_error& e) {
369
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
363
+ } catch (const tao::json::pegtl::parse_error& e) {
364
+ response.ctx.ec = error::common_errc::parsing_failure;
370
365
  return response;
371
366
  }
372
367
  response.status = payload.at("status").get_string();
373
368
  response.error = payload.at("error").get_string();
374
369
  if (response.error.find("index not found") != std::string::npos) {
375
- response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
370
+ response.ctx.ec = error::common_errc::index_not_found;
376
371
  return response;
377
372
  }
378
373
  if (response.error.find("no planPIndexes for indexName") != std::string::npos) {
379
- response.ctx.ec = std::make_error_code(error::search_errc::index_not_ready);
374
+ response.ctx.ec = error::search_errc::index_not_ready;
380
375
  return response;
381
376
  }
382
377
  if (response.error.find("pindex_consistency mismatched partition") != std::string::npos) {
383
- response.ctx.ec = std::make_error_code(error::search_errc::consistency_mismatch);
378
+ response.ctx.ec = error::search_errc::consistency_mismatch;
384
379
  return response;
385
380
  }
386
381
  }
387
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
382
+ response.ctx.ec = error::common_errc::internal_server_failure;
388
383
  }
389
384
  return response;
390
385
  }
@@ -40,7 +40,7 @@ struct touch_request {
40
40
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
41
41
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
42
42
 
43
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
43
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
44
44
  {
45
45
  encoded.opaque(opaque);
46
46
  encoded.partition(partition);
@@ -51,9 +51,9 @@ struct touch_request {
51
51
  };
52
52
 
53
53
  touch_response
54
- make_response(error_context::key_value&& ctx, touch_request&, touch_request::encoded_response_type&& encoded)
54
+ make_response(error_context::key_value&& ctx, const touch_request& /* request */, touch_request::encoded_response_type&& encoded)
55
55
  {
56
- touch_response response{ ctx };
56
+ touch_response response{ std::move(ctx) };
57
57
  if (!response.ctx.ec) {
58
58
  response.cas = encoded.cas();
59
59
  }
@@ -40,7 +40,7 @@ struct unlock_request {
40
40
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
41
41
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
42
42
 
43
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
43
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
44
44
  {
45
45
  encoded.opaque(opaque);
46
46
  encoded.partition(partition);
@@ -51,9 +51,9 @@ struct unlock_request {
51
51
  };
52
52
 
53
53
  unlock_response
54
- make_response(error_context::key_value&& ctx, unlock_request&, unlock_request::encoded_response_type&& encoded)
54
+ make_response(error_context::key_value&& ctx, const unlock_request& /* request */, unlock_request::encoded_response_type&& encoded)
55
55
  {
56
- unlock_response response{ ctx };
56
+ unlock_response response{ std::move(ctx) };
57
57
  if (!response.ctx.ec) {
58
58
  response.cas = encoded.cas();
59
59
  }
@@ -47,7 +47,7 @@ struct upsert_request {
47
47
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
48
48
  bool preserve_expiry{ false };
49
49
 
50
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
50
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
51
51
  {
52
52
  encoded.opaque(opaque);
53
53
  encoded.partition(partition);
@@ -66,9 +66,9 @@ struct upsert_request {
66
66
  };
67
67
 
68
68
  upsert_response
69
- make_response(error_context::key_value&& ctx, upsert_request& request, upsert_request::encoded_response_type&& encoded)
69
+ make_response(error_context::key_value&& ctx, const upsert_request& request, upsert_request::encoded_response_type&& encoded)
70
70
  {
71
- upsert_response response{ ctx };
71
+ upsert_response response{ std::move(ctx) };
72
72
  if (!response.ctx.ec) {
73
73
  response.cas = encoded.cas();
74
74
  response.token = encoded.body().token();
@@ -53,7 +53,7 @@ struct document_view_request {
53
53
  using encoded_response_type = io::http_response;
54
54
  using error_context_type = error_context::view;
55
55
 
56
- static const inline service_type type = service_type::views;
56
+ static const inline service_type type = service_type::view;
57
57
 
58
58
  std::string client_context_id{ uuid::to_string(uuid::random()) };
59
59
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
@@ -91,7 +91,7 @@ struct document_view_request {
91
91
  std::optional<sort_order> order;
92
92
  std::vector<std::string> query_string{};
93
93
 
94
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
94
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
95
95
  {
96
96
  if (debug) {
97
97
  query_string.emplace_back("debug=true");
@@ -177,9 +177,9 @@ struct document_view_request {
177
177
  };
178
178
 
179
179
  document_view_response
180
- make_response(error_context::view&& ctx, document_view_request& request, document_view_request::encoded_response_type&& encoded)
180
+ make_response(error_context::view&& ctx, const document_view_request& request, document_view_request::encoded_response_type&& encoded)
181
181
  {
182
- document_view_response response{ ctx };
182
+ document_view_response response{ std::move(ctx) };
183
183
  response.ctx.client_context_id = request.client_context_id;
184
184
  response.ctx.design_document_name = request.document_name;
185
185
  response.ctx.view_name = request.view_name;
@@ -189,24 +189,24 @@ make_response(error_context::view&& ctx, document_view_request& request, documen
189
189
  tao::json::value payload{};
190
190
  try {
191
191
  payload = tao::json::from_string(encoded.body);
192
- } catch (tao::json::pegtl::parse_error& e) {
193
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
192
+ } catch (const tao::json::pegtl::parse_error& e) {
193
+ response.ctx.ec = error::common_errc::parsing_failure;
194
194
  return response;
195
195
  }
196
- const auto* total_rows = payload.find("total_rows");
197
- if (total_rows != nullptr && total_rows->is_unsigned()) {
196
+
197
+ if (const auto* total_rows = payload.find("total_rows"); total_rows != nullptr && total_rows->is_unsigned()) {
198
198
  response.meta_data.total_rows = total_rows->get_unsigned();
199
199
  }
200
- const auto* debug_info = payload.find("debug_info");
201
- if (debug_info != nullptr && debug_info->is_object()) {
200
+
201
+ if (const auto* debug_info = payload.find("debug_info"); debug_info != nullptr && debug_info->is_object()) {
202
202
  response.meta_data.debug_info.emplace(tao::json::to_string(*debug_info));
203
203
  }
204
- const auto* rows = payload.find("rows");
205
- if (rows != nullptr && rows->is_array()) {
204
+
205
+ if (const auto* rows = payload.find("rows"); rows != nullptr && rows->is_array()) {
206
206
  for (const auto& entry : rows->get_array()) {
207
207
  document_view_response::row row{};
208
- const auto* id = entry.find("id");
209
- if (id != nullptr && id->is_string()) {
208
+
209
+ if (const auto* id = entry.find("id"); id != nullptr && id->is_string()) {
210
210
  row.id = id->get_string();
211
211
  }
212
212
  row.key = tao::json::to_string(entry.at("key"));
@@ -218,25 +218,25 @@ make_response(error_context::view&& ctx, document_view_request& request, documen
218
218
  tao::json::value payload{};
219
219
  try {
220
220
  payload = tao::json::from_string(encoded.body);
221
- } catch (tao::json::pegtl::parse_error& e) {
222
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
221
+ } catch (const tao::json::pegtl::parse_error& e) {
222
+ response.ctx.ec = error::common_errc::parsing_failure;
223
223
  return response;
224
224
  }
225
225
  document_view_response::problem problem{};
226
- const auto* error = payload.find("error");
227
- if (error != nullptr && error->is_string()) {
226
+
227
+ if (const auto* error = payload.find("error"); error != nullptr && error->is_string()) {
228
228
  problem.code = error->get_string();
229
229
  }
230
- const auto* reason = payload.find("reason");
231
- if (reason != nullptr && reason->is_string()) {
230
+
231
+ if (const auto* reason = payload.find("reason"); reason != nullptr && reason->is_string()) {
232
232
  problem.message = reason->get_string();
233
233
  }
234
234
  response.error.emplace(problem);
235
- response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
235
+ response.ctx.ec = error::common_errc::invalid_argument;
236
236
  } else if (encoded.status_code == 404) {
237
- response.ctx.ec = std::make_error_code(error::view_errc::design_document_not_found);
237
+ response.ctx.ec = error::view_errc::design_document_not_found;
238
238
  } else {
239
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
239
+ response.ctx.ec = error::common_errc::internal_server_failure;
240
240
  }
241
241
  }
242
242
  return response;
@@ -42,7 +42,7 @@ struct group_drop_request {
42
42
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
43
43
  std::string client_context_id{ uuid::to_string(uuid::random()) };
44
44
 
45
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
45
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
46
46
  {
47
47
  encoded.method = "DELETE";
48
48
  encoded.path = fmt::format("/settings/rbac/groups/{}", name);
@@ -51,18 +51,18 @@ struct group_drop_request {
51
51
  };
52
52
 
53
53
  group_drop_response
54
- make_response(error_context::http&& ctx, group_drop_request&, group_drop_request::encoded_response_type&& encoded)
54
+ make_response(error_context::http&& ctx, const group_drop_request& /* request */, group_drop_request::encoded_response_type&& encoded)
55
55
  {
56
- group_drop_response response{ ctx };
56
+ group_drop_response response{ std::move(ctx) };
57
57
  if (!response.ctx.ec) {
58
58
  switch (encoded.status_code) {
59
59
  case 200:
60
60
  break;
61
61
  case 404:
62
- response.ctx.ec = std::make_error_code(error::management_errc::group_not_found);
62
+ response.ctx.ec = error::management_errc::group_not_found;
63
63
  break;
64
64
  default:
65
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
65
+ response.ctx.ec = error::common_errc::internal_server_failure;
66
66
  break;
67
67
  }
68
68
  }