couchbase 3.5.7 → 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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  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/rcb_buckets.cxx +26 -0
  121. data/lib/active_support/cache/couchbase_store.rb +1 -1
  122. data/lib/couchbase/cluster.rb +1 -1
  123. data/lib/couchbase/collection.rb +1 -1
  124. data/lib/couchbase/collection_options.rb +2 -2
  125. data/lib/couchbase/management/analytics_index_manager.rb +4 -4
  126. data/lib/couchbase/management/bucket_manager.rb +8 -2
  127. data/lib/couchbase/protostellar/cluster.rb +2 -2
  128. data/lib/couchbase/protostellar/collection.rb +1 -1
  129. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +1 -1
  130. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +4 -4
  131. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +6 -6
  132. data/lib/couchbase/protostellar/request_generator/admin/query.rb +13 -13
  133. data/lib/couchbase/protostellar/request_generator/kv.rb +25 -25
  134. data/lib/couchbase/protostellar/request_generator/query.rb +4 -4
  135. data/lib/couchbase/protostellar/request_generator/search.rb +25 -25
  136. data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
  137. data/lib/couchbase/protostellar/retry/reason.rb +1 -1
  138. data/lib/couchbase/protostellar/timeouts.rb +1 -1
  139. data/lib/couchbase/scope.rb +1 -1
  140. data/lib/couchbase/transcoder_flags.rb +1 -1
  141. data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -1
  142. data/lib/couchbase/version.rb +1 -1
  143. metadata +47 -19
  144. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/COPYING +0 -0
  145. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/SnappyConfig.cmake.in +0 -0
  146. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/config.h.in +0 -0
  147. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.cc +0 -0
  148. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.h +0 -0
  149. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-internal.h +0 -0
  150. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.cc +0 -0
  151. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.h +0 -0
  152. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.cc +0 -0
  153. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.h +0 -0
  154. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-public.h.in +0 -0
  155. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.h +0 -0
@@ -37,23 +37,15 @@ enum class staged_mutation_type {
37
37
 
38
38
  class staged_mutation
39
39
  {
40
- private:
41
- transaction_get_result doc_;
42
- staged_mutation_type type_;
43
- codec::encoded_value content_;
44
- std::string operation_id_;
45
-
46
40
  public:
47
- staged_mutation(transaction_get_result doc,
48
- codec::encoded_value content,
49
- staged_mutation_type type,
50
- std::string operation_id = uid_generator::next())
51
- : doc_(std::move(doc))
52
- , type_(type)
53
- , content_(std::move(content))
54
- , operation_id_(std::move(operation_id))
55
- {
56
- }
41
+ staged_mutation(staged_mutation_type type,
42
+ document_id doc_id,
43
+ cas cas,
44
+ std::optional<codec::binary> staged_content,
45
+ std::uint32_t staged_flags,
46
+ std::uint32_t current_user_flags,
47
+ std::optional<document_metadata> doc_metadata,
48
+ std::string operation_id = uid_generator::next());
57
49
 
58
50
  ~staged_mutation() = default;
59
51
  staged_mutation(const staged_mutation&) = delete;
@@ -61,68 +53,28 @@ public:
61
53
  auto operator=(const staged_mutation&) -> staged_mutation& = delete;
62
54
  auto operator=(staged_mutation&&) -> staged_mutation& = default;
63
55
 
64
- [[nodiscard]] auto id() const -> const core::document_id&
65
- {
66
- return doc_.id();
67
- }
68
-
69
- [[nodiscard]] auto doc() const -> const transaction_get_result&
70
- {
71
- return doc_;
72
- }
73
-
74
- [[nodiscard]] auto doc() -> transaction_get_result&
75
- {
76
- return doc_;
77
- }
78
-
79
- [[nodiscard]] auto type() const -> const staged_mutation_type&
80
- {
81
- return type_;
82
- }
83
-
84
- void type(staged_mutation_type& type)
85
- {
86
- type_ = type;
87
- }
88
-
56
+ [[nodiscard]] auto id() const -> const document_id&;
57
+ [[nodiscard]] auto cas() const -> const couchbase::cas&;
58
+ [[nodiscard]] auto type() const -> const staged_mutation_type&;
89
59
  [[nodiscard]] auto is_staged_binary() const -> bool;
60
+ [[nodiscard]] auto staged_content() const -> const std::optional<codec::binary>&;
61
+ [[nodiscard]] auto staged_flags() const -> std::uint32_t;
62
+ [[nodiscard]] auto current_user_flags() const -> std::uint32_t;
63
+ [[nodiscard]] auto doc_metadata() const -> const std::optional<document_metadata>&;
64
+ [[nodiscard]] auto operation_id() const -> const std::string&;
65
+ [[nodiscard]] auto type_as_string() const -> std::string;
66
+
67
+ void cas(couchbase::cas cas);
90
68
 
91
- [[nodiscard]] auto content() const -> const codec::encoded_value&
92
- {
93
- return content_;
94
- }
95
-
96
- /**
97
- * @return current user flags before the staging of the document
98
- */
99
- [[nodiscard]] auto current_user_flags() const -> std::uint32_t
100
- {
101
- return doc_.content().flags;
102
- }
103
-
104
- void content(const codec::encoded_value& content)
105
- {
106
- content_ = content;
107
- }
108
-
109
- [[nodiscard]] auto type_as_string() const -> std::string
110
- {
111
- switch (type_) {
112
- case staged_mutation_type::INSERT:
113
- return "INSERT";
114
- case staged_mutation_type::REMOVE:
115
- return "REMOVE";
116
- case staged_mutation_type::REPLACE:
117
- return "REPLACE";
118
- }
119
- throw std::runtime_error("unknown type of staged mutation");
120
- }
121
-
122
- [[nodiscard]] auto operation_id() const -> const std::string&
123
- {
124
- return operation_id_;
125
- }
69
+ private:
70
+ staged_mutation_type type_;
71
+ document_id doc_id_;
72
+ couchbase::cas cas_;
73
+ std::optional<codec::binary> staged_content_;
74
+ std::uint32_t staged_flags_;
75
+ std::uint32_t current_user_flags_;
76
+ std::optional<document_metadata> doc_metadata_;
77
+ std::string operation_id_;
126
78
  };
127
79
 
128
80
  struct unstaging_state {
@@ -91,6 +91,12 @@ transaction_context::remaining() const -> std::chrono::nanoseconds
91
91
  return config_.timeout - expired_nanos;
92
92
  }
93
93
 
94
+ auto
95
+ transaction_context::expiry_time() const -> std::chrono::steady_clock::time_point
96
+ {
97
+ return start_time_client_ + config_.timeout;
98
+ }
99
+
94
100
  [[nodiscard]] auto
95
101
  transaction_context::has_expired_client_side() -> bool
96
102
  {
@@ -175,6 +181,33 @@ transaction_context::get_replica_from_preferred_server_group(const core::documen
175
181
  throw transaction_operation_failed(FAIL_OTHER, "no current attempt context");
176
182
  }
177
183
 
184
+ void
185
+ transaction_context::get_multi_replicas_from_preferred_server_group(
186
+ const std::vector<core::document_id>& ids,
187
+ transaction_get_multi_replicas_from_preferred_server_group_mode mode,
188
+ std::function<
189
+ void(std::exception_ptr,
190
+ std::optional<transaction_get_multi_replicas_from_preferred_server_group_result>)>&& cb)
191
+ {
192
+ if (current_attempt_context_) {
193
+ return current_attempt_context_->get_multi_replicas_from_preferred_server_group(
194
+ ids, mode, std::move(cb));
195
+ }
196
+ throw transaction_operation_failed(FAIL_OTHER, "no current attempt context");
197
+ }
198
+
199
+ void
200
+ transaction_context::get_multi(
201
+ const std::vector<core::document_id>& ids,
202
+ transaction_get_multi_mode mode,
203
+ std::function<void(std::exception_ptr, std::optional<transaction_get_multi_result>)>&& cb)
204
+ {
205
+ if (current_attempt_context_) {
206
+ return current_attempt_context_->get_multi(ids, mode, std::move(cb));
207
+ }
208
+ throw transaction_operation_failed(FAIL_OTHER, "no current attempt context");
209
+ }
210
+
178
211
  void
179
212
  transaction_context::get_optional(const core::document_id& id, async_attempt_context::Callback&& cb)
180
213
  {
@@ -0,0 +1,28 @@
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::core::transactions
21
+ {
22
+ enum class transaction_get_multi_mode : std::uint8_t {
23
+ prioritise_latency,
24
+ disable_read_skew_detection,
25
+ prioritise_read_skew_detection,
26
+ };
27
+
28
+ } // namespace couchbase::core::transactions
@@ -0,0 +1,27 @@
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::core::transactions
21
+ {
22
+ enum class transaction_get_multi_replicas_from_preferred_server_group_mode : std::uint8_t {
23
+ prioritise_latency,
24
+ disable_read_skew_detection,
25
+ prioritise_read_skew_detection,
26
+ };
27
+ } // namespace couchbase::core::transactions
@@ -0,0 +1,71 @@
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 <gsl/assert>
21
+
22
+ #include <optional>
23
+ #include <vector>
24
+
25
+ namespace couchbase::core::transactions
26
+ {
27
+ class transaction_get_multi_replicas_from_preferred_server_group_result
28
+ {
29
+ public:
30
+ transaction_get_multi_replicas_from_preferred_server_group_result() = default;
31
+ ~transaction_get_multi_replicas_from_preferred_server_group_result() = default;
32
+ transaction_get_multi_replicas_from_preferred_server_group_result(
33
+ const transaction_get_multi_replicas_from_preferred_server_group_result&) = default;
34
+ transaction_get_multi_replicas_from_preferred_server_group_result(
35
+ transaction_get_multi_replicas_from_preferred_server_group_result&&) = default;
36
+ auto operator=(const transaction_get_multi_replicas_from_preferred_server_group_result&)
37
+ -> transaction_get_multi_replicas_from_preferred_server_group_result& = default;
38
+ auto operator=(transaction_get_multi_replicas_from_preferred_server_group_result&&)
39
+ -> transaction_get_multi_replicas_from_preferred_server_group_result& = default;
40
+
41
+ explicit transaction_get_multi_replicas_from_preferred_server_group_result(
42
+ std::vector<std::optional<codec::encoded_value>> content)
43
+ : content_{ std::move(content) }
44
+ {
45
+ }
46
+
47
+ [[nodiscard]] auto content(std::size_t spec_index) const -> const codec::encoded_value&
48
+ {
49
+ Expects(exists(spec_index));
50
+ return content_[spec_index].value();
51
+ }
52
+
53
+ [[nodiscard]] auto exists(std::size_t spec_index) const -> bool
54
+ {
55
+ return spec_index >= content_.size() && content_[spec_index].has_value();
56
+ }
57
+
58
+ [[nodiscard]] auto content() const -> const std::vector<std::optional<codec::encoded_value>>&
59
+ {
60
+ return content_;
61
+ }
62
+
63
+ [[nodiscard]] auto content() -> std::vector<std::optional<codec::encoded_value>>&&
64
+ {
65
+ return std::move(content_);
66
+ }
67
+
68
+ private:
69
+ std::vector<std::optional<codec::encoded_value>> content_;
70
+ };
71
+ } // namespace couchbase::core::transactions
@@ -0,0 +1,66 @@
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 <gsl/assert>
21
+
22
+ #include <optional>
23
+ #include <vector>
24
+
25
+ namespace couchbase::core::transactions
26
+ {
27
+ class transaction_get_multi_result
28
+ {
29
+ public:
30
+ transaction_get_multi_result() = default;
31
+ ~transaction_get_multi_result() = default;
32
+ transaction_get_multi_result(const transaction_get_multi_result&) = default;
33
+ transaction_get_multi_result(transaction_get_multi_result&&) = default;
34
+ auto operator=(const transaction_get_multi_result&) -> transaction_get_multi_result& = default;
35
+ auto operator=(transaction_get_multi_result&&) -> transaction_get_multi_result& = default;
36
+
37
+ explicit transaction_get_multi_result(std::vector<std::optional<codec::encoded_value>> content)
38
+ : content_{ std::move(content) }
39
+ {
40
+ }
41
+
42
+ [[nodiscard]] auto content(std::size_t spec_index) const -> const codec::encoded_value&
43
+ {
44
+ Expects(exists(spec_index));
45
+ return content_[spec_index].value();
46
+ }
47
+
48
+ [[nodiscard]] auto exists(std::size_t spec_index) const -> bool
49
+ {
50
+ return spec_index >= content_.size() && content_[spec_index].has_value();
51
+ }
52
+
53
+ [[nodiscard]] auto content() const -> const std::vector<std::optional<codec::encoded_value>>&
54
+ {
55
+ return content_;
56
+ }
57
+
58
+ [[nodiscard]] auto content() -> std::vector<std::optional<codec::encoded_value>>&&
59
+ {
60
+ return std::move(content_);
61
+ }
62
+
63
+ private:
64
+ std::vector<std::optional<codec::encoded_value>> content_;
65
+ };
66
+ } // namespace couchbase::core::transactions
@@ -172,6 +172,16 @@ public:
172
172
  return staged_content_json_.value_or(staged_content_binary_.value_or(codec::encoded_value{}));
173
173
  }
174
174
 
175
+ [[nodiscard]] auto staged_user_flags() const -> std::uint32_t
176
+ {
177
+ return staged_content_json_or_binary().flags;
178
+ }
179
+
180
+ [[nodiscard]] auto is_staged_content_binary() const -> bool
181
+ {
182
+ return staged_content_binary_.has_value();
183
+ }
184
+
175
185
  [[nodiscard]] auto staged_content_json() const -> codec::encoded_value
176
186
  {
177
187
  return staged_content_json_.value_or(codec::encoded_value{});
@@ -21,6 +21,7 @@
21
21
  #include "core/meta/version.hxx"
22
22
  #include "core/transactions.hxx"
23
23
 
24
+ #include "couchbase/error_codes.hxx"
24
25
  #include "internal/exceptions_internal.hxx"
25
26
  #include "internal/logging.hxx"
26
27
  #include "internal/transaction_context.hxx"
@@ -28,6 +29,7 @@
28
29
  #include "internal/utils.hxx"
29
30
 
30
31
  #include <couchbase/error.hxx>
32
+ #include <couchbase/fmt/error.hxx>
31
33
 
32
34
  #include <system_error>
33
35
  #include <utility>
@@ -174,10 +176,13 @@ wrap_public_api_run(transactions& txns,
174
176
  return wrap_run(txns, config, max_attempts, [fn = std::forward<Handler>(fn)](const auto& ctx) {
175
177
  const couchbase::error err = fn(ctx);
176
178
  if (err && err.ec() != errc::transaction_op::transaction_op_failed) {
179
+ // We intentionally don't handle transaction_op_failed here, as we must have cached the
180
+ // transaction error internally already, which has the full context with the right error class
181
+ // etc.
177
182
  if (err.ec().category() == core::impl::transaction_op_category()) {
178
183
  throw op_exception(err);
179
184
  }
180
- throw std::runtime_error(err.ec().message());
185
+ throw std::system_error(err.ec(), fmt::format("{}", err));
181
186
  }
182
187
  });
183
188
  }
@@ -190,8 +195,8 @@ transactions::run(logic&& code) -> ::couchbase::transactions::transaction_result
190
195
  }
191
196
 
192
197
  auto
193
- transactions::run(const couchbase::transactions::transaction_options& config,
194
- logic&& code) -> ::couchbase::transactions::transaction_result
198
+ transactions::run(const couchbase::transactions::transaction_options& config, logic&& code)
199
+ -> ::couchbase::transactions::transaction_result
195
200
  {
196
201
  return wrap_run(*this, config, max_attempts_, std::move(code));
197
202
  }
@@ -582,6 +582,10 @@ extract_options(connection_string& connstr)
582
582
  } else if (name == "server_group") {
583
583
  parse_option(connstr.options.server_group, name, value, connstr.warnings);
584
584
  #endif
585
+ } else if (name == "enable_app_telemetry") {
586
+ parse_option(connstr.options.enable_app_telemetry, name, value, connstr.warnings);
587
+ } else if (name == "app_telemetry_endpoint") {
588
+ parse_option(connstr.options.app_telemetry_endpoint, name, value, connstr.warnings);
585
589
  } else {
586
590
  connstr.warnings.push_back(
587
591
  fmt::format(R"(unknown parameter "{}" in connection string (value "{}"))", name, value));
@@ -22,6 +22,7 @@
22
22
  #include <cctype>
23
23
  #include <climits>
24
24
  #include <cstdint>
25
+ #include <regex>
25
26
 
26
27
  namespace couchbase::core::utils::string_codec
27
28
  {
@@ -409,4 +410,29 @@ escape(const std::string& s, encoding mode) -> std::string
409
410
 
410
411
  } // namespace v2
411
412
 
413
+ auto
414
+ url_parse(const std::string& src) -> url
415
+ {
416
+ // very basic URL parser, only cares about scheme://host[:port][/path]
417
+ static const std::regex url_regexp{
418
+ R"(^([a-zA-Z][a-zA-Z\d+\-.]+):\/\/([^\/:]+)(?::(\d+))?(\/[^?#]*)?$)"
419
+ };
420
+
421
+ url u{};
422
+
423
+ std::smatch matches;
424
+ if (std::regex_match(src, matches, url_regexp)) {
425
+ u.scheme = matches[1].str();
426
+ u.host = matches[2].str();
427
+ if (matches[3].length() > 0) {
428
+ u.port = static_cast<std::uint16_t>(std::stoul(matches[3].str()));
429
+ } else {
430
+ u.port = (u.scheme == "https" || u.scheme == "wss") ? 443 : 80;
431
+ }
432
+ u.path = matches[4].str();
433
+ }
434
+
435
+ return u;
436
+ }
437
+
412
438
  } // namespace couchbase::core::utils::string_codec
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <cinttypes>
3
4
  #include <map>
4
5
  #include <sstream>
5
6
  #include <string>
@@ -69,4 +70,14 @@ form_encode(const std::map<std::string, std::string>& values) -> std::string
69
70
  }
70
71
  } // namespace v2
71
72
 
73
+ struct url {
74
+ std::string scheme;
75
+ std::string host;
76
+ std::uint16_t port;
77
+ std::string path;
78
+ };
79
+
80
+ auto
81
+ url_parse(const std::string& src) -> url;
82
+
72
83
  } // namespace couchbase::core::utils::string_codec