couchbase 3.0.0.alpha.1-universal-darwin-19 → 3.0.0.alpha.2-universal-darwin-19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests-6.0.3.yml +49 -0
  3. data/.github/workflows/tests.yml +47 -0
  4. data/.gitmodules +3 -0
  5. data/.idea/dictionaries/gem_terms.xml +5 -0
  6. data/.idea/inspectionProfiles/Project_Default.xml +1 -0
  7. data/.idea/vcs.xml +1 -0
  8. data/Gemfile +1 -0
  9. data/README.md +55 -2
  10. data/Rakefile +18 -0
  11. data/bin/init-cluster +62 -0
  12. data/bin/setup +1 -0
  13. data/couchbase.gemspec +3 -2
  14. data/examples/crud.rb +1 -2
  15. data/examples/managing_buckets.rb +47 -0
  16. data/examples/managing_collections.rb +58 -0
  17. data/examples/managing_query_indexes.rb +63 -0
  18. data/examples/query.rb +3 -2
  19. data/examples/query_with_consistency.rb +76 -0
  20. data/examples/subdocument.rb +23 -1
  21. data/ext/.clang-format +1 -1
  22. data/ext/.idea/dictionaries/couchbase_terms.xml +2 -0
  23. data/ext/.idea/vcs.xml +1 -0
  24. data/ext/CMakeLists.txt +30 -12
  25. data/ext/build_version.hxx.in +26 -0
  26. data/ext/couchbase/bucket.hxx +69 -8
  27. data/ext/couchbase/cluster.hxx +70 -54
  28. data/ext/couchbase/collections_manifest.hxx +3 -3
  29. data/ext/couchbase/configuration.hxx +14 -0
  30. data/ext/couchbase/couchbase.cxx +2044 -383
  31. data/ext/couchbase/{operations/document_id.hxx → document_id.hxx} +5 -4
  32. data/ext/couchbase/io/http_message.hxx +5 -1
  33. data/ext/couchbase/io/http_parser.hxx +2 -1
  34. data/ext/couchbase/io/http_session.hxx +6 -3
  35. data/ext/couchbase/io/{binary_message.hxx → mcbp_message.hxx} +15 -12
  36. data/ext/couchbase/io/mcbp_parser.hxx +99 -0
  37. data/ext/couchbase/io/{key_value_session.hxx → mcbp_session.hxx} +200 -95
  38. data/ext/couchbase/io/session_manager.hxx +37 -22
  39. data/ext/couchbase/mutation_token.hxx +2 -1
  40. data/ext/couchbase/operations.hxx +38 -8
  41. data/ext/couchbase/operations/bucket_create.hxx +138 -0
  42. data/ext/couchbase/operations/bucket_drop.hxx +65 -0
  43. data/ext/couchbase/operations/bucket_flush.hxx +65 -0
  44. data/ext/couchbase/operations/bucket_get.hxx +69 -0
  45. data/ext/couchbase/operations/bucket_get_all.hxx +62 -0
  46. data/ext/couchbase/operations/bucket_settings.hxx +111 -0
  47. data/ext/couchbase/operations/bucket_update.hxx +115 -0
  48. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +60 -0
  49. data/ext/couchbase/operations/collection_create.hxx +86 -0
  50. data/ext/couchbase/operations/collection_drop.hxx +82 -0
  51. data/ext/couchbase/operations/command.hxx +10 -10
  52. data/ext/couchbase/operations/document_decrement.hxx +80 -0
  53. data/ext/couchbase/operations/document_exists.hxx +80 -0
  54. data/ext/couchbase/operations/{get.hxx → document_get.hxx} +4 -2
  55. data/ext/couchbase/operations/document_get_and_lock.hxx +64 -0
  56. data/ext/couchbase/operations/document_get_and_touch.hxx +64 -0
  57. data/ext/couchbase/operations/document_increment.hxx +80 -0
  58. data/ext/couchbase/operations/document_insert.hxx +74 -0
  59. data/ext/couchbase/operations/{lookup_in.hxx → document_lookup_in.hxx} +2 -2
  60. data/ext/couchbase/operations/{mutate_in.hxx → document_mutate_in.hxx} +11 -2
  61. data/ext/couchbase/operations/{query.hxx → document_query.hxx} +101 -6
  62. data/ext/couchbase/operations/document_remove.hxx +67 -0
  63. data/ext/couchbase/operations/document_replace.hxx +76 -0
  64. data/ext/couchbase/operations/{upsert.hxx → document_touch.hxx} +14 -14
  65. data/ext/couchbase/operations/{remove.hxx → document_unlock.hxx} +12 -10
  66. data/ext/couchbase/operations/document_upsert.hxx +74 -0
  67. data/ext/couchbase/operations/query_index_build_deferred.hxx +85 -0
  68. data/ext/couchbase/operations/query_index_create.hxx +134 -0
  69. data/ext/couchbase/operations/query_index_drop.hxx +108 -0
  70. data/ext/couchbase/operations/query_index_get_all.hxx +106 -0
  71. data/ext/couchbase/operations/scope_create.hxx +81 -0
  72. data/ext/couchbase/operations/scope_drop.hxx +79 -0
  73. data/ext/couchbase/operations/scope_get_all.hxx +72 -0
  74. data/ext/couchbase/protocol/client_opcode.hxx +35 -0
  75. data/ext/couchbase/protocol/client_request.hxx +56 -9
  76. data/ext/couchbase/protocol/client_response.hxx +52 -15
  77. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +81 -0
  78. data/ext/couchbase/protocol/cmd_decrement.hxx +187 -0
  79. data/ext/couchbase/protocol/cmd_exists.hxx +171 -0
  80. data/ext/couchbase/protocol/cmd_get.hxx +31 -8
  81. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +142 -0
  82. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +142 -0
  83. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +16 -3
  84. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +16 -3
  85. data/ext/couchbase/protocol/cmd_get_error_map.hxx +16 -3
  86. data/ext/couchbase/protocol/cmd_hello.hxx +24 -8
  87. data/ext/couchbase/protocol/cmd_increment.hxx +187 -0
  88. data/ext/couchbase/protocol/cmd_info.hxx +1 -0
  89. data/ext/couchbase/protocol/cmd_insert.hxx +172 -0
  90. data/ext/couchbase/protocol/cmd_lookup_in.hxx +28 -13
  91. data/ext/couchbase/protocol/cmd_mutate_in.hxx +65 -13
  92. data/ext/couchbase/protocol/cmd_remove.hxx +59 -4
  93. data/ext/couchbase/protocol/cmd_replace.hxx +172 -0
  94. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +15 -3
  95. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +15 -3
  96. data/ext/couchbase/protocol/cmd_sasl_step.hxx +15 -3
  97. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -2
  98. data/ext/couchbase/protocol/cmd_touch.hxx +102 -0
  99. data/ext/couchbase/protocol/cmd_unlock.hxx +95 -0
  100. data/ext/couchbase/protocol/cmd_upsert.hxx +50 -14
  101. data/ext/couchbase/protocol/durability_level.hxx +67 -0
  102. data/ext/couchbase/protocol/frame_info_id.hxx +187 -0
  103. data/ext/couchbase/protocol/hello_feature.hxx +137 -0
  104. data/ext/couchbase/protocol/server_opcode.hxx +57 -0
  105. data/ext/couchbase/protocol/server_request.hxx +122 -0
  106. data/ext/couchbase/protocol/unsigned_leb128.h +15 -15
  107. data/ext/couchbase/utils/byteswap.hxx +1 -2
  108. data/ext/couchbase/utils/url_codec.hxx +225 -0
  109. data/ext/couchbase/version.hxx +3 -1
  110. data/ext/extconf.rb +4 -1
  111. data/ext/test/main.cxx +37 -113
  112. data/ext/third_party/snappy/.appveyor.yml +36 -0
  113. data/ext/third_party/snappy/.gitignore +8 -0
  114. data/ext/third_party/snappy/.travis.yml +98 -0
  115. data/ext/third_party/snappy/AUTHORS +1 -0
  116. data/ext/third_party/snappy/CMakeLists.txt +345 -0
  117. data/ext/third_party/snappy/CONTRIBUTING.md +26 -0
  118. data/ext/third_party/snappy/COPYING +54 -0
  119. data/ext/third_party/snappy/NEWS +188 -0
  120. data/ext/third_party/snappy/README.md +148 -0
  121. data/ext/third_party/snappy/cmake/SnappyConfig.cmake.in +33 -0
  122. data/ext/third_party/snappy/cmake/config.h.in +59 -0
  123. data/ext/third_party/snappy/docs/README.md +72 -0
  124. data/ext/third_party/snappy/format_description.txt +110 -0
  125. data/ext/third_party/snappy/framing_format.txt +135 -0
  126. data/ext/third_party/snappy/snappy-c.cc +90 -0
  127. data/ext/third_party/snappy/snappy-c.h +138 -0
  128. data/ext/third_party/snappy/snappy-internal.h +315 -0
  129. data/ext/third_party/snappy/snappy-sinksource.cc +121 -0
  130. data/ext/third_party/snappy/snappy-sinksource.h +182 -0
  131. data/ext/third_party/snappy/snappy-stubs-internal.cc +42 -0
  132. data/ext/third_party/snappy/snappy-stubs-internal.h +493 -0
  133. data/ext/third_party/snappy/snappy-stubs-public.h.in +63 -0
  134. data/ext/third_party/snappy/snappy-test.cc +613 -0
  135. data/ext/third_party/snappy/snappy-test.h +526 -0
  136. data/ext/third_party/snappy/snappy.cc +1770 -0
  137. data/ext/third_party/snappy/snappy.h +209 -0
  138. data/ext/third_party/snappy/snappy_compress_fuzzer.cc +60 -0
  139. data/ext/third_party/snappy/snappy_uncompress_fuzzer.cc +58 -0
  140. data/ext/third_party/snappy/snappy_unittest.cc +1512 -0
  141. data/ext/third_party/snappy/testdata/alice29.txt +3609 -0
  142. data/ext/third_party/snappy/testdata/asyoulik.txt +4122 -0
  143. data/ext/third_party/snappy/testdata/baddata1.snappy +0 -0
  144. data/ext/third_party/snappy/testdata/baddata2.snappy +0 -0
  145. data/ext/third_party/snappy/testdata/baddata3.snappy +0 -0
  146. data/ext/third_party/snappy/testdata/fireworks.jpeg +0 -0
  147. data/ext/third_party/snappy/testdata/geo.protodata +0 -0
  148. data/ext/third_party/snappy/testdata/html +1 -0
  149. data/ext/third_party/snappy/testdata/html_x_4 +1 -0
  150. data/ext/third_party/snappy/testdata/kppkn.gtb +0 -0
  151. data/ext/third_party/snappy/testdata/lcet10.txt +7519 -0
  152. data/ext/third_party/snappy/testdata/paper-100k.pdf +600 -2
  153. data/ext/third_party/snappy/testdata/plrabn12.txt +10699 -0
  154. data/ext/third_party/snappy/testdata/urls.10K +10000 -0
  155. data/lib/couchbase/binary_collection.rb +33 -76
  156. data/lib/couchbase/binary_collection_options.rb +94 -0
  157. data/lib/couchbase/bucket.rb +9 -3
  158. data/lib/couchbase/cluster.rb +161 -23
  159. data/lib/couchbase/collection.rb +108 -191
  160. data/lib/couchbase/collection_options.rb +430 -0
  161. data/lib/couchbase/errors.rb +136 -134
  162. data/lib/couchbase/json_transcoder.rb +32 -0
  163. data/lib/couchbase/management/analytics_index_manager.rb +185 -9
  164. data/lib/couchbase/management/bucket_manager.rb +84 -33
  165. data/lib/couchbase/management/collection_manager.rb +166 -1
  166. data/lib/couchbase/management/query_index_manager.rb +261 -0
  167. data/lib/couchbase/management/search_index_manager.rb +291 -0
  168. data/lib/couchbase/management/user_manager.rb +12 -10
  169. data/lib/couchbase/management/view_index_manager.rb +151 -1
  170. data/lib/couchbase/mutation_state.rb +11 -1
  171. data/lib/couchbase/scope.rb +4 -4
  172. data/lib/couchbase/version.rb +1 -1
  173. metadata +113 -18
  174. data/.travis.yml +0 -7
  175. data/ext/couchbase/io/binary_parser.hxx +0 -64
  176. data/lib/couchbase/results.rb +0 -307
@@ -0,0 +1,142 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <protocol/unsigned_leb128.h>
21
+
22
+ #include <protocol/client_opcode.hxx>
23
+ #include <document_id.hxx>
24
+
25
+ namespace couchbase::protocol
26
+ {
27
+
28
+ class get_and_lock_response_body
29
+ {
30
+ public:
31
+ static const inline client_opcode opcode = client_opcode::get_and_lock;
32
+
33
+ private:
34
+ std::uint32_t flags_;
35
+ std::string value_;
36
+
37
+ public:
38
+ std::string& value()
39
+ {
40
+ return value_;
41
+ }
42
+
43
+ std::uint32_t flags()
44
+ {
45
+ return flags_;
46
+ }
47
+
48
+ bool parse(protocol::status status,
49
+ const header_buffer& header,
50
+ std::uint8_t framing_extras_size,
51
+ std::uint16_t key_size,
52
+ std::uint8_t extras_size,
53
+ const std::vector<uint8_t>& body,
54
+ const cmd_info&)
55
+ {
56
+ Expects(header[1] == static_cast<uint8_t>(opcode));
57
+ if (status == protocol::status::success) {
58
+ std::vector<uint8_t>::difference_type offset = framing_extras_size;
59
+ if (extras_size == 4) {
60
+ memcpy(&flags_, body.data() + offset, sizeof(flags_));
61
+ flags_ = ntohl(flags_);
62
+ offset += 4;
63
+ } else {
64
+ offset += extras_size;
65
+ }
66
+ offset += key_size;
67
+ value_.assign(body.begin() + offset, body.end());
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+ };
73
+
74
+ class get_and_lock_request_body
75
+ {
76
+ public:
77
+ using response_body_type = get_and_lock_response_body;
78
+ static const inline client_opcode opcode = client_opcode::get_and_lock;
79
+
80
+ private:
81
+ std::string key_;
82
+ std::uint32_t lock_time_;
83
+ std::vector<std::uint8_t> extras_{};
84
+
85
+ public:
86
+ void id(const document_id& id)
87
+ {
88
+ key_ = id.key;
89
+ if (id.collection_uid) {
90
+ unsigned_leb128<uint32_t> encoded(*id.collection_uid);
91
+ key_.insert(0, encoded.get());
92
+ }
93
+ }
94
+
95
+ void lock_time(std::uint32_t seconds)
96
+ {
97
+ lock_time_ = seconds;
98
+ }
99
+
100
+ const std::string& key()
101
+ {
102
+ return key_;
103
+ }
104
+
105
+ const std::vector<std::uint8_t>& framing_extras()
106
+ {
107
+ static std::vector<std::uint8_t> empty;
108
+ return empty;
109
+ }
110
+
111
+ const std::vector<std::uint8_t>& extras()
112
+ {
113
+ if (extras_.empty()) {
114
+ fill_extras();
115
+ }
116
+ return extras_;
117
+ }
118
+
119
+ const std::vector<std::uint8_t>& value()
120
+ {
121
+ static std::vector<std::uint8_t> empty;
122
+ return empty;
123
+ }
124
+
125
+ std::size_t size()
126
+ {
127
+ if (extras_.empty()) {
128
+ fill_extras();
129
+ }
130
+ return key_.size() + extras_.size();
131
+ }
132
+
133
+ private:
134
+ void fill_extras()
135
+ {
136
+ extras_.resize(sizeof(lock_time_));
137
+ uint32_t field = htonl(lock_time_);
138
+ memcpy(extras_.data(), &field, sizeof(field));
139
+ }
140
+ };
141
+
142
+ } // namespace couchbase::protocol
@@ -0,0 +1,142 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <protocol/unsigned_leb128.h>
21
+
22
+ #include <protocol/client_opcode.hxx>
23
+ #include <document_id.hxx>
24
+
25
+ namespace couchbase::protocol
26
+ {
27
+
28
+ class get_and_touch_response_body
29
+ {
30
+ public:
31
+ static const inline client_opcode opcode = client_opcode::get_and_touch;
32
+
33
+ private:
34
+ std::uint32_t flags_;
35
+ std::string value_;
36
+
37
+ public:
38
+ std::string& value()
39
+ {
40
+ return value_;
41
+ }
42
+
43
+ std::uint32_t flags()
44
+ {
45
+ return flags_;
46
+ }
47
+
48
+ bool parse(protocol::status status,
49
+ const header_buffer& header,
50
+ std::uint8_t framing_extras_size,
51
+ std::uint16_t key_size,
52
+ std::uint8_t extras_size,
53
+ const std::vector<uint8_t>& body,
54
+ const cmd_info&)
55
+ {
56
+ Expects(header[1] == static_cast<uint8_t>(opcode));
57
+ if (status == protocol::status::success) {
58
+ std::vector<uint8_t>::difference_type offset = framing_extras_size;
59
+ if (extras_size == 4) {
60
+ memcpy(&flags_, body.data() + offset, sizeof(flags_));
61
+ flags_ = ntohl(flags_);
62
+ offset += 4;
63
+ } else {
64
+ offset += extras_size;
65
+ }
66
+ offset += key_size;
67
+ value_.assign(body.begin() + offset, body.end());
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+ };
73
+
74
+ class get_and_touch_request_body
75
+ {
76
+ public:
77
+ using response_body_type = get_and_touch_response_body;
78
+ static const inline client_opcode opcode = client_opcode::get_and_touch;
79
+
80
+ private:
81
+ std::string key_;
82
+ std::uint32_t expiration_;
83
+ std::vector<std::uint8_t> extras_{};
84
+
85
+ public:
86
+ void id(const document_id& id)
87
+ {
88
+ key_ = id.key;
89
+ if (id.collection_uid) {
90
+ unsigned_leb128<uint32_t> encoded(*id.collection_uid);
91
+ key_.insert(0, encoded.get());
92
+ }
93
+ }
94
+
95
+ void expiration(std::uint32_t seconds)
96
+ {
97
+ expiration_ = seconds;
98
+ }
99
+
100
+ const std::string& key()
101
+ {
102
+ return key_;
103
+ }
104
+
105
+ const std::vector<std::uint8_t>& framing_extras()
106
+ {
107
+ static std::vector<std::uint8_t> empty;
108
+ return empty;
109
+ }
110
+
111
+ const std::vector<std::uint8_t>& extras()
112
+ {
113
+ if (extras_.empty()) {
114
+ fill_extras();
115
+ }
116
+ return extras_;
117
+ }
118
+
119
+ const std::vector<std::uint8_t>& value()
120
+ {
121
+ static std::vector<std::uint8_t> empty;
122
+ return empty;
123
+ }
124
+
125
+ std::size_t size()
126
+ {
127
+ if (extras_.empty()) {
128
+ fill_extras();
129
+ }
130
+ return key_.size() + extras_.size();
131
+ }
132
+
133
+ private:
134
+ void fill_extras()
135
+ {
136
+ extras_.resize(sizeof(expiration_));
137
+ uint32_t field = htonl(expiration_);
138
+ memcpy(extras_.data(), &field, sizeof(field));
139
+ }
140
+ };
141
+
142
+ } // namespace couchbase::protocol
@@ -61,11 +61,18 @@ class get_cluster_config_response_body
61
61
  return config_;
62
62
  }
63
63
 
64
- bool parse(protocol::status status, const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info& info)
64
+ bool parse(protocol::status status,
65
+ const header_buffer& header,
66
+ std::uint8_t framing_extras_size,
67
+ std::uint16_t key_size,
68
+ std::uint8_t extras_size,
69
+ const std::vector<uint8_t>& body,
70
+ const cmd_info& info)
65
71
  {
66
72
  Expects(header[1] == static_cast<uint8_t>(opcode));
67
73
  if (status == protocol::status::success) {
68
- config_ = tao::json::from_string<deduplicate_keys>(std::string(body.begin(), body.end())).as<configuration>();
74
+ std::vector<uint8_t>::difference_type offset = framing_extras_size + key_size + extras_size;
75
+ config_ = tao::json::from_string<deduplicate_keys>(std::string(body.begin() + offset, body.end())).as<configuration>();
69
76
  for (auto& node : config_.nodes) {
70
77
  if (node.this_node && node.hostname.empty()) {
71
78
  node.hostname = info.remote_endpoint.address().to_string();
@@ -90,7 +97,13 @@ class get_cluster_config_request_body
90
97
  return empty;
91
98
  }
92
99
 
93
- const std::vector<std::uint8_t>& extension()
100
+ const std::vector<std::uint8_t>& framing_extras()
101
+ {
102
+ static std::vector<std::uint8_t> empty;
103
+ return empty;
104
+ }
105
+
106
+ const std::vector<std::uint8_t>& extras()
94
107
  {
95
108
  static std::vector<std::uint8_t> empty;
96
109
  return empty;
@@ -42,11 +42,18 @@ class get_collections_manifest_response_body
42
42
  return manifest_;
43
43
  }
44
44
 
45
- bool parse(protocol::status status, const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info&)
45
+ bool parse(protocol::status status,
46
+ const header_buffer& header,
47
+ std::uint8_t framing_extras_size,
48
+ std::uint16_t key_size,
49
+ std::uint8_t extras_size,
50
+ const std::vector<uint8_t>& body,
51
+ const cmd_info&)
46
52
  {
47
53
  Expects(header[1] == static_cast<uint8_t>(opcode));
48
54
  if (status == protocol::status::success) {
49
- manifest_ = tao::json::from_string(std::string(body.begin(), body.end())).as<collections_manifest>();
55
+ std::vector<uint8_t>::difference_type offset = framing_extras_size + key_size + extras_size;
56
+ manifest_ = tao::json::from_string(std::string(body.begin() + offset, body.end())).as<collections_manifest>();
50
57
  return true;
51
58
  }
52
59
  return false;
@@ -65,7 +72,13 @@ class get_collections_manifest_request_body
65
72
  return empty;
66
73
  }
67
74
 
68
- const std::vector<std::uint8_t>& extension()
75
+ const std::vector<std::uint8_t>& framing_extras()
76
+ {
77
+ static std::vector<std::uint8_t> empty;
78
+ return empty;
79
+ }
80
+
81
+ const std::vector<std::uint8_t>& extras()
69
82
  {
70
83
  static std::vector<std::uint8_t> empty;
71
84
  return empty;
@@ -42,12 +42,19 @@ class get_error_map_response_body
42
42
  return errmap_;
43
43
  }
44
44
 
45
- bool parse(protocol::status status, const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info&)
45
+ bool parse(protocol::status status,
46
+ const header_buffer& header,
47
+ std::uint8_t framing_extras_size,
48
+ std::uint16_t key_size,
49
+ std::uint8_t extras_size,
50
+ const std::vector<uint8_t>& body,
51
+ const cmd_info&)
46
52
  {
47
53
  Expects(header[1] == static_cast<uint8_t>(opcode));
48
54
  if (status == protocol::status::success) {
49
55
  try {
50
- errmap_ = tao::json::from_string(std::string(body.begin(), body.end())).as<error_map>();
56
+ std::vector<uint8_t>::difference_type offset = framing_extras_size + key_size + extras_size;
57
+ errmap_ = tao::json::from_string(std::string(body.begin() + offset, body.end())).as<error_map>();
51
58
  } catch (tao::json::pegtl::parse_error& e) {
52
59
  spdlog::critical("unable to parse JSON: {}", std::string(body.begin(), body.end()));
53
60
  }
@@ -79,7 +86,13 @@ class get_error_map_request_body
79
86
  return empty;
80
87
  }
81
88
 
82
- const std::vector<std::uint8_t>& extension()
89
+ const std::vector<std::uint8_t>& framing_extras()
90
+ {
91
+ static std::vector<std::uint8_t> empty;
92
+ return empty;
93
+ }
94
+
95
+ const std::vector<std::uint8_t>& extras()
83
96
  {
84
97
  static std::vector<std::uint8_t> empty;
85
98
  return empty;
@@ -36,16 +36,25 @@ class hello_response_body
36
36
  return supported_features_;
37
37
  }
38
38
 
39
- bool parse(protocol::status status, const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info&)
39
+ bool parse(protocol::status status,
40
+ const header_buffer& header,
41
+ std::uint8_t framing_extras_size,
42
+ std::uint16_t key_size,
43
+ std::uint8_t extras_size,
44
+ const std::vector<uint8_t>& body,
45
+ const cmd_info&)
40
46
  {
41
47
  Expects(header[1] == static_cast<uint8_t>(opcode));
42
48
  if (status == protocol::status::success) {
43
- Expects(body.size() % 2 == 0);
44
- size_t num_features = body.size() / 2;
49
+ std::vector<uint8_t>::difference_type offset = framing_extras_size + key_size + extras_size;
50
+ size_t value_size = body.size() - static_cast<std::size_t>(offset);
51
+ Expects(value_size % 2 == 0);
52
+ size_t num_features = value_size / 2;
45
53
  supported_features_.reserve(num_features);
54
+ const auto* value = body.data() + offset;
46
55
  for (size_t i = 0; i < num_features; i++) {
47
56
  std::uint16_t field = 0;
48
- std::memcpy(&field, body.data() + i * 2, sizeof(std::uint16_t));
57
+ std::memcpy(&field, value + i * 2, sizeof(std::uint16_t));
49
58
  field = ntohs(field);
50
59
  if (is_valid_hello_feature(field)) {
51
60
  supported_features_.push_back(static_cast<hello_feature>(field));
@@ -66,7 +75,6 @@ class hello_request_body
66
75
  private:
67
76
  std::string key_;
68
77
  std::vector<hello_feature> features_{
69
- hello_feature::tls,
70
78
  hello_feature::tcp_nodelay,
71
79
  hello_feature::mutation_seqno,
72
80
  hello_feature::xattr,
@@ -77,9 +85,11 @@ class hello_request_body
77
85
  hello_feature::duplex,
78
86
  hello_feature::clustermap_change_notification,
79
87
  hello_feature::unordered_execution,
80
- // hello_feature::alt_request_support,
81
- // hello_feature::sync_replication,
88
+ hello_feature::alt_request_support,
89
+ hello_feature::tracing,
90
+ hello_feature::sync_replication,
82
91
  hello_feature::vattr,
92
+ hello_feature::collections,
83
93
  };
84
94
  std::vector<std::uint8_t> value_;
85
95
 
@@ -94,7 +104,13 @@ class hello_request_body
94
104
  return key_;
95
105
  }
96
106
 
97
- const std::vector<std::uint8_t>& extension()
107
+ const std::vector<std::uint8_t>& framing_extras()
108
+ {
109
+ static std::vector<std::uint8_t> empty;
110
+ return empty;
111
+ }
112
+
113
+ const std::vector<std::uint8_t>& extras()
98
114
  {
99
115
  static std::vector<std::uint8_t> empty;
100
116
  return empty;