couchbase 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) 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/analytics_dataset_create.hxx +16 -12
  43. data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
  44. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
  45. data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
  46. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
  47. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
  48. data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
  49. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
  50. data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
  51. data/ext/couchbase/operations/analytics_link.hxx +39 -0
  52. data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
  53. data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
  54. data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
  55. data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
  56. data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
  57. data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
  58. data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
  59. data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
  60. data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
  61. data/ext/couchbase/operations/bucket_create.hxx +8 -8
  62. data/ext/couchbase/operations/bucket_drop.hxx +5 -5
  63. data/ext/couchbase/operations/bucket_flush.hxx +5 -5
  64. data/ext/couchbase/operations/bucket_get.hxx +7 -7
  65. data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
  66. data/ext/couchbase/operations/bucket_settings.hxx +40 -49
  67. data/ext/couchbase/operations/bucket_update.hxx +8 -8
  68. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
  69. data/ext/couchbase/operations/collection_create.hxx +11 -11
  70. data/ext/couchbase/operations/collection_drop.hxx +12 -10
  71. data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
  72. data/ext/couchbase/operations/design_document.hxx +2 -2
  73. data/ext/couchbase/operations/document_analytics.hxx +29 -36
  74. data/ext/couchbase/operations/document_append.hxx +3 -3
  75. data/ext/couchbase/operations/document_decrement.hxx +3 -3
  76. data/ext/couchbase/operations/document_exists.hxx +2 -2
  77. data/ext/couchbase/operations/document_get.hxx +3 -3
  78. data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
  79. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
  80. data/ext/couchbase/operations/document_get_projected.hxx +10 -11
  81. data/ext/couchbase/operations/document_increment.hxx +3 -3
  82. data/ext/couchbase/operations/document_insert.hxx +3 -3
  83. data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
  84. data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
  85. data/ext/couchbase/operations/document_prepend.hxx +3 -3
  86. data/ext/couchbase/operations/document_query.hxx +39 -41
  87. data/ext/couchbase/operations/document_remove.hxx +3 -3
  88. data/ext/couchbase/operations/document_replace.hxx +3 -3
  89. data/ext/couchbase/operations/document_search.hxx +56 -61
  90. data/ext/couchbase/operations/document_touch.hxx +3 -3
  91. data/ext/couchbase/operations/document_unlock.hxx +3 -3
  92. data/ext/couchbase/operations/document_upsert.hxx +3 -3
  93. data/ext/couchbase/operations/document_view.hxx +23 -23
  94. data/ext/couchbase/operations/group_drop.hxx +5 -5
  95. data/ext/couchbase/operations/group_get.hxx +7 -7
  96. data/ext/couchbase/operations/group_get_all.hxx +6 -6
  97. data/ext/couchbase/operations/group_upsert.hxx +11 -11
  98. data/ext/couchbase/operations/http_noop.hxx +6 -6
  99. data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
  100. data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
  101. data/ext/couchbase/operations/query_index_create.hxx +10 -8
  102. data/ext/couchbase/operations/query_index_drop.hxx +8 -8
  103. data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
  104. data/ext/couchbase/operations/rbac.hxx +40 -63
  105. data/ext/couchbase/operations/role_get_all.hxx +6 -6
  106. data/ext/couchbase/operations/scope_create.hxx +10 -10
  107. data/ext/couchbase/operations/scope_drop.hxx +9 -9
  108. data/ext/couchbase/operations/scope_get_all.hxx +8 -8
  109. data/ext/couchbase/operations/search_get_stats.hxx +5 -3
  110. data/ext/couchbase/operations/search_index.hxx +6 -15
  111. data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
  112. data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
  113. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
  114. data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
  115. data/ext/couchbase/operations/search_index_drop.hxx +11 -9
  116. data/ext/couchbase/operations/search_index_get.hxx +11 -9
  117. data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
  118. data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
  119. data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
  120. data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
  121. data/ext/couchbase/operations/user_drop.hxx +5 -5
  122. data/ext/couchbase/operations/user_get.hxx +7 -7
  123. data/ext/couchbase/operations/user_get_all.hxx +6 -6
  124. data/ext/couchbase/operations/user_upsert.hxx +9 -9
  125. data/ext/couchbase/operations/view_index_drop.hxx +10 -10
  126. data/ext/couchbase/operations/view_index_get.hxx +13 -15
  127. data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
  128. data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
  129. data/ext/couchbase/operations.hxx +4 -0
  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/management/analytics_index_manager.rb +920 -226
  213. data/lib/couchbase/management/bucket_manager.rb +207 -69
  214. data/lib/couchbase/management/collection_manager.rb +173 -61
  215. data/lib/couchbase/management/query_index_manager.rb +357 -169
  216. data/lib/couchbase/options.rb +75 -3
  217. data/lib/couchbase/scope.rb +102 -0
  218. data/lib/couchbase/utils/time.rb +4 -0
  219. data/lib/couchbase/version.rb +6 -6
  220. metadata +50 -7
@@ -42,7 +42,7 @@ struct role_get_all_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 = "GET";
48
48
  encoded.path = "/settings/rbac/roles";
@@ -52,23 +52,23 @@ struct role_get_all_request {
52
52
  };
53
53
 
54
54
  role_get_all_response
55
- make_response(error_context::http&& ctx, role_get_all_request&, role_get_all_request::encoded_response_type&& encoded)
55
+ make_response(error_context::http&& ctx, const role_get_all_request& /* request */, role_get_all_request::encoded_response_type&& encoded)
56
56
  {
57
- role_get_all_response response{ ctx };
57
+ role_get_all_response response{ std::move(ctx) };
58
58
  if (!response.ctx.ec) {
59
59
  if (encoded.status_code == 200) {
60
60
  tao::json::value payload{};
61
61
  try {
62
62
  payload = tao::json::from_string(encoded.body);
63
- } catch (tao::json::pegtl::parse_error& e) {
64
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
63
+ } catch (const tao::json::pegtl::parse_error& e) {
64
+ response.ctx.ec = error::common_errc::parsing_failure;
65
65
  return response;
66
66
  }
67
67
  for (const auto& entry : payload.get_array()) {
68
68
  response.roles.emplace_back(entry.as<rbac::role_and_description>());
69
69
  }
70
70
  } else {
71
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
71
+ response.ctx.ec = error::common_errc::internal_server_failure;
72
72
  }
73
73
  }
74
74
  return response;
@@ -46,7 +46,7 @@ struct scope_create_request {
46
46
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
47
47
  std::string client_context_id{ uuid::to_string(uuid::random()) };
48
48
 
49
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
49
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
50
50
  {
51
51
  encoded.method = "POST";
52
52
  encoded.path = fmt::format("/pools/default/buckets/{}/scopes", bucket_name);
@@ -57,36 +57,36 @@ struct scope_create_request {
57
57
  };
58
58
 
59
59
  scope_create_response
60
- make_response(error_context::http&& ctx, scope_create_request& /* request */, scope_create_request::encoded_response_type&& encoded)
60
+ make_response(error_context::http&& ctx, const scope_create_request& /* request */, scope_create_request::encoded_response_type&& encoded)
61
61
  {
62
- scope_create_response response{ ctx };
62
+ scope_create_response response{ std::move(ctx) };
63
63
  if (!response.ctx.ec) {
64
64
  switch (encoded.status_code) {
65
65
  case 400: {
66
66
  std::regex scope_exists("Scope with name .+ already exists");
67
67
  if (std::regex_search(encoded.body, scope_exists)) {
68
- response.ctx.ec = std::make_error_code(error::management_errc::scope_exists);
68
+ response.ctx.ec = error::management_errc::scope_exists;
69
69
  } else if (encoded.body.find("Not allowed on this version of cluster") != std::string::npos) {
70
- response.ctx.ec = std::make_error_code(error::common_errc::feature_not_available);
70
+ response.ctx.ec = error::common_errc::feature_not_available;
71
71
  } else {
72
- response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
72
+ response.ctx.ec = error::common_errc::invalid_argument;
73
73
  }
74
74
  } break;
75
75
  case 404:
76
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
76
+ response.ctx.ec = error::common_errc::bucket_not_found;
77
77
  break;
78
78
  case 200: {
79
79
  tao::json::value payload{};
80
80
  try {
81
81
  payload = tao::json::from_string(encoded.body);
82
- } catch (tao::json::pegtl::parse_error& e) {
83
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
82
+ } catch (const tao::json::pegtl::parse_error& e) {
83
+ response.ctx.ec = error::common_errc::parsing_failure;
84
84
  return response;
85
85
  }
86
86
  response.uid = std::stoull(payload.at("uid").get_string(), 0, 16);
87
87
  } break;
88
88
  default:
89
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
89
+ response.ctx.ec = error::common_errc::internal_server_failure;
90
90
  break;
91
91
  }
92
92
  }
@@ -46,7 +46,7 @@ struct scope_drop_request {
46
46
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
47
47
  std::string client_context_id{ uuid::to_string(uuid::random()) };
48
48
 
49
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
49
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
50
50
  {
51
51
  encoded.method = "DELETE";
52
52
  encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}", bucket_name, scope_name);
@@ -55,34 +55,34 @@ struct scope_drop_request {
55
55
  };
56
56
 
57
57
  scope_drop_response
58
- make_response(error_context::http&& ctx, scope_drop_request& /* request */, scope_drop_request::encoded_response_type&& encoded)
58
+ make_response(error_context::http&& ctx, const scope_drop_request& /* request */, scope_drop_request::encoded_response_type&& encoded)
59
59
  {
60
- scope_drop_response response{ ctx };
60
+ scope_drop_response response{ std::move(ctx) };
61
61
  if (!response.ctx.ec) {
62
62
  switch (encoded.status_code) {
63
63
  case 400:
64
- response.ctx.ec = std::make_error_code(error::common_errc::unsupported_operation);
64
+ response.ctx.ec = error::common_errc::unsupported_operation;
65
65
  break;
66
66
  case 404: {
67
67
  std::regex scope_not_found("Scope with name .+ is not found");
68
68
  if (std::regex_search(encoded.body, scope_not_found)) {
69
- response.ctx.ec = std::make_error_code(error::common_errc::scope_not_found);
69
+ response.ctx.ec = error::common_errc::scope_not_found;
70
70
  } else {
71
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
71
+ response.ctx.ec = error::common_errc::bucket_not_found;
72
72
  }
73
73
  } break;
74
74
  case 200: {
75
75
  tao::json::value payload{};
76
76
  try {
77
77
  payload = tao::json::from_string(encoded.body);
78
- } catch (tao::json::pegtl::parse_error& e) {
79
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
78
+ } catch (const tao::json::pegtl::parse_error& e) {
79
+ response.ctx.ec = error::common_errc::parsing_failure;
80
80
  return response;
81
81
  }
82
82
  response.uid = std::stoull(payload.at("uid").get_string(), 0, 16);
83
83
  } break;
84
84
  default:
85
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
85
+ response.ctx.ec = error::common_errc::internal_server_failure;
86
86
  break;
87
87
  }
88
88
  }
@@ -43,7 +43,7 @@ struct scope_get_all_request {
43
43
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
44
44
  std::string client_context_id{ uuid::to_string(uuid::random()) };
45
45
 
46
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
46
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
47
47
  {
48
48
  encoded.method = "GET";
49
49
  encoded.path = fmt::format("/pools/default/buckets/{}/scopes", bucket_name);
@@ -52,27 +52,27 @@ struct scope_get_all_request {
52
52
  };
53
53
 
54
54
  scope_get_all_response
55
- make_response(error_context::http&& ctx, scope_get_all_request&, scope_get_all_request::encoded_response_type&& encoded)
55
+ make_response(error_context::http&& ctx, const scope_get_all_request& /* request */, scope_get_all_request::encoded_response_type&& encoded)
56
56
  {
57
- scope_get_all_response response{ ctx };
57
+ scope_get_all_response response{ std::move(ctx) };
58
58
  if (!response.ctx.ec) {
59
59
  switch (encoded.status_code) {
60
60
  case 400:
61
- response.ctx.ec = std::make_error_code(error::common_errc::unsupported_operation);
61
+ response.ctx.ec = error::common_errc::unsupported_operation;
62
62
  break;
63
63
  case 404:
64
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
64
+ response.ctx.ec = error::common_errc::bucket_not_found;
65
65
  break;
66
66
  case 200:
67
67
  try {
68
68
  response.manifest = tao::json::from_string(encoded.body).as<collections_manifest>();
69
- } catch (tao::json::pegtl::parse_error& e) {
70
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
69
+ } catch (const tao::json::pegtl::parse_error& e) {
70
+ response.ctx.ec = error::common_errc::parsing_failure;
71
71
  return response;
72
72
  }
73
73
  break;
74
74
  default:
75
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
75
+ response.ctx.ec = error::common_errc::internal_server_failure;
76
76
  break;
77
77
  }
78
78
  }
@@ -39,7 +39,7 @@ struct search_index_stats_request {
39
39
  std::string client_context_id{ uuid::to_string(uuid::random()) };
40
40
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
41
41
 
42
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
42
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
43
43
  {
44
44
  encoded.method = "GET";
45
45
  encoded.path = "/api/nsstats";
@@ -48,9 +48,11 @@ struct search_index_stats_request {
48
48
  };
49
49
 
50
50
  search_index_stats_response
51
- make_response(error_context::http&& ctx, search_index_stats_request&, search_index_stats_request::encoded_response_type&& encoded)
51
+ make_response(error_context::http&& ctx,
52
+ const search_index_stats_request& /* request */,
53
+ search_index_stats_request::encoded_response_type&& encoded)
52
54
  {
53
- search_index_stats_response response{ ctx };
55
+ search_index_stats_response response{ std::move(ctx) };
54
56
  if (!response.ctx.ec) {
55
57
  response.stats = encoded.body;
56
58
  }
@@ -46,11 +46,8 @@ struct traits<couchbase::operations::search_index> {
46
46
  result.uuid = v.at("uuid").get_string();
47
47
  result.name = v.at("name").get_string();
48
48
  result.type = v.at("type").get_string();
49
- {
50
- const auto* params = v.find("params");
51
- if (params != nullptr && params->is_object()) {
52
- result.params_json = tao::json::to_string(*params);
53
- }
49
+ if (const auto* params = v.find("params"); params != nullptr && params->is_object()) {
50
+ result.params_json = tao::json::to_string(*params);
54
51
  }
55
52
  if (v.find("sourceUUID") != nullptr) {
56
53
  result.source_uuid = v.at("sourceUUID").get_string();
@@ -61,17 +58,11 @@ struct traits<couchbase::operations::search_index> {
61
58
  if (v.find("sourceType") != nullptr) {
62
59
  result.source_type = v.at("sourceType").get_string();
63
60
  }
64
- {
65
- const auto* params = v.find("sourceParams");
66
- if (params != nullptr && params->is_object()) {
67
- result.source_params_json = tao::json::to_string(*params);
68
- }
61
+ if (const auto* params = v.find("sourceParams"); params != nullptr && params->is_object()) {
62
+ result.source_params_json = tao::json::to_string(*params);
69
63
  }
70
- {
71
- const auto* params = v.find("planParams");
72
- if (params != nullptr && params->is_object()) {
73
- result.plan_params_json = tao::json::to_string(*params);
74
- }
64
+ if (const auto* params = v.find("planParams"); params != nullptr && params->is_object()) {
65
+ result.plan_params_json = tao::json::to_string(*params);
75
66
  }
76
67
  return result;
77
68
  }
@@ -44,7 +44,7 @@ struct search_index_analyze_document_request {
44
44
  std::string index_name;
45
45
  std::string encoded_document;
46
46
 
47
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
47
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
48
48
  {
49
49
  encoded.method = "POST";
50
50
  encoded.headers["cache-control"] = "no-cache";
@@ -57,17 +57,17 @@ struct search_index_analyze_document_request {
57
57
 
58
58
  search_index_analyze_document_response
59
59
  make_response(error_context::http&& ctx,
60
- search_index_analyze_document_request&,
60
+ const search_index_analyze_document_request& /* request */,
61
61
  search_index_analyze_document_request::encoded_response_type&& encoded)
62
62
  {
63
- search_index_analyze_document_response response{ ctx };
63
+ search_index_analyze_document_response response{ std::move(ctx) };
64
64
  if (!response.ctx.ec) {
65
65
  if (encoded.status_code == 200) {
66
66
  tao::json::value payload{};
67
67
  try {
68
68
  payload = tao::json::from_string(encoded.body);
69
- } catch (tao::json::pegtl::parse_error& e) {
70
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
69
+ } catch (const tao::json::pegtl::parse_error& e) {
70
+ response.ctx.ec = error::common_errc::parsing_failure;
71
71
  return response;
72
72
  }
73
73
  response.status = payload.at("status").get_string();
@@ -77,27 +77,27 @@ make_response(error_context::http&& ctx,
77
77
  }
78
78
  } else if (encoded.status_code == 400) {
79
79
  if (encoded.body.find("no indexName:") != std::string::npos) {
80
- response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
80
+ response.ctx.ec = error::common_errc::index_not_found;
81
81
  return response;
82
82
  }
83
83
  tao::json::value payload{};
84
84
  try {
85
85
  payload = tao::json::from_string(encoded.body);
86
- } catch (tao::json::pegtl::parse_error& e) {
87
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
86
+ } catch (const tao::json::pegtl::parse_error& e) {
87
+ response.ctx.ec = error::common_errc::parsing_failure;
88
88
  return response;
89
89
  }
90
90
  response.status = payload.at("status").get_string();
91
91
  response.error = payload.at("error").get_string();
92
92
  if (response.error.find("index not found") != std::string::npos) {
93
- response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
93
+ response.ctx.ec = error::common_errc::index_not_found;
94
94
  return response;
95
95
  } else if (response.error.find("index with the same name already exists") != std::string::npos) {
96
- response.ctx.ec = std::make_error_code(error::common_errc::index_exists);
96
+ response.ctx.ec = error::common_errc::index_exists;
97
97
  return response;
98
98
  }
99
99
  }
100
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
100
+ response.ctx.ec = error::common_errc::internal_server_failure;
101
101
  }
102
102
  return response;
103
103
  }
@@ -43,7 +43,7 @@ struct search_index_control_ingest_request {
43
43
  std::string index_name;
44
44
  bool pause;
45
45
 
46
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
46
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
47
47
  {
48
48
  encoded.method = "POST";
49
49
  encoded.path = fmt::format("/api/index/{}/ingestControl/{}", index_name, pause ? "pause" : "resume");
@@ -53,17 +53,17 @@ struct search_index_control_ingest_request {
53
53
 
54
54
  search_index_control_ingest_response
55
55
  make_response(error_context::http&& ctx,
56
- search_index_control_ingest_request&,
56
+ const search_index_control_ingest_request& /* request */,
57
57
  search_index_control_ingest_request::encoded_response_type&& encoded)
58
58
  {
59
- search_index_control_ingest_response response{ ctx };
59
+ search_index_control_ingest_response response{ std::move(ctx) };
60
60
  if (!response.ctx.ec) {
61
61
  if (encoded.status_code == 200) {
62
62
  tao::json::value payload{};
63
63
  try {
64
64
  payload = tao::json::from_string(encoded.body);
65
- } catch (tao::json::pegtl::parse_error& e) {
66
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
65
+ } catch (const tao::json::pegtl::parse_error& e) {
66
+ response.ctx.ec = error::common_errc::parsing_failure;
67
67
  return response;
68
68
  }
69
69
  response.status = payload.at("status").get_string();
@@ -74,18 +74,18 @@ make_response(error_context::http&& ctx,
74
74
  tao::json::value payload{};
75
75
  try {
76
76
  payload = tao::json::from_string(encoded.body);
77
- } catch (tao::json::pegtl::parse_error& e) {
78
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
77
+ } catch (const tao::json::pegtl::parse_error& e) {
78
+ response.ctx.ec = error::common_errc::parsing_failure;
79
79
  return response;
80
80
  }
81
81
  response.status = payload.at("status").get_string();
82
82
  response.error = payload.at("error").get_string();
83
83
  if (response.error.find("index not found") != std::string::npos) {
84
- response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
84
+ response.ctx.ec = error::common_errc::index_not_found;
85
85
  return response;
86
86
  }
87
87
  }
88
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
88
+ response.ctx.ec = error::common_errc::internal_server_failure;
89
89
  }
90
90
  return response;
91
91
  }
@@ -43,7 +43,7 @@ struct search_index_control_plan_freeze_request {
43
43
  std::string index_name;
44
44
  bool freeze;
45
45
 
46
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
46
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
47
47
  {
48
48
  encoded.method = "POST";
49
49
  encoded.path = fmt::format("/api/index/{}/planFreezeControl/{}", index_name, freeze ? "freeze" : "unfreeze");
@@ -53,17 +53,17 @@ struct search_index_control_plan_freeze_request {
53
53
 
54
54
  search_index_control_plan_freeze_response
55
55
  make_response(error_context::http&& ctx,
56
- search_index_control_plan_freeze_request&,
56
+ const search_index_control_plan_freeze_request& /* request */,
57
57
  search_index_control_plan_freeze_request::encoded_response_type&& encoded)
58
58
  {
59
- search_index_control_plan_freeze_response response{ ctx };
59
+ search_index_control_plan_freeze_response response{ std::move(ctx) };
60
60
  if (!response.ctx.ec) {
61
61
  if (encoded.status_code == 200) {
62
62
  tao::json::value payload{};
63
63
  try {
64
64
  payload = tao::json::from_string(encoded.body);
65
- } catch (tao::json::pegtl::parse_error& e) {
66
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
65
+ } catch (const tao::json::pegtl::parse_error& e) {
66
+ response.ctx.ec = error::common_errc::parsing_failure;
67
67
  return response;
68
68
  }
69
69
  response.status = payload.at("status").get_string();
@@ -74,18 +74,18 @@ make_response(error_context::http&& ctx,
74
74
  tao::json::value payload{};
75
75
  try {
76
76
  payload = tao::json::from_string(encoded.body);
77
- } catch (tao::json::pegtl::parse_error& e) {
78
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
77
+ } catch (const tao::json::pegtl::parse_error& e) {
78
+ response.ctx.ec = error::common_errc::parsing_failure;
79
79
  return response;
80
80
  }
81
81
  response.status = payload.at("status").get_string();
82
82
  response.error = payload.at("error").get_string();
83
83
  if (response.error.find("index not found") != std::string::npos) {
84
- response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
84
+ response.ctx.ec = error::common_errc::index_not_found;
85
85
  return response;
86
86
  }
87
87
  }
88
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
88
+ response.ctx.ec = error::common_errc::internal_server_failure;
89
89
  }
90
90
  return response;
91
91
  }
@@ -43,7 +43,7 @@ struct search_index_control_query_request {
43
43
  std::string index_name;
44
44
  bool allow;
45
45
 
46
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
46
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
47
47
  {
48
48
  encoded.method = "POST";
49
49
  encoded.path = fmt::format("/api/index/{}/queryControl/{}", index_name, allow ? "allow" : "disallow");
@@ -53,17 +53,17 @@ struct search_index_control_query_request {
53
53
 
54
54
  search_index_control_query_response
55
55
  make_response(error_context::http&& ctx,
56
- search_index_control_query_request&,
56
+ const search_index_control_query_request& /* request */,
57
57
  search_index_control_query_request::encoded_response_type&& encoded)
58
58
  {
59
- search_index_control_query_response response{ ctx };
59
+ search_index_control_query_response response{ std::move(ctx) };
60
60
  if (!response.ctx.ec) {
61
61
  if (encoded.status_code == 200) {
62
62
  tao::json::value payload{};
63
63
  try {
64
64
  payload = tao::json::from_string(encoded.body);
65
- } catch (tao::json::pegtl::parse_error& e) {
66
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
65
+ } catch (const tao::json::pegtl::parse_error& e) {
66
+ response.ctx.ec = error::common_errc::parsing_failure;
67
67
  return response;
68
68
  }
69
69
  response.status = payload.at("status").get_string();
@@ -74,18 +74,18 @@ make_response(error_context::http&& ctx,
74
74
  tao::json::value payload{};
75
75
  try {
76
76
  payload = tao::json::from_string(encoded.body);
77
- } catch (tao::json::pegtl::parse_error& e) {
78
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
77
+ } catch (const tao::json::pegtl::parse_error& e) {
78
+ response.ctx.ec = error::common_errc::parsing_failure;
79
79
  return response;
80
80
  }
81
81
  response.status = payload.at("status").get_string();
82
82
  response.error = payload.at("error").get_string();
83
83
  if (response.error.find("index not found") != std::string::npos) {
84
- response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
84
+ response.ctx.ec = error::common_errc::index_not_found;
85
85
  return response;
86
86
  }
87
87
  }
88
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
88
+ response.ctx.ec = error::common_errc::internal_server_failure;
89
89
  }
90
90
  return response;
91
91
  }