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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ed2265468b3ab614f6e74a188015c2f96ce595116af1fc981ea30314e7d2ae3
4
- data.tar.gz: bce8a86c7ea3f563e24b106dd981cace9bb558e9a6e70cb906e58df433b05201
3
+ metadata.gz: f6067d84b58a261969e5b43e9703dc036a4a612d2ce644e2247875d9fde089d7
4
+ data.tar.gz: 0a39070aa359284ee51490a9a79096b5ba14f6e0838f85373da6fc01b5ad7f34
5
5
  SHA512:
6
- metadata.gz: 2a14b4867628eea0bb6a52c0eaf4e683b44261306b897f194de9f195c5aa2105ecb646c62c961ceeb903c7aa728342d130bfb15005bee07ecf9a3ebc8155c776
7
- data.tar.gz: e31a897199cae23cd47c945f99353019cfa94e4a176a4a235de834143944b14b84aec84c5c0f99c12cce8a711155375e7525187d4c0b6b945ff1d5434750e44f
6
+ metadata.gz: 59818d9ce11ea0a643471fd4f4c58cd4e838f5dfd2e97fbd72640eea3469268582bf36162a74fcb92ebd8fdc681b92e1b3de3672c258d98fdb2f21dc971d614a
7
+ data.tar.gz: e9775a3b9b25b3670c874092aaa79734bfccff4475f2dee05a48334c8edffe5f40b86142a352c4e1f7ea9f34f6e211686d97dfd4b8faa8bfa5808122b26d680b
data/README.md CHANGED
@@ -19,12 +19,12 @@ Please attach version information to ticket/post. To obtain this information use
19
19
 
20
20
  ## Installation
21
21
 
22
- The library tested with the MRI 2.5, 2.6, 2.7 and 3.0. Supported platforms are Linux and MacOS.
22
+ The library tested with the MRI 2.6, 2.7 and 3.0. Supported platforms are Linux and MacOS.
23
23
 
24
24
  Add this line to your application's Gemfile:
25
25
 
26
26
  ```ruby
27
- gem "couchbase", "3.1.1"
27
+ gem "couchbase", "3.2.0"
28
28
  ```
29
29
 
30
30
  And then execute:
data/ext/CMakeLists.txt CHANGED
@@ -71,7 +71,7 @@ add_library(
71
71
  target_include_directories(platform PRIVATE ${PROJECT_BINARY_DIR}/generated)
72
72
  target_link_libraries(platform PRIVATE ${PLATFORM_LIBRARIES})
73
73
 
74
- add_library(cbcrypto OBJECT couchbase/cbcrypto/cbcrypto.cc)
74
+ add_library(cbcrypto OBJECT couchbase/cbcrypto/cbcrypto.cc couchbase/utils/name_codec.hxx)
75
75
  target_link_libraries(
76
76
  cbcrypto
77
77
  PRIVATE project_options
@@ -113,6 +113,7 @@ target_link_libraries(
113
113
  cbcrypto
114
114
  cbsasl
115
115
  http_parser
116
+ hdr_histogram_static
116
117
  snappy
117
118
  spdlog::spdlog_header_only)
118
119
 
@@ -121,6 +122,7 @@ set_target_properties(
121
122
  cbsasl
122
123
  platform
123
124
  snappy
125
+ hdr_histogram_static
124
126
  PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
125
127
 
126
128
  if(APPLE)
@@ -26,5 +26,5 @@ constexpr auto BACKEND_CXX_COMPILER = "@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPIL
26
26
  constexpr auto BACKEND_C_COMPILER = "@CMAKE_C_COMPILER_ID@ @CMAKE_C_COMPILER_VERSION@";
27
27
  constexpr auto BACKEND_SYSTEM = "@CMAKE_SYSTEM@";
28
28
  constexpr auto BACKEND_SYSTEM_PROCESSOR = "@CMAKE_SYSTEM_PROCESSOR@";
29
- constexpr auto BACKEND_GIT_REVISION = "a79d098eb238b3883e49e1738c35167642e8834f";
29
+ constexpr auto BACKEND_GIT_REVISION = "6c069e4e6965117c7240b331847dc3f62afe0554";
30
30
  } // namespace couchbase
@@ -40,6 +40,7 @@ if(ENABLE_TESTING)
40
40
  cbcrypto
41
41
  cbsasl
42
42
  http_parser
43
+ hdr_histogram_static
43
44
  snappy
44
45
  spdlog::spdlog_header_only)
45
46
  catch_discover_tests(test_native_${name})
@@ -10,6 +10,12 @@ option(SNAPPY_BUILD_TESTS OFF)
10
10
  option(SNAPPY_INSTALL OFF)
11
11
  add_subdirectory(third_party/snappy)
12
12
 
13
+ option(HDR_LOG_REQUIRED OFF)
14
+ option(HDR_HISTOGRAM_BUILD_SHARED OFF)
15
+ option(HDR_HISTOGRAM_BUILD_PROGRAMS OFF)
16
+ add_subdirectory(third_party/hdr_histogram_c)
17
+ include_directories(BEFORE SYSTEM third_party/hdr_histogram_c/src)
18
+
13
19
  include_directories(BEFORE SYSTEM third_party/gsl/include)
14
20
  include_directories(BEFORE SYSTEM third_party/asio/asio/include)
15
21
  include_directories(BEFORE SYSTEM third_party/json/include)
@@ -34,4 +34,7 @@ file(
34
34
  #define RUBY_INCLUDE_DIR \"${RUBY_INCLUDE_DIR}\"
35
35
 
36
36
  #define CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\"
37
+ #define CMAKE_VERSION \"${CMAKE_VERSION}\"
38
+
39
+ #define BACKEND_DEBUG_BUILD $<STREQUAL:$<UPPER_CASE:\"${CMAKE_BUILD_TYPE}\">,\"DEBUG\">
37
40
  ")
@@ -22,6 +22,8 @@
22
22
 
23
23
  #include <operations.hxx>
24
24
  #include <origin.hxx>
25
+ #include <tracing/request_tracer.hxx>
26
+ #include <metrics/meter.hxx>
25
27
 
26
28
  namespace couchbase
27
29
  {
@@ -31,6 +33,8 @@ class bucket : public std::enable_shared_from_this<bucket>
31
33
  explicit bucket(const std::string& client_id,
32
34
  asio::io_context& ctx,
33
35
  asio::ssl::context& tls,
36
+ tracing::request_tracer* tracer,
37
+ metrics::meter* meter,
34
38
  std::string name,
35
39
  couchbase::origin origin,
36
40
  const std::vector<protocol::hello_feature>& known_features)
@@ -38,6 +42,8 @@ class bucket : public std::enable_shared_from_this<bucket>
38
42
  : client_id_(client_id)
39
43
  , ctx_(ctx)
40
44
  , tls_(tls)
45
+ , tracer_(tracer)
46
+ , meter_(meter)
41
47
  , name_(std::move(name))
42
48
  , origin_(std::move(origin))
43
49
  , known_features_(known_features)
@@ -80,7 +86,7 @@ class bucket : public std::enable_shared_from_this<bucket>
80
86
  {
81
87
  if (!config_) {
82
88
  spdlog::debug("{} initialize configuration rev={}", log_prefix_, config.rev_str());
83
- } else if (config.rev && config_->rev && *config.rev > *config_->rev) {
89
+ } else if (config_ < config) {
84
90
  spdlog::debug("{} will update the configuration old={} -> new={}", log_prefix_, config_->rev_str(), config.rev_str());
85
91
  } else {
86
92
  return;
@@ -98,12 +104,13 @@ class bucket : public std::enable_shared_from_this<bucket>
98
104
  if (!added.empty() || removed.empty()) {
99
105
  std::map<size_t, std::shared_ptr<io::mcbp_session>> new_sessions{};
100
106
 
101
- for (auto entry : sessions_) {
107
+ for (auto& [index, session] : sessions_) {
102
108
  std::size_t new_index = config.nodes.size() + 1;
103
109
  for (const auto& node : config.nodes) {
104
- if (entry.second->bootstrap_hostname() == node.hostname_for(origin_.options().network) &&
105
- entry.second->bootstrap_port() ==
106
- std::to_string(node.port_or(origin_.options().network, service_type::kv, origin_.options().enable_tls, 0))) {
110
+ if (session->bootstrap_hostname() == node.hostname_for(origin_.options().network) &&
111
+ session->bootstrap_port() ==
112
+ std::to_string(
113
+ node.port_or(origin_.options().network, service_type::key_value, origin_.options().enable_tls, 0))) {
107
114
  new_index = node.index;
108
115
  break;
109
116
  }
@@ -112,18 +119,18 @@ class bucket : public std::enable_shared_from_this<bucket>
112
119
  spdlog::debug(R"({} rev={}, preserve session="{}", address="{}:{}")",
113
120
  log_prefix_,
114
121
  config.rev_str(),
115
- entry.second->id(),
116
- entry.second->bootstrap_hostname(),
117
- entry.second->bootstrap_port());
118
- new_sessions.emplace(new_index, std::move(entry.second));
122
+ session->id(),
123
+ session->bootstrap_hostname(),
124
+ session->bootstrap_port());
125
+ new_sessions.emplace(new_index, std::move(session));
119
126
  } else {
120
127
  spdlog::debug(R"({} rev={}, drop session="{}", address="{}:{}")",
121
128
  log_prefix_,
122
129
  config.rev_str(),
123
- entry.second->id(),
124
- entry.second->bootstrap_hostname(),
125
- entry.second->bootstrap_port());
126
- entry.second.reset();
130
+ session->id(),
131
+ session->bootstrap_hostname(),
132
+ session->bootstrap_port());
133
+ session.reset();
127
134
  }
128
135
  }
129
136
 
@@ -132,8 +139,8 @@ class bucket : public std::enable_shared_from_this<bucket>
132
139
  continue;
133
140
  }
134
141
 
135
- auto hostname = node.hostname_for(origin_.options().network);
136
- auto port = node.port_or(origin_.options().network, service_type::kv, origin_.options().enable_tls, 0);
142
+ const auto& hostname = node.hostname_for(origin_.options().network);
143
+ auto port = node.port_or(origin_.options().network, service_type::key_value, origin_.options().enable_tls, 0);
137
144
  if (port == 0) {
138
145
  continue;
139
146
  }
@@ -172,7 +179,7 @@ class bucket : public std::enable_shared_from_this<bucket>
172
179
  spdlog::debug(R"({} requested to restart session idx={}, which does not exist, ignoring)", log_prefix_, index);
173
180
  return;
174
181
  }
175
- auto& old_session = ptr->second;
182
+ const auto& old_session = ptr->second;
176
183
  auto hostname = old_session->bootstrap_hostname();
177
184
  auto port = old_session->bootstrap_port();
178
185
  auto old_id = old_session->id();
@@ -242,7 +249,7 @@ class bucket : public std::enable_shared_from_this<bucket>
242
249
  auto cmd = std::make_shared<operations::mcbp_command<bucket, Request>>(ctx_, shared_from_this(), request);
243
250
  cmd->start([cmd, handler = std::forward<Handler>(handler)](std::error_code ec, std::optional<io::mcbp_message> msg) mutable {
244
251
  using encoded_response_type = typename Request::encoded_response_type;
245
- auto resp = msg ? encoded_response_type(*msg) : encoded_response_type{};
252
+ auto resp = msg ? encoded_response_type(std::move(*msg)) : encoded_response_type{};
246
253
  error_context::key_value ctx{};
247
254
  ctx.id = cmd->request.id;
248
255
  ctx.opaque = resp.opaque();
@@ -280,10 +287,10 @@ class bucket : public std::enable_shared_from_this<bucket>
280
287
  closed_ = true;
281
288
 
282
289
  drain_deferred_queue();
283
- for (auto& session : sessions_) {
284
- if (session.second) {
285
- spdlog::debug(R"({} shutdown session session="{}", idx={})", log_prefix_, session.second->id(), session.first);
286
- session.second->stop(io::retry_reason::do_not_retry);
290
+ for (auto& [index, session] : sessions_) {
291
+ if (session) {
292
+ spdlog::debug(R"({} shutdown session session="{}", idx={})", log_prefix_, session->id(), index);
293
+ session->stop(io::retry_reason::do_not_retry);
287
294
  }
288
295
  }
289
296
  }
@@ -305,13 +312,13 @@ class bucket : public std::enable_shared_from_this<bucket>
305
312
  std::tie(cmd->request.partition, index) = config_->map_key(cmd->request.id.key);
306
313
  if (index < 0) {
307
314
  return io::retry_orchestrator::maybe_retry(
308
- cmd->manager_, cmd, io::retry_reason::node_not_available, std::make_error_code(error::common_errc::request_canceled));
315
+ cmd->manager_, cmd, io::retry_reason::node_not_available, error::common_errc::request_canceled);
309
316
  }
310
317
  }
311
318
  auto session = sessions_.at(static_cast<std::size_t>(index));
312
319
  if (session->is_stopped()) {
313
320
  return io::retry_orchestrator::maybe_retry(
314
- cmd->manager_, cmd, io::retry_reason::node_not_available, std::make_error_code(error::common_errc::request_canceled));
321
+ cmd->manager_, cmd, io::retry_reason::node_not_available, error::common_errc::request_canceled);
315
322
  }
316
323
  cmd->send_to(session);
317
324
  }
@@ -331,30 +338,42 @@ class bucket : public std::enable_shared_from_this<bucket>
331
338
  });
332
339
  }
333
340
 
334
- [[nodiscard]] const std::string& log_prefix()
341
+ [[nodiscard]] const std::string& log_prefix() const
335
342
  {
336
343
  return log_prefix_;
337
344
  }
338
345
 
339
346
  void export_diag_info(diag::diagnostics_result& res) const
340
347
  {
341
- for (const auto& session : sessions_) {
342
- res.services[service_type::kv].emplace_back(session.second->diag_info());
348
+ for (const auto& [index, session] : sessions_) {
349
+ res.services[service_type::key_value].emplace_back(session->diag_info());
343
350
  }
344
351
  }
345
352
 
346
353
  template<typename Collector>
347
354
  void ping(std::shared_ptr<Collector> collector)
348
355
  {
349
- for (const auto& session : sessions_) {
350
- session.second->ping(collector->build_reporter());
356
+ for (const auto& [index, session] : sessions_) {
357
+ session->ping(collector->build_reporter());
351
358
  }
352
359
  }
353
360
 
361
+ auto tracer() const
362
+ {
363
+ return tracer_;
364
+ }
365
+
366
+ auto meter() const
367
+ {
368
+ return meter_;
369
+ }
370
+
354
371
  private:
355
372
  std::string client_id_;
356
373
  asio::io_context& ctx_;
357
374
  asio::ssl::context& tls_;
375
+ tracing::request_tracer* tracer_;
376
+ metrics::meter* meter_;
358
377
  std::string name_;
359
378
  origin origin_;
360
379
 
@@ -120,7 +120,7 @@ class ClientContext : public Context
120
120
  return backend->step(input);
121
121
  }
122
122
 
123
- protected:
123
+ private:
124
124
  std::unique_ptr<MechanismBackend> backend;
125
125
  };
126
126
 
@@ -21,7 +21,7 @@
21
21
  namespace couchbase::sasl
22
22
  {
23
23
 
24
- std::string
24
+ const std::string&
25
25
  Context::get_uuid()
26
26
  {
27
27
  if (uuid.empty()) {
@@ -35,7 +35,7 @@ class Context
35
35
  * Get the UUID used for errors by this connection. If none
36
36
  * is created a new one is generated.
37
37
  */
38
- std::string get_uuid();
38
+ [[nodiscard]] const std::string& get_uuid();
39
39
 
40
40
  /**
41
41
  * Do this context contain a UUID?
@@ -45,8 +45,8 @@ class Context
45
45
  return !uuid.empty();
46
46
  }
47
47
 
48
- protected:
48
+ private:
49
49
  std::string uuid;
50
50
  };
51
51
 
52
- } // namespace couchbase::sasl
52
+ } // namespace couchbase::sasl
@@ -21,9 +21,7 @@
21
21
  #include <iterator>
22
22
  #include <vector>
23
23
 
24
- namespace couchbase
25
- {
26
- namespace sasl
24
+ namespace couchbase::sasl
27
25
  {
28
26
 
29
27
  Mechanism
@@ -35,14 +33,13 @@ select_mechanism(const std::vector<std::string>& available_mechanisms)
35
33
  { std::string{ "SCRAM-SHA1" }, Mechanism::SCRAM_SHA1 },
36
34
  { std::string{ "PLAIN" }, Mechanism::PLAIN } };
37
35
 
38
- for (const auto& mechanism : mechs) {
39
- if (std::find(available_mechanisms.begin(), available_mechanisms.end(), mechanism.first) != available_mechanisms.end()) {
40
- return mechanism.second;
36
+ for (const auto& [name, code] : mechs) {
37
+ if (std::find(available_mechanisms.begin(), available_mechanisms.end(), name) != available_mechanisms.end()) {
38
+ return code;
41
39
  }
42
40
  }
43
41
 
44
42
  throw unknown_mechanism("unknown mechanism"); // TODO: avoid this exception
45
43
  }
46
44
 
47
- } // namespace sasl
48
- } // namespace couchbase
45
+ } // namespace couchbase::sasl
@@ -31,10 +31,7 @@ enum class Mechanism { SCRAM_SHA512, SCRAM_SHA256, SCRAM_SHA1, PLAIN };
31
31
  class unknown_mechanism : public std::invalid_argument
32
32
  {
33
33
  public:
34
- explicit unknown_mechanism(const std::string& msg)
35
- : std::invalid_argument(msg)
36
- {
37
- }
34
+ using std::invalid_argument::invalid_argument;
38
35
  };
39
36
 
40
37
  /**
@@ -30,7 +30,7 @@ ClientBackend::start()
30
30
  buffer.push_back(0);
31
31
  std::copy(passwd.begin(), passwd.end(), std::back_inserter(buffer));
32
32
 
33
- return std::make_pair<error, std::string_view>(error::OK, { buffer.data(), buffer.size() });
33
+ return { error::OK, { buffer.data(), buffer.size() } };
34
34
  }
35
35
 
36
36
  } // namespace couchbase::sasl::mechanism::plain
@@ -27,11 +27,8 @@
27
27
  #include <cbsasl/scram-sha/stringutils.h>
28
28
 
29
29
  #include <cstring>
30
- #include <gsl/gsl>
31
- #include <iomanip>
32
30
  #include <iostream>
33
31
  #include <map>
34
- #include <memory>
35
32
  #include <set>
36
33
  #include <sstream>
37
34
  #include <string>
@@ -80,10 +77,10 @@ decodeAttributeList(const std::string& list, AttributeMap& attributes)
80
77
 
81
78
  auto comma = list.find(',', pos);
82
79
  if (comma == std::string::npos) {
83
- attributes.insert(std::make_pair(key, list.substr(pos)));
80
+ attributes.try_emplace(key, list.substr(pos));
84
81
  pos = list.length();
85
82
  } else {
86
- attributes.insert(std::make_pair(key, list.substr(pos, comma - pos)));
83
+ attributes.try_emplace(key, list.substr(pos, comma - pos));
87
84
  pos = comma + 1;
88
85
  }
89
86
  }
@@ -188,7 +185,6 @@ ScramShaBackend::addAttribute(std::ostream& out, char key, int value, bool more)
188
185
  case 'e': // error message
189
186
  throw std::invalid_argument("ScramShaBackend::addAttribute:"
190
187
  " Invalid value (should not be int)");
191
- break;
192
188
 
193
189
  case 'i': // iterator count
194
190
  out << value;
@@ -284,14 +280,14 @@ ClientBackend::start()
284
280
  client_first_message = out.str();
285
281
  client_first_message_bare = client_first_message.substr(3); // skip n,,
286
282
 
287
- return std::make_pair<error, std::string_view>(error::OK, client_first_message);
283
+ return { error::OK, client_first_message };
288
284
  }
289
285
 
290
286
  std::pair<error, std::string_view>
291
287
  ClientBackend::step(std::string_view input)
292
288
  {
293
289
  if (input.empty()) {
294
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
290
+ return { error::BAD_PARAM, {} };
295
291
  }
296
292
 
297
293
  if (server_first_message.empty()) {
@@ -299,7 +295,7 @@ ClientBackend::step(std::string_view input)
299
295
 
300
296
  AttributeMap attributes;
301
297
  if (!decodeAttributeList(server_first_message, attributes)) {
302
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
298
+ return { error::BAD_PARAM, {} };
303
299
  }
304
300
 
305
301
  for (const auto& attribute : attributes) {
@@ -314,24 +310,24 @@ ClientBackend::step(std::string_view input)
314
310
  try {
315
311
  iterationCount = static_cast<unsigned int>(std::stoul(attribute.second));
316
312
  } catch (...) {
317
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
313
+ return { error::BAD_PARAM, {} };
318
314
  }
319
315
  break;
320
316
  default:
321
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
317
+ return { error::BAD_PARAM, {} };
322
318
  }
323
319
  }
324
320
 
325
321
  if (attributes.find('r') == attributes.end() || attributes.find('s') == attributes.end() ||
326
322
  attributes.find('i') == attributes.end()) {
327
323
  spdlog::error("missing r/s/i in server message");
328
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
324
+ return { error::BAD_PARAM, {} };
329
325
  }
330
326
 
331
327
  // I've got the SALT, lets generate the salted password
332
328
  if (!generateSaltedPassword(passwordCallback())) {
333
329
  spdlog::error("failed to generated salted password");
334
- return std::make_pair<error, std::string_view>(error::FAIL, {});
330
+ return { error::FAIL, {} };
335
331
  }
336
332
 
337
333
  // Ok so we have salted hased password :D
@@ -346,34 +342,32 @@ ClientBackend::step(std::string_view input)
346
342
 
347
343
  client_final_message = out.str();
348
344
 
349
- return std::make_pair<error, std::string_view>(error::CONTINUE, client_final_message);
350
- } else {
351
- server_final_message.assign(input.data(), input.size());
352
-
353
- AttributeMap attributes;
354
- if (!decodeAttributeList(server_final_message, attributes)) {
355
- spdlog::error("SCRAM: failed to decode server-final-message");
356
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
357
- }
345
+ return { error::CONTINUE, client_final_message };
346
+ }
347
+ server_final_message.assign(input.data(), input.size());
358
348
 
359
- if (attributes.find('e') != attributes.end()) {
360
- spdlog::error("failed to authenticate: {}", attributes['e']);
361
- return std::make_pair<error, std::string_view>(error::FAIL, {});
362
- }
349
+ AttributeMap attributes;
350
+ if (!decodeAttributeList(server_final_message, attributes)) {
351
+ spdlog::error("SCRAM: failed to decode server-final-message");
352
+ return { error::BAD_PARAM, {} };
353
+ }
363
354
 
364
- if (attributes.find('v') == attributes.end()) {
365
- spdlog::error("syntax error server final message is missing 'v'");
366
- return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
367
- }
355
+ if (attributes.find('e') != attributes.end()) {
356
+ spdlog::error("failed to authenticate: {}", attributes['e']);
357
+ return { error::FAIL, {} };
358
+ }
368
359
 
369
- auto encoded = couchbase::base64::encode(getServerSignature());
370
- if (encoded != attributes['v']) {
371
- spdlog::error("incorrect ServerKey received");
372
- return std::make_pair<error, std::string_view>(error::FAIL, {});
373
- }
360
+ if (attributes.find('v') == attributes.end()) {
361
+ spdlog::error("syntax error server final message is missing 'v'");
362
+ return { error::BAD_PARAM, {} };
363
+ }
374
364
 
375
- return std::make_pair<error, std::string_view>(error::OK, {});
365
+ if (auto encoded = couchbase::base64::encode(getServerSignature()); encoded != attributes['v']) {
366
+ spdlog::error("incorrect ServerKey received");
367
+ return { error::FAIL, {} };
376
368
  }
369
+
370
+ return { error::OK, {} };
377
371
  }
378
372
 
379
373
  bool