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
@@ -33,6 +33,34 @@
33
33
  namespace couchbase::protocol
34
34
  {
35
35
 
36
+ double
37
+ parse_server_duration_us(const io::mcbp_message& msg)
38
+ {
39
+ if (msg.header.magic != static_cast<std::uint8_t>(magic::alt_client_response)) {
40
+ return 0;
41
+ }
42
+ std::uint8_t framing_extras_size = static_cast<std::uint8_t>(msg.header.keylen & 0xfU);
43
+ if (framing_extras_size == 0) {
44
+ return 0;
45
+ }
46
+ std::size_t offset = 0;
47
+ while (offset < framing_extras_size) {
48
+ std::uint8_t frame_size = static_cast<std::uint8_t>(msg.body[offset] & 0xfU);
49
+ std::uint8_t frame_id = static_cast<std::uint8_t>((static_cast<std::uint32_t>(msg.body[offset]) >> 4U) & 0xfU);
50
+ offset++;
51
+ if (frame_id == static_cast<std::uint8_t>(response_frame_info_id::server_duration)) {
52
+ if (frame_size == 2 && framing_extras_size - offset >= frame_size) {
53
+ std::uint16_t encoded_duration{};
54
+ std::memcpy(&encoded_duration, msg.body.data() + offset, sizeof(encoded_duration));
55
+ encoded_duration = ntohs(encoded_duration);
56
+ return std::pow(encoded_duration, 1.74) / 2;
57
+ }
58
+ }
59
+ offset += frame_size;
60
+ }
61
+ return 0;
62
+ }
63
+
36
64
  template<typename Body>
37
65
  class client_response
38
66
  {
@@ -55,7 +83,7 @@ class client_response
55
83
 
56
84
  public:
57
85
  client_response() = default;
58
- explicit client_response(io::mcbp_message& msg)
86
+ explicit client_response(io::mcbp_message&& msg)
59
87
  {
60
88
  header_ = msg.header_data();
61
89
  data_ = std::move(msg.body);
@@ -108,15 +136,15 @@ class client_response
108
136
  Expects(header_[0] == static_cast<std::uint8_t>(magic::alt_client_response) ||
109
137
  header_[0] == static_cast<std::uint8_t>(magic::client_response));
110
138
  Expects(header_[1] == static_cast<std::uint8_t>(Body::opcode));
111
- magic_ = static_cast<magic>(header_[0]);
112
- opcode_ = static_cast<client_opcode>(header_[1]);
139
+ magic_ = magic(header_[0]);
140
+ opcode_ = client_opcode(header_[1]);
113
141
  data_type_ = header_[5];
114
142
 
115
143
  uint16_t status = 0;
116
144
  memcpy(&status, header_.data() + 6, sizeof(status));
117
145
  status = ntohs(status);
118
146
  Expects(protocol::is_valid_status(status));
119
- status_ = static_cast<protocol::status>(status);
147
+ status_ = protocol::status(status);
120
148
 
121
149
  extras_size_ = header_[4];
122
150
  if (magic_ == magic::alt_client_response) {
@@ -143,7 +171,7 @@ class client_response
143
171
  return error_;
144
172
  }
145
173
 
146
- [[nodiscard]] std::string error_message()
174
+ [[nodiscard]] std::string error_message() const
147
175
  {
148
176
  if (error_) {
149
177
  return fmt::format(R"(magic={}, opcode={}, status={}, error={})", magic_, opcode_, status_, *error_);
@@ -161,12 +189,10 @@ class client_response
161
189
  auto& err_obj = error["error"];
162
190
  if (err_obj.is_object()) {
163
191
  enhanced_error_info err{};
164
- auto& ref = err_obj["ref"];
165
- if (ref.is_string()) {
192
+ if (auto& ref = err_obj["ref"]; ref.is_string()) {
166
193
  err.reference = ref.get_string();
167
194
  }
168
- auto& ctx = err_obj["context"];
169
- if (ctx.is_string()) {
195
+ if (auto& ctx = err_obj["context"]; ctx.is_string()) {
170
196
  err.context = ctx.get_string();
171
197
  }
172
198
  error_.emplace(err);
@@ -185,13 +211,12 @@ class client_response
185
211
  std::uint8_t frame_size = data_[offset] & 0xfU;
186
212
  std::uint8_t frame_id = (static_cast<std::uint32_t>(data_[offset]) >> 4U) & 0xfU;
187
213
  offset++;
188
- if (frame_id == static_cast<std::uint8_t>(response_frame_info_id::server_duration)) {
189
- if (frame_size == 2 && framing_extras_size_ - offset >= frame_size) {
190
- std::uint16_t encoded_duration{};
191
- std::memcpy(&encoded_duration, data_.data() + offset, sizeof(encoded_duration));
192
- encoded_duration = ntohs(encoded_duration);
193
- info_.server_duration_us = std::pow(encoded_duration, 1.74) / 2;
194
- }
214
+ if (frame_id == static_cast<std::uint8_t>(response_frame_info_id::server_duration) && frame_size == 2 &&
215
+ framing_extras_size_ - offset >= frame_size) {
216
+ std::uint16_t encoded_duration{};
217
+ std::memcpy(&encoded_duration, data_.data() + offset, sizeof(encoded_duration));
218
+ encoded_duration = ntohs(encoded_duration);
219
+ info_.server_duration_us = std::pow(encoded_duration, 1.74) / 2;
195
220
  }
196
221
  offset += frame_size;
197
222
  }
@@ -18,13 +18,13 @@
18
18
  #pragma once
19
19
 
20
20
  #include <document_id.hxx>
21
- #include <protocol/status.hxx>
21
+ #include <mutation_token.hxx>
22
22
  #include <protocol/client_opcode.hxx>
23
+ #include <protocol/cmd_info.hxx>
24
+ #include <protocol/durability_level.hxx>
23
25
  #include <protocol/frame_info_id.hxx>
26
+ #include <protocol/status.hxx>
24
27
  #include <protocol/unsigned_leb128.h>
25
- #include <protocol/durability_level.hxx>
26
- #include <protocol/cmd_info.hxx>
27
- #include <mutation_token.hxx>
28
28
  #include <utils/byteswap.hxx>
29
29
 
30
30
  namespace couchbase::protocol
@@ -36,10 +36,10 @@ class append_response_body
36
36
  static const inline client_opcode opcode = client_opcode::append;
37
37
 
38
38
  private:
39
- mutation_token token_;
39
+ mutation_token token_{};
40
40
 
41
41
  public:
42
- mutation_token& token()
42
+ [[nodiscard]] const mutation_token& token() const
43
43
  {
44
44
  return token_;
45
45
  }
@@ -47,10 +47,10 @@ class append_response_body
47
47
  bool parse(protocol::status status,
48
48
  const header_buffer& header,
49
49
  std::uint8_t framing_extras_size,
50
- std::uint16_t,
50
+ std::uint16_t /* key_size */,
51
51
  std::uint8_t extras_size,
52
52
  const std::vector<uint8_t>& body,
53
- const cmd_info&)
53
+ const cmd_info& /* info */)
54
54
  {
55
55
  Expects(header[1] == static_cast<uint8_t>(opcode));
56
56
  if (status == protocol::status::success) {
@@ -81,6 +81,8 @@ class append_request_body
81
81
  std::vector<std::uint8_t> content_{};
82
82
  std::vector<std::uint8_t> framing_extras_{};
83
83
 
84
+ static inline std::vector<std::uint8_t> empty;
85
+
84
86
  public:
85
87
  void id(const document_id& id)
86
88
  {
@@ -110,33 +112,32 @@ class append_request_body
110
112
  }
111
113
  }
112
114
 
113
- void content(const std::string& content)
115
+ void content(const std::string_view& content)
114
116
  {
115
117
  content_ = { content.begin(), content.end() };
116
118
  }
117
119
 
118
- const std::string& key()
120
+ [[nodiscard]] const std::string& key() const
119
121
  {
120
122
  return key_;
121
123
  }
122
124
 
123
- const std::vector<std::uint8_t>& framing_extras()
125
+ [[nodiscard]] const std::vector<std::uint8_t>& framing_extras() const
124
126
  {
125
127
  return framing_extras_;
126
128
  }
127
129
 
128
- const std::vector<std::uint8_t>& extras()
130
+ [[nodiscard]] const std::vector<std::uint8_t>& extras() const
129
131
  {
130
- static std::vector<std::uint8_t> empty;
131
- return empty;
132
+ return empty_buffer;
132
133
  }
133
134
 
134
- const std::vector<std::uint8_t>& value()
135
+ [[nodiscard]] const std::vector<std::uint8_t>& value() const
135
136
  {
136
137
  return content_;
137
138
  }
138
139
 
139
- std::size_t size()
140
+ [[nodiscard]] std::size_t size() const
140
141
  {
141
142
  return framing_extras_.size() + key_.size() + content_.size();
142
143
  }
@@ -19,8 +19,8 @@
19
19
 
20
20
  #include <gsl/gsl_assert>
21
21
 
22
- #include <protocol/server_opcode.hxx>
23
22
  #include <protocol/cmd_info.hxx>
23
+ #include <protocol/server_opcode.hxx>
24
24
 
25
25
  #include <configuration.hxx>
26
26
 
@@ -38,12 +38,12 @@ class cluster_map_change_notification_request_body
38
38
  std::optional<configuration> config_;
39
39
 
40
40
  public:
41
- [[nodiscard]] uint32_t protocol_revision()
41
+ [[nodiscard]] uint32_t protocol_revision() const
42
42
  {
43
43
  return protocol_revision_;
44
44
  }
45
45
 
46
- [[nodiscard]] const std::string& bucket()
46
+ [[nodiscard]] const std::string& bucket() const
47
47
  {
48
48
  return bucket_;
49
49
  }
@@ -53,7 +53,7 @@ class cluster_map_change_notification_request_body
53
53
  return config_;
54
54
  }
55
55
 
56
- bool parse(const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info&)
56
+ bool parse(const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info& /* info */)
57
57
  {
58
58
  Expects(header[1] == static_cast<uint8_t>(opcode));
59
59
  using offset_type = std::vector<uint8_t>::difference_type;
@@ -31,16 +31,16 @@ class decrement_response_body
31
31
  static const inline client_opcode opcode = client_opcode::decrement;
32
32
 
33
33
  private:
34
- mutation_token token_;
35
- std::uint64_t content_;
34
+ mutation_token token_{};
35
+ std::uint64_t content_{};
36
36
 
37
37
  public:
38
- std::uint64_t content()
38
+ [[nodiscard]] std::uint64_t content() const
39
39
  {
40
40
  return content_;
41
41
  }
42
42
 
43
- mutation_token& token()
43
+ [[nodiscard]] const mutation_token& token() const
44
44
  {
45
45
  return token_;
46
46
  }
@@ -51,7 +51,7 @@ class decrement_response_body
51
51
  std::uint16_t key_size,
52
52
  std::uint8_t extras_size,
53
53
  const std::vector<uint8_t>& body,
54
- const cmd_info&)
54
+ const cmd_info& /* info */)
55
55
  {
56
56
  Expects(header[1] == static_cast<uint8_t>(opcode));
57
57
  if (status == protocol::status::success) {
@@ -142,17 +142,17 @@ class decrement_request_body
142
142
  framing_extras_[extras_size + 0] = static_cast<std::uint8_t>(static_cast<std::uint32_t>(frame_id) << 4U | 0U);
143
143
  }
144
144
 
145
- const std::string& key()
145
+ [[nodiscard]] const std::string& key() const
146
146
  {
147
147
  return key_;
148
148
  }
149
149
 
150
- const std::vector<std::uint8_t>& framing_extras()
150
+ [[nodiscard]] const std::vector<std::uint8_t>& framing_extras() const
151
151
  {
152
152
  return framing_extras_;
153
153
  }
154
154
 
155
- const std::vector<std::uint8_t>& extras()
155
+ [[nodiscard]] const std::vector<std::uint8_t>& extras()
156
156
  {
157
157
  if (extras_.empty()) {
158
158
  fill_extras();
@@ -160,10 +160,9 @@ class decrement_request_body
160
160
  return extras_;
161
161
  }
162
162
 
163
- const std::vector<std::uint8_t>& value()
163
+ [[nodiscard]] const std::vector<std::uint8_t>& value() const
164
164
  {
165
- static std::vector<std::uint8_t> empty;
166
- return empty;
165
+ return empty_buffer;
167
166
  }
168
167
 
169
168
  [[nodiscard]] std::size_t size()
@@ -37,22 +37,22 @@ class exists_response_body
37
37
  std::uint64_t cas_;
38
38
 
39
39
  public:
40
- [[nodiscard]] std::uint16_t partition_id()
40
+ [[nodiscard]] std::uint16_t partition_id() const
41
41
  {
42
42
  return partition_id_;
43
43
  }
44
44
 
45
- [[nodiscard]] std::uint64_t cas()
45
+ [[nodiscard]] std::uint64_t cas() const
46
46
  {
47
47
  return cas_;
48
48
  }
49
49
 
50
- [[nodiscard]] const std::string& key()
50
+ [[nodiscard]] const std::string& key() const
51
51
  {
52
52
  return key_;
53
53
  }
54
54
 
55
- [[nodiscard]] std::uint8_t status()
55
+ [[nodiscard]] std::uint8_t status() const
56
56
  {
57
57
  return status_;
58
58
  }
@@ -115,26 +115,23 @@ class exists_request_body
115
115
  }
116
116
  }
117
117
 
118
- const std::string& key()
118
+ [[nodiscard]] const std::string& key() const
119
119
  {
120
120
  /* for observe key goes in the body */
121
- static std::string empty;
122
- return empty;
121
+ return empty_string;
123
122
  }
124
123
 
125
- const std::vector<std::uint8_t>& framing_extras()
124
+ [[nodiscard]] const std::vector<std::uint8_t>& framing_extras() const
126
125
  {
127
- static std::vector<std::uint8_t> empty;
128
- return empty;
126
+ return empty_buffer;
129
127
  }
130
128
 
131
- const std::vector<std::uint8_t>& extras()
129
+ [[nodiscard]] const std::vector<std::uint8_t>& extras() const
132
130
  {
133
- static std::vector<std::uint8_t> empty;
134
- return empty;
131
+ return empty_buffer;
135
132
  }
136
133
 
137
- const std::vector<std::uint8_t>& value()
134
+ [[nodiscard]] const std::vector<std::uint8_t>& value()
138
135
  {
139
136
  if (value_.empty()) {
140
137
  fill_body();
@@ -142,7 +139,7 @@ class exists_request_body
142
139
  return value_;
143
140
  }
144
141
 
145
- std::size_t size()
142
+ [[nodiscard]] std::size_t size()
146
143
  {
147
144
  if (value_.empty()) {
148
145
  fill_body();
@@ -35,12 +35,12 @@ class get_response_body
35
35
  std::string value_;
36
36
 
37
37
  public:
38
- std::string& value()
38
+ [[nodiscard]] const std::string& value() const
39
39
  {
40
40
  return value_;
41
41
  }
42
42
 
43
- std::uint32_t flags()
43
+ [[nodiscard]] std::uint32_t flags() const
44
44
  {
45
45
  return flags_;
46
46
  }
@@ -51,7 +51,7 @@ class get_response_body
51
51
  std::uint16_t key_size,
52
52
  std::uint8_t extras_size,
53
53
  const std::vector<uint8_t>& body,
54
- const cmd_info&)
54
+ const cmd_info& /* info */)
55
55
  {
56
56
  Expects(header[1] == static_cast<uint8_t>(opcode));
57
57
  if (status == protocol::status::success) {
@@ -90,30 +90,27 @@ class get_request_body
90
90
  }
91
91
  }
92
92
 
93
- const std::string& key()
93
+ [[nodiscard]] const std::string& key() const
94
94
  {
95
95
  return key_;
96
96
  }
97
97
 
98
- const std::vector<std::uint8_t>& framing_extras()
98
+ [[nodiscard]] const std::vector<std::uint8_t>& framing_extras() const
99
99
  {
100
- static std::vector<std::uint8_t> empty;
101
- return empty;
100
+ return empty_buffer;
102
101
  }
103
102
 
104
- const std::vector<std::uint8_t>& extras()
103
+ [[nodiscard]] const std::vector<std::uint8_t>& extras() const
105
104
  {
106
- static std::vector<std::uint8_t> empty;
107
- return empty;
105
+ return empty_buffer;
108
106
  }
109
107
 
110
- const std::vector<std::uint8_t>& value()
108
+ [[nodiscard]] const std::vector<std::uint8_t>& value() const
111
109
  {
112
- static std::vector<std::uint8_t> empty;
113
- return empty;
110
+ return empty_buffer;
114
111
  }
115
112
 
116
- std::size_t size()
113
+ [[nodiscard]] std::size_t size() const
117
114
  {
118
115
  return key_.size();
119
116
  }
@@ -35,12 +35,12 @@ class get_and_lock_response_body
35
35
  std::string value_;
36
36
 
37
37
  public:
38
- std::string& value()
38
+ [[nodiscard]] const std::string& value() const
39
39
  {
40
40
  return value_;
41
41
  }
42
42
 
43
- std::uint32_t flags()
43
+ [[nodiscard]] std::uint32_t flags() const
44
44
  {
45
45
  return flags_;
46
46
  }
@@ -51,7 +51,7 @@ class get_and_lock_response_body
51
51
  std::uint16_t key_size,
52
52
  std::uint8_t extras_size,
53
53
  const std::vector<uint8_t>& body,
54
- const cmd_info&)
54
+ const cmd_info& /* info */)
55
55
  {
56
56
  Expects(header[1] == static_cast<uint8_t>(opcode));
57
57
  if (status == protocol::status::success) {
@@ -97,18 +97,17 @@ class get_and_lock_request_body
97
97
  lock_time_ = seconds;
98
98
  }
99
99
 
100
- const std::string& key()
100
+ [[nodiscard]] const std::string& key() const
101
101
  {
102
102
  return key_;
103
103
  }
104
104
 
105
- const std::vector<std::uint8_t>& framing_extras()
105
+ [[nodiscard]] const std::vector<std::uint8_t>& framing_extras() const
106
106
  {
107
- static std::vector<std::uint8_t> empty;
108
- return empty;
107
+ return empty_buffer;
109
108
  }
110
109
 
111
- const std::vector<std::uint8_t>& extras()
110
+ [[nodiscard]] const std::vector<std::uint8_t>& extras()
112
111
  {
113
112
  if (extras_.empty()) {
114
113
  fill_extras();
@@ -116,13 +115,12 @@ class get_and_lock_request_body
116
115
  return extras_;
117
116
  }
118
117
 
119
- const std::vector<std::uint8_t>& value()
118
+ [[nodiscard]] const std::vector<std::uint8_t>& value() const
120
119
  {
121
- static std::vector<std::uint8_t> empty;
122
- return empty;
120
+ return empty_buffer;
123
121
  }
124
122
 
125
- std::size_t size()
123
+ [[nodiscard]] std::size_t size()
126
124
  {
127
125
  if (extras_.empty()) {
128
126
  fill_extras();