couchbase 3.5.6 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/cache/extconf_include.rb +3 -3
  4. data/ext/cache/mozilla-ca-bundle.crt +3 -165
  5. data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
  6. data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/CMakeLists.txt +14 -10
  7. data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.cc +7 -4
  8. data/ext/couchbase/CMakeLists.txt +12 -1
  9. data/ext/couchbase/cmake/Profiler.cmake +15 -0
  10. data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +2 -2
  11. data/ext/couchbase/cmake/couchbase_cxx_client.pc.in +1 -1
  12. data/ext/couchbase/core/app_telemetry_address.cxx +55 -0
  13. data/ext/couchbase/core/app_telemetry_address.hxx +39 -0
  14. data/ext/couchbase/core/app_telemetry_meter.cxx +753 -0
  15. data/ext/couchbase/core/app_telemetry_meter.hxx +198 -0
  16. data/ext/couchbase/core/app_telemetry_reporter.cxx +895 -0
  17. data/ext/couchbase/core/app_telemetry_reporter.hxx +59 -0
  18. data/ext/couchbase/core/bucket.cxx +77 -35
  19. data/ext/couchbase/core/bucket.hxx +17 -10
  20. data/ext/couchbase/core/cluster.cxx +54 -16
  21. data/ext/couchbase/core/cluster_credentials.cxx +27 -0
  22. data/ext/couchbase/core/cluster_credentials.hxx +36 -0
  23. data/ext/couchbase/core/cluster_options.hxx +12 -0
  24. data/ext/couchbase/core/collections_component.cxx +7 -5
  25. data/ext/couchbase/core/http_component.cxx +6 -0
  26. data/ext/couchbase/core/impl/binary_collection.cxx +4 -0
  27. data/ext/couchbase/core/impl/bucket_manager.cxx +2 -0
  28. data/ext/couchbase/core/impl/cluster.cxx +9 -0
  29. data/ext/couchbase/core/impl/collection.cxx +2 -0
  30. data/ext/couchbase/core/impl/error.cxx +1 -0
  31. data/ext/couchbase/core/impl/logger.cxx +51 -0
  32. data/ext/couchbase/core/impl/replica_utils.cxx +1 -1
  33. data/ext/couchbase/core/impl/transaction_get_multi_replicas_from_preferred_server_group_spec.cxx +32 -0
  34. data/ext/couchbase/core/impl/transaction_get_multi_spec.cxx +30 -0
  35. data/ext/couchbase/core/impl/transaction_op_error_category.cxx +2 -0
  36. data/ext/couchbase/core/io/config_tracker.cxx +6 -6
  37. data/ext/couchbase/core/io/http_command.hxx +35 -11
  38. data/ext/couchbase/core/io/http_session.cxx +10 -0
  39. data/ext/couchbase/core/io/http_session.hxx +4 -0
  40. data/ext/couchbase/core/io/http_session_manager.hxx +83 -34
  41. data/ext/couchbase/core/io/mcbp_command.hxx +41 -2
  42. data/ext/couchbase/core/io/mcbp_session.cxx +52 -19
  43. data/ext/couchbase/core/io/mcbp_session.hxx +3 -0
  44. data/ext/couchbase/core/logger/logger.cxx +46 -0
  45. data/ext/couchbase/core/logger/logger.hxx +41 -1
  46. data/ext/couchbase/core/management/bucket_settings.hxx +1 -0
  47. data/ext/couchbase/core/management/bucket_settings_json.hxx +4 -0
  48. data/ext/couchbase/core/meta/features.hxx +32 -0
  49. data/ext/couchbase/core/operations/document_analytics.cxx +9 -9
  50. data/ext/couchbase/core/operations/document_append.cxx +1 -0
  51. data/ext/couchbase/core/operations/document_append.hxx +1 -0
  52. data/ext/couchbase/core/operations/document_get_all_replicas.hxx +10 -2
  53. data/ext/couchbase/core/operations/document_lookup_in.cxx +4 -0
  54. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +14 -2
  55. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +4 -0
  56. data/ext/couchbase/core/operations/document_mutate_in.cxx +4 -0
  57. data/ext/couchbase/core/operations/document_mutate_in.hxx +1 -0
  58. data/ext/couchbase/core/operations/document_prepend.cxx +1 -0
  59. data/ext/couchbase/core/operations/document_prepend.hxx +1 -0
  60. data/ext/couchbase/core/operations/document_query.cxx +12 -10
  61. data/ext/couchbase/core/operations/http_noop.cxx +1 -0
  62. data/ext/couchbase/core/operations/management/bucket_create.cxx +3 -0
  63. data/ext/couchbase/core/operations/management/bucket_update.cxx +3 -0
  64. data/ext/couchbase/core/origin.cxx +0 -5
  65. data/ext/couchbase/core/origin.hxx +2 -11
  66. data/ext/couchbase/core/platform/random.cc +6 -3
  67. data/ext/couchbase/core/platform/random.h +2 -2
  68. data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +9 -0
  69. data/ext/couchbase/core/timeout_defaults.hxx +4 -0
  70. data/ext/couchbase/core/topology/configuration.cxx +10 -13
  71. data/ext/couchbase/core/topology/configuration.hxx +14 -15
  72. data/ext/couchbase/core/topology/configuration_json.hxx +6 -0
  73. data/ext/couchbase/core/transactions/async_attempt_context.hxx +22 -2
  74. data/ext/couchbase/core/transactions/attempt_context.hxx +25 -7
  75. data/ext/couchbase/core/transactions/attempt_context_impl.cxx +688 -238
  76. data/ext/couchbase/core/transactions/attempt_context_impl.hxx +91 -12
  77. data/ext/couchbase/core/transactions/exceptions.cxx +5 -0
  78. data/ext/couchbase/core/transactions/exceptions.hxx +20 -0
  79. data/ext/couchbase/core/transactions/exceptions_fmt.hxx +3 -0
  80. data/ext/couchbase/core/transactions/forward_compat.cxx +71 -6
  81. data/ext/couchbase/core/transactions/forward_compat.hxx +45 -59
  82. data/ext/couchbase/core/transactions/get_multi_orchestrator.cxx +616 -0
  83. data/ext/couchbase/core/transactions/get_multi_orchestrator.hxx +61 -0
  84. data/ext/couchbase/core/transactions/internal/doc_record.cxx +8 -0
  85. data/ext/couchbase/core/transactions/internal/doc_record.hxx +16 -5
  86. data/ext/couchbase/core/transactions/internal/exceptions_internal.hxx +12 -0
  87. data/ext/couchbase/core/transactions/internal/transaction_context.hxx +13 -0
  88. data/ext/couchbase/core/transactions/internal/transaction_fields.hxx +1 -0
  89. data/ext/couchbase/core/transactions/staged_mutation.cxx +277 -96
  90. data/ext/couchbase/core/transactions/staged_mutation.hxx +28 -76
  91. data/ext/couchbase/core/transactions/transaction_context.cxx +33 -0
  92. data/ext/couchbase/core/transactions/transaction_get_multi_mode.hxx +28 -0
  93. data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +27 -0
  94. data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +71 -0
  95. data/ext/couchbase/core/transactions/transaction_get_multi_result.hxx +66 -0
  96. data/ext/couchbase/core/transactions/transaction_links.hxx +10 -0
  97. data/ext/couchbase/core/transactions/transactions.cxx +8 -3
  98. data/ext/couchbase/core/utils/connection_string.cxx +4 -0
  99. data/ext/couchbase/core/utils/url_codec.cxx +26 -0
  100. data/ext/couchbase/core/utils/url_codec.hxx +11 -0
  101. data/ext/couchbase/core/websocket_codec.cxx +647 -0
  102. data/ext/couchbase/core/websocket_codec.hxx +77 -0
  103. data/ext/couchbase/couchbase/analytics_options.hxx +70 -6
  104. data/ext/couchbase/couchbase/application_telemetry_options.hxx +124 -0
  105. data/ext/couchbase/couchbase/cluster_options.hxx +17 -0
  106. data/ext/couchbase/couchbase/error_codes.hxx +1 -0
  107. data/ext/couchbase/couchbase/logger.hxx +16 -0
  108. data/ext/couchbase/couchbase/management/bucket_settings.hxx +1 -0
  109. data/ext/couchbase/couchbase/query_options.hxx +70 -6
  110. data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +29 -5
  111. data/ext/couchbase/couchbase/transactions/attempt_context.hxx +24 -7
  112. data/ext/couchbase/couchbase/transactions/transaction_get_multi_mode.hxx +47 -0
  113. data/ext/couchbase/couchbase/transactions/transaction_get_multi_options.hxx +44 -0
  114. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +46 -0
  115. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx +48 -0
  116. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +109 -0
  117. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx +47 -0
  118. data/ext/couchbase/couchbase/transactions/transaction_get_multi_result.hxx +102 -0
  119. data/ext/couchbase/couchbase/transactions/transaction_get_multi_spec.hxx +45 -0
  120. data/ext/extconf.rb +6 -0
  121. data/ext/rcb_buckets.cxx +26 -0
  122. data/lib/active_support/cache/couchbase_store.rb +1 -1
  123. data/lib/couchbase/cluster.rb +1 -1
  124. data/lib/couchbase/collection.rb +1 -1
  125. data/lib/couchbase/collection_options.rb +2 -2
  126. data/lib/couchbase/management/analytics_index_manager.rb +4 -4
  127. data/lib/couchbase/management/bucket_manager.rb +8 -2
  128. data/lib/couchbase/protostellar/cluster.rb +2 -2
  129. data/lib/couchbase/protostellar/collection.rb +1 -1
  130. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +1 -1
  131. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +4 -4
  132. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +6 -6
  133. data/lib/couchbase/protostellar/request_generator/admin/query.rb +13 -13
  134. data/lib/couchbase/protostellar/request_generator/kv.rb +25 -25
  135. data/lib/couchbase/protostellar/request_generator/query.rb +4 -4
  136. data/lib/couchbase/protostellar/request_generator/search.rb +25 -25
  137. data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
  138. data/lib/couchbase/protostellar/retry/reason.rb +1 -1
  139. data/lib/couchbase/protostellar/timeouts.rb +1 -1
  140. data/lib/couchbase/scope.rb +1 -1
  141. data/lib/couchbase/transcoder_flags.rb +1 -1
  142. data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -1
  143. data/lib/couchbase/version.rb +1 -1
  144. metadata +47 -19
  145. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/COPYING +0 -0
  146. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/SnappyConfig.cmake.in +0 -0
  147. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/config.h.in +0 -0
  148. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.cc +0 -0
  149. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.h +0 -0
  150. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-internal.h +0 -0
  151. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.cc +0 -0
  152. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.h +0 -0
  153. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.cc +0 -0
  154. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.h +0 -0
  155. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-public.h.in +0 -0
  156. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.h +0 -0
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <cstdint>
19
+
20
+ namespace couchbase::transactions
21
+ {
22
+ /**
23
+ * Strategy to deal with potential read skews while reading multiple documents.
24
+ *
25
+ * Essentially when a transaction reads document X and then Y, and another
26
+ * transaction commits a change to Y inbetween those reads - read skew has
27
+ * occurred.
28
+ */
29
+ enum class transaction_get_multi_mode : std::uint8_t {
30
+ /**
31
+ * Some time-bounded effort will be made to detect and avoid read skew.
32
+ */
33
+ prioritise_latency,
34
+
35
+ /**
36
+ * No read skew detection should be attempted. Once the documents are fetched, they will be
37
+ * returned immediately.
38
+ */
39
+ disable_read_skew_detection,
40
+
41
+ /**
42
+ * Great effort will be made to detect and avoid read skew.
43
+ */
44
+ prioritise_read_skew_detection,
45
+ };
46
+
47
+ } // namespace couchbase::transactions
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <couchbase/transactions/transaction_get_multi_mode.hxx>
19
+
20
+ namespace couchbase
21
+ {
22
+ namespace core::transactions
23
+ {
24
+ class attempt_context_impl;
25
+ } // namespace core::transactions
26
+
27
+ namespace transactions
28
+ {
29
+ class transaction_get_multi_options
30
+ {
31
+ public:
32
+ auto mode(transaction_get_multi_mode mode) -> transaction_get_multi_options&
33
+ {
34
+ mode_ = mode;
35
+ return *this;
36
+ }
37
+
38
+ private:
39
+ friend class core::transactions::attempt_context_impl;
40
+
41
+ transaction_get_multi_mode mode_{ transaction_get_multi_mode::prioritise_latency };
42
+ };
43
+ } // namespace transactions
44
+ } // namespace couchbase
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <cstdint>
19
+
20
+ namespace couchbase::transactions
21
+ {
22
+ /**
23
+ * Strategy to deal with potential read skews while reading multiple documents.
24
+ *
25
+ * Essentially when a transaction reads document X and then Y, and another
26
+ * transaction commits a change to Y inbetween those reads - read skew has
27
+ * occurred.
28
+ */
29
+ enum class transaction_get_multi_replicas_from_preferred_server_group_mode : std::uint8_t {
30
+ /**
31
+ * Some time-bounded effort will be made to detect and avoid read skew.
32
+ */
33
+ prioritise_latency,
34
+
35
+ /**
36
+ * No read skew detection should be attempted. Once the documents are fetched, they will be
37
+ * returned immediately.
38
+ */
39
+ disable_read_skew_detection,
40
+
41
+ /**
42
+ * Great effort will be made to detect and avoid read skew.
43
+ */
44
+ prioritise_read_skew_detection,
45
+ };
46
+ } // namespace couchbase::transactions
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx>
19
+
20
+ namespace couchbase
21
+ {
22
+ namespace core::transactions
23
+ {
24
+ class attempt_context_impl;
25
+ } // namespace core::transactions
26
+
27
+ namespace transactions
28
+ {
29
+ class transaction_get_multi_replicas_from_preferred_server_group_options
30
+ {
31
+ public:
32
+ auto mode(transaction_get_multi_replicas_from_preferred_server_group_mode mode)
33
+ -> transaction_get_multi_replicas_from_preferred_server_group_options&
34
+ {
35
+ mode_ = mode;
36
+ return *this;
37
+ }
38
+
39
+ private:
40
+ friend class core::transactions::attempt_context_impl;
41
+
42
+ transaction_get_multi_replicas_from_preferred_server_group_mode mode_{
43
+ transaction_get_multi_replicas_from_preferred_server_group_mode::prioritise_latency
44
+ };
45
+ };
46
+
47
+ } // namespace transactions
48
+ } // namespace couchbase
@@ -0,0 +1,109 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include "couchbase/error_codes.hxx"
19
+ #include <couchbase/codec/default_json_transcoder.hxx>
20
+
21
+ #include <optional>
22
+ #include <stdexcept>
23
+ #include <system_error>
24
+ #include <vector>
25
+
26
+ namespace couchbase
27
+ {
28
+ namespace core::transactions
29
+ {
30
+ class attempt_context_impl;
31
+ } // namespace core::transactions
32
+
33
+ namespace transactions
34
+ {
35
+ class transaction_get_multi_replicas_from_preferred_server_group_result
36
+ {
37
+ public:
38
+ transaction_get_multi_replicas_from_preferred_server_group_result(
39
+ const transaction_get_multi_replicas_from_preferred_server_group_result&) = default;
40
+ ~transaction_get_multi_replicas_from_preferred_server_group_result() = default;
41
+ transaction_get_multi_replicas_from_preferred_server_group_result(
42
+ transaction_get_multi_replicas_from_preferred_server_group_result&&) = default;
43
+ auto operator=(const transaction_get_multi_replicas_from_preferred_server_group_result&)
44
+ -> transaction_get_multi_replicas_from_preferred_server_group_result& = default;
45
+ auto operator=(transaction_get_multi_replicas_from_preferred_server_group_result&&)
46
+ -> transaction_get_multi_replicas_from_preferred_server_group_result& = default;
47
+
48
+ /**
49
+ * Content of the document.
50
+ *
51
+ * @return content of the document.
52
+ */
53
+ template<typename Document,
54
+ typename Transcoder = codec::default_json_transcoder,
55
+ std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
56
+ std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
57
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> Document
58
+ {
59
+ if (spec_index >= content_.size()) {
60
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
61
+ }
62
+ if (const auto& content = content_[spec_index]; content.has_value()) {
63
+ return Transcoder::template decode<Document>(content.value());
64
+ }
65
+ throw std::system_error(errc::key_value::document_not_found,
66
+ "document was not found for index " + std::to_string(spec_index));
67
+ }
68
+
69
+ /**
70
+ * Content of the document.
71
+ *
72
+ * @return content of the document.
73
+ */
74
+ template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
75
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> typename Transcoder::document_type
76
+ {
77
+ if (spec_index >= content_.size()) {
78
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
79
+ }
80
+ if (const auto& content = content_[spec_index]; content.has_value()) {
81
+ return Transcoder::decode(content.value());
82
+ }
83
+ throw std::system_error(errc::key_value::document_not_found,
84
+ "document was not found for index " + std::to_string(spec_index));
85
+ }
86
+
87
+ /**
88
+ * Check if spec returned any content
89
+ *
90
+ * @return the id of this document.
91
+ */
92
+ [[nodiscard]] auto exists(std::size_t spec_index) const -> bool
93
+ {
94
+ return spec_index >= content_.size() && content_[spec_index].has_value();
95
+ }
96
+
97
+ private:
98
+ friend core::transactions::attempt_context_impl;
99
+
100
+ explicit transaction_get_multi_replicas_from_preferred_server_group_result(
101
+ std::vector<std::optional<codec::encoded_value>> content)
102
+ : content_{ std::move(content) }
103
+ {
104
+ }
105
+
106
+ std::vector<std::optional<codec::encoded_value>> content_;
107
+ };
108
+ } // namespace transactions
109
+ } // namespace couchbase
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <string>
19
+
20
+ namespace couchbase
21
+ {
22
+ class collection;
23
+ namespace core::transactions
24
+ {
25
+ class attempt_context_impl;
26
+ } // namespace core::transactions
27
+
28
+ namespace transactions
29
+ {
30
+ class transaction_get_multi_replicas_from_preferred_server_group_spec
31
+ {
32
+ public:
33
+ transaction_get_multi_replicas_from_preferred_server_group_spec(
34
+ const couchbase::collection& collection,
35
+ std::string id);
36
+
37
+ private:
38
+ friend class core::transactions::attempt_context_impl;
39
+
40
+ std::string bucket_;
41
+ std::string scope_;
42
+ std::string collection_;
43
+ std::string id_;
44
+ };
45
+
46
+ } // namespace transactions
47
+ } // namespace couchbase
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <couchbase/codec/default_json_transcoder.hxx>
19
+
20
+ #include <optional>
21
+ #include <vector>
22
+
23
+ namespace couchbase
24
+ {
25
+ namespace core::transactions
26
+ {
27
+ class attempt_context_impl;
28
+ } // namespace core::transactions
29
+
30
+ namespace transactions
31
+ {
32
+ class transaction_get_multi_result
33
+ {
34
+ public:
35
+ transaction_get_multi_result() = default;
36
+ ~transaction_get_multi_result() = default;
37
+ transaction_get_multi_result(const transaction_get_multi_result&) = default;
38
+ transaction_get_multi_result(transaction_get_multi_result&&) = default;
39
+ auto operator=(const transaction_get_multi_result&) -> transaction_get_multi_result& = default;
40
+ auto operator=(transaction_get_multi_result&&) -> transaction_get_multi_result& = default;
41
+
42
+ /**
43
+ * Content of the document.
44
+ *
45
+ * @return content of the document.
46
+ */
47
+ template<typename Document,
48
+ typename Transcoder = codec::default_json_transcoder,
49
+ std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
50
+ std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
51
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> Document
52
+ {
53
+ if (spec_index >= content_.size()) {
54
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
55
+ }
56
+ if (const auto& content = content_[spec_index]; content.has_value()) {
57
+ return Transcoder::template decode<Document>(content.value());
58
+ }
59
+ throw std::system_error(errc::key_value::document_not_found,
60
+ "document was not found for index " + std::to_string(spec_index));
61
+ }
62
+
63
+ /**
64
+ * Content of the document.
65
+ *
66
+ * @return content of the document.
67
+ */
68
+ template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
69
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> typename Transcoder::document_type
70
+ {
71
+ if (spec_index >= content_.size()) {
72
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
73
+ }
74
+ if (const auto& content = content_[spec_index]; content.has_value()) {
75
+ return Transcoder::decode(content_[spec_index]);
76
+ }
77
+ throw std::system_error(errc::key_value::document_not_found,
78
+ "document was not found for index " + std::to_string(spec_index));
79
+ }
80
+
81
+ /**
82
+ * Check if spec returned any content
83
+ *
84
+ * @return the id of this document.
85
+ */
86
+ [[nodiscard]] auto exists(std::size_t spec_index) const -> bool
87
+ {
88
+ return spec_index >= content_.size() && content_[spec_index].has_value();
89
+ }
90
+
91
+ private:
92
+ friend core::transactions::attempt_context_impl;
93
+
94
+ explicit transaction_get_multi_result(std::vector<std::optional<codec::encoded_value>> content)
95
+ : content_{ std::move(content) }
96
+ {
97
+ }
98
+
99
+ std::vector<std::optional<codec::encoded_value>> content_;
100
+ };
101
+ } // namespace transactions
102
+ } // namespace couchbase
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <string>
19
+
20
+ namespace couchbase
21
+ {
22
+ class collection;
23
+ namespace core::transactions
24
+ {
25
+ class attempt_context_impl;
26
+ } // namespace core::transactions
27
+
28
+ namespace transactions
29
+ {
30
+ class transaction_get_multi_spec
31
+ {
32
+ public:
33
+ transaction_get_multi_spec(const couchbase::collection& collection, std::string id);
34
+
35
+ private:
36
+ friend class core::transactions::attempt_context_impl;
37
+
38
+ std::string bucket_;
39
+ std::string scope_;
40
+ std::string collection_;
41
+ std::string id_;
42
+ };
43
+
44
+ } // namespace transactions
45
+ } // namespace couchbase
data/ext/extconf.rb CHANGED
@@ -93,6 +93,12 @@ cmake_flags = [
93
93
  "-DCOUCHBASE_CXX_CLIENT_INSTALL=OFF",
94
94
  ]
95
95
 
96
+ if version.start_with?("4")
97
+ # snappy requires CMake 3.1
98
+ cmake_flags << "-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
99
+ end
100
+
101
+
96
102
  extconf_include = File.expand_path("cache/extconf_include.rb", __dir__)
97
103
  if File.exist?(extconf_include)
98
104
  puts "-- include extra cmake options from #{extconf_include}"
data/ext/rcb_buckets.cxx CHANGED
@@ -232,6 +232,17 @@ cb_generate_bucket_settings(VALUE bucket,
232
232
  }
233
233
  }
234
234
 
235
+ if (VALUE num_vbuckets = rb_hash_aref(bucket, rb_id2sym(rb_intern("num_vbuckets")));
236
+ !NIL_P(num_vbuckets)) {
237
+ if (TYPE(num_vbuckets) == T_FIXNUM) {
238
+ entry.num_vbuckets = FIX2UINT(num_vbuckets);
239
+ } else {
240
+ throw ruby_exception(
241
+ rb_eArgError,
242
+ rb_sprintf("num vbuckets must be an Integer, given %+" PRIsVALUE, num_vbuckets));
243
+ }
244
+ }
245
+
235
246
  if (is_create) {
236
247
  if (VALUE conflict_resolution_type =
237
248
  rb_hash_aref(bucket, rb_id2sym(rb_intern("conflict_resolution_type")));
@@ -506,6 +517,18 @@ cb_extract_bucket_settings(const core::management::cluster::bucket_settings& ent
506
517
  break;
507
518
  }
508
519
  }
520
+ switch (entry.storage_backend) {
521
+ case core::management::cluster::bucket_storage_backend::couchstore:
522
+ rb_hash_aset(
523
+ bucket, rb_id2sym(rb_intern("storage_backend")), rb_id2sym(rb_intern("couchstore")));
524
+ break;
525
+ case core::management::cluster::bucket_storage_backend::magma:
526
+ rb_hash_aset(bucket, rb_id2sym(rb_intern("storage_backend")), rb_id2sym(rb_intern("magma")));
527
+ break;
528
+ case core::management::cluster::bucket_storage_backend::unknown:
529
+ rb_hash_aset(bucket, rb_id2sym(rb_intern("storage_backend")), Qnil);
530
+ break;
531
+ }
509
532
  if (entry.history_retention_collection_default.has_value()) {
510
533
  rb_hash_aset(bucket,
511
534
  rb_id2sym(rb_intern("history_retention_collection_default")),
@@ -518,6 +541,9 @@ cb_extract_bucket_settings(const core::management::cluster::bucket_settings& ent
518
541
  rb_hash_aset(
519
542
  bucket, rb_id2sym(rb_intern("history_retention_duration")), ULONG2NUM(val.value()));
520
543
  }
544
+ if (const auto& val = entry.num_vbuckets; val.has_value()) {
545
+ rb_hash_aset(bucket, rb_id2sym(rb_intern("num_vbuckets")), USHORT2NUM(val.value()));
546
+ }
521
547
 
522
548
  VALUE capabilities = rb_ary_new_capa(static_cast<long>(entry.capabilities.size()));
523
549
  for (const auto& capa : entry.capabilities) {
@@ -316,7 +316,7 @@ module ActiveSupport
316
316
  @couchbase_options[:connection_string],
317
317
  ::Couchbase::Options::Cluster(authenticator: ::Couchbase::PasswordAuthenticator.new(
318
318
  @couchbase_options[:username], @couchbase_options[:password]
319
- ))
319
+ )),
320
320
  )
321
321
  end
322
322
 
@@ -391,7 +391,7 @@ module Couchbase
391
391
  location.end_offset = loc[:end_offset]
392
392
  location.array_positions = loc[:array_positions]
393
393
  end
394
- end
394
+ end,
395
395
  )
396
396
  end
397
397
  row.instance_variable_set(:@fields, r[:fields])
@@ -626,7 +626,7 @@ module Couchbase
626
626
  core_scan_result: @backend.document_scan_create(
627
627
  @bucket_name, @scope_name, @name, scan_type.to_backend, options.to_backend
628
628
  ),
629
- transcoder: options.transcoder
629
+ transcoder: options.transcoder,
630
630
  )
631
631
  end
632
632
 
@@ -381,7 +381,7 @@ module Couchbase
381
381
  yield ScanResult.new(
382
382
  id: resp[:id],
383
383
  id_only: resp[:id_only],
384
- transcoder: @transcoder
384
+ transcoder: @transcoder,
385
385
  )
386
386
  else
387
387
  yield ScanResult.new(
@@ -391,7 +391,7 @@ module Couchbase
391
391
  expiry: resp[:expiry],
392
392
  encoded: resp[:encoded],
393
393
  flags: resp[:flags],
394
- transcoder: @transcoder
394
+ transcoder: @transcoder,
395
395
  )
396
396
  end
397
397
  end
@@ -846,7 +846,7 @@ module Couchbase
846
846
  entry[:access_key_id],
847
847
  nil,
848
848
  entry[:region],
849
- service_endpoint: entry[:service_endpoint]
849
+ service_endpoint: entry[:service_endpoint],
850
850
  )
851
851
  when :couchbase
852
852
  CouchbaseRemoteAnalyticsLink.new(
@@ -857,8 +857,8 @@ module Couchbase
857
857
  encryption: EncryptionSettings.new(
858
858
  level: entry[:encryption_level],
859
859
  certificate: entry[:certificate],
860
- client_certificate: entry[:client_certificate]
861
- )
860
+ client_certificate: entry[:client_certificate],
861
+ ),
862
862
  )
863
863
  when :azureblob
864
864
  AzureBlobExternalAnalyticsLink.new(
@@ -866,7 +866,7 @@ module Couchbase
866
866
  entry[:dataverse],
867
867
  account_name: entry[:account_name],
868
868
  blob_endpoint: entry[:blob_endpoint],
869
- endpoint_suffix: entry[:endpoint_suffix]
869
+ endpoint_suffix: entry[:endpoint_suffix],
870
870
  )
871
871
  end
872
872
  end
@@ -206,7 +206,6 @@ module Couchbase
206
206
  def create_bucket(settings, options = Options::Bucket::CreateBucket.new)
207
207
  @backend.bucket_create(
208
208
  {
209
-
210
209
  name: settings.name,
211
210
  flush_enabled: settings.flush_enabled,
212
211
  ram_quota_mb: settings.ram_quota_mb,
@@ -222,6 +221,7 @@ module Couchbase
222
221
  history_retention_collection_default: settings.history_retention_collection_default,
223
222
  history_retention_duration: settings.history_retention_duration,
224
223
  history_retention_bytes: settings.history_retention_bytes,
224
+ num_vbuckets: settings.num_vbuckets,
225
225
  }, options.to_backend
226
226
  )
227
227
  end
@@ -252,6 +252,7 @@ module Couchbase
252
252
  history_retention_collection_default: settings.history_retention_collection_default,
253
253
  history_retention_bytes: settings.history_retention_bytes,
254
254
  history_retention_duration: settings.history_retention_duration,
255
+ num_vbuckets: settings.num_vbuckets,
255
256
  }, options.to_backend
256
257
  )
257
258
  end
@@ -342,9 +343,11 @@ module Couchbase
342
343
  bucket.minimum_durability_level = entry[:minimum_durability_level]
343
344
  bucket.compression_mode = entry[:compression_mode]
344
345
  bucket.instance_variable_set(:@healthy, entry[:nodes].all? { |node| node[:status] == "healthy" })
346
+ bucket.storage_backend = entry[:storage_backend]
345
347
  bucket.history_retention_collection_default = entry[:history_retention_collection_default]
346
348
  bucket.history_retention_bytes = entry[:history_retention_bytes]
347
349
  bucket.history_retention_duration = entry[:history_retention_duration]
350
+ bucket.num_vbuckets = entry[:num_vbuckets]
348
351
  end
349
352
  end
350
353
  end
@@ -405,7 +408,7 @@ module Couchbase
405
408
  # @return [nil, :none, :majority, :majority_and_persist_to_active, :persist_to_majority] the minimum durability level
406
409
  attr_accessor :minimum_durability_level
407
410
 
408
- # @return [Boolean, nil] whether to enable history retention on collections by default
411
+ # @return [Boolean, nil] whether to enable history retention on collections by default
409
412
  attr_accessor :history_retention_collection_default
410
413
 
411
414
  # @return [Integer, nil] the maximum size, in bytes, of the change history that is written to disk for all
@@ -416,6 +419,9 @@ module Couchbase
416
419
  # collections in this bucket
417
420
  attr_accessor :history_retention_duration
418
421
 
422
+ # @return [Integer, nil] the number of vBuckets the bucket should have. If not set, the server default will be used
423
+ attr_accessor :num_vbuckets
424
+
419
425
  # @api private
420
426
  # @return [Boolean] false if status of the bucket is not healthy
421
427
  def healthy?