couchbase 4.4.3 → 4.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. package/BUILDING.md +182 -0
  2. package/CMakeLists.txt +11 -0
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -2
  5. package/deps/couchbase-cxx-cache/boringssl/e31ea00c1ea52052d2d78d44006cc88c80fa24a9/boringssl/src/BUILDING.md +206 -0
  6. package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
  7. package/deps/couchbase-cxx-client/README.md +2 -2
  8. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +54 -0
  9. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +0 -5
  10. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +174 -11
  11. package/deps/couchbase-cxx-client/cmake/RPath.cmake +10 -0
  12. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +4 -0
  13. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  14. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +2 -2
  15. package/deps/couchbase-cxx-client/cmake/couchbase_cxx_client.pc.in +2 -2
  16. package/deps/couchbase-cxx-client/cmake/debian/changelog.in +5 -0
  17. package/deps/couchbase-cxx-client/cmake/debian/compat +1 -0
  18. package/deps/couchbase-cxx-client/cmake/debian/control +40 -0
  19. package/deps/couchbase-cxx-client/cmake/debian/rules +41 -0
  20. package/deps/couchbase-cxx-client/cmake/debian/source/format +1 -0
  21. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  22. package/deps/couchbase-cxx-client/core/impl/collection.cxx +27 -3
  23. package/deps/couchbase-cxx-client/core/impl/error.cxx +24 -3
  24. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +2 -0
  26. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  27. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  28. package/deps/couchbase-cxx-client/core/impl/search.cxx +2 -0
  29. package/deps/couchbase-cxx-client/core/io/http_command.hxx +2 -2
  30. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +1 -1
  31. package/deps/couchbase-cxx-client/core/meta/features.hxx +11 -0
  32. package/deps/couchbase-cxx-client/core/meta/version.cxx +47 -6
  33. package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +23 -17
  34. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +2 -0
  36. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +2 -0
  37. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +2 -0
  38. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +2 -0
  39. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +2 -0
  40. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +2 -0
  41. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +2 -0
  42. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +2 -0
  43. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +2 -0
  44. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +2 -0
  45. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +2 -0
  46. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +2 -0
  47. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +2 -0
  49. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +2 -0
  50. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  52. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +2 -0
  53. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +2 -0
  54. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -0
  55. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +2 -0
  56. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +2 -0
  57. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +2 -0
  58. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  59. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  60. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +1 -0
  61. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +1 -0
  62. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +1 -0
  63. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +1 -0
  64. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +1 -0
  65. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  66. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +1 -0
  67. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +1 -0
  68. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +1 -0
  69. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +1 -0
  70. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +1 -0
  71. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +1 -0
  72. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +1 -0
  73. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.cxx +23 -15
  74. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +4 -3
  75. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +1 -0
  76. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +1 -0
  77. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +1 -0
  78. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +1 -0
  79. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +1 -0
  80. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +1 -0
  81. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +1 -0
  82. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +1 -0
  83. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +1 -0
  84. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +1 -0
  85. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +1 -0
  86. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  87. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +1 -0
  88. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
  89. package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
  90. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +3 -2
  91. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +3 -2
  92. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +3 -2
  93. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +3 -2
  94. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +3 -2
  95. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +3 -2
  96. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +3 -2
  97. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +3 -2
  98. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +3 -2
  99. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  100. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +1 -0
  101. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +1 -0
  102. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +1 -0
  103. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +1 -0
  104. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
  105. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +3 -0
  106. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -0
  107. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +1 -0
  108. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +2 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +1 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +1 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +1 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +1 -0
  114. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +1 -0
  115. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +1 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +1 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +1 -0
  118. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +1 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +1 -0
  120. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +1 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +1 -0
  122. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +1 -0
  124. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +1 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +1 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +1 -0
  127. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +1 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.cxx +3 -3
  129. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +1 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +1 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +1 -0
  132. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +1 -0
  134. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +9 -21
  135. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +6 -33
  136. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +41 -41
  137. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +15 -16
  138. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +2 -2
  139. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +0 -20
  140. package/deps/couchbase-cxx-client/couchbase/common_options.hxx +16 -1
  141. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +16 -20
  142. package/dist/analyticsindexmanager.d.ts +98 -14
  143. package/dist/analyticsindexmanager.js +452 -411
  144. package/dist/binding.d.ts +53 -4
  145. package/dist/bindingutilities.d.ts +26 -1
  146. package/dist/bindingutilities.js +108 -1
  147. package/dist/couchbase.d.ts +3 -1
  148. package/dist/couchbase.js +2 -0
  149. package/dist/rangeScan.d.ts +1 -1
  150. package/dist/rangeScan.js +1 -1
  151. package/dist/transactions.d.ts +34 -3
  152. package/dist/transactions.js +25 -18
  153. package/dist/transcoders.d.ts +68 -0
  154. package/dist/transcoders.js +194 -1
  155. package/dist/usermanager.d.ts +14 -14
  156. package/dist/usermanager.js +178 -228
  157. package/dist/utilities.js +4 -6
  158. package/dist/utilities_internal.js +1 -2
  159. package/package.json +9 -8
  160. package/src/connection.cpp +22 -0
  161. package/src/connection.hpp +12 -0
  162. package/src/connection_autogen.cpp +100 -0
  163. package/src/jstocbpp_autogen.hpp +315 -8
  164. package/src/jstocbpp_transactions.hpp +1 -2
  165. package/tools/gen-bindings-js.js +38 -3
  166. package/tools/gen-bindings-json.py +575 -328
@@ -37,6 +37,7 @@ struct user_get_all_request {
37
37
  using encoded_response_type = io::http_response;
38
38
  using error_context_type = error_context::http;
39
39
 
40
+ static const inline std::string observability_identifier = "manager_users_get_all_users";
40
41
  static const inline service_type type = service_type::management;
41
42
 
42
43
  couchbase::core::management::rbac::auth_domain domain{
@@ -51,11 +51,11 @@ user_upsert_request::encode_to(encoded_request_type& encoded,
51
51
  for (const auto& role : user.roles) {
52
52
  std::string spec = role.name;
53
53
  if (role.bucket) {
54
- spec += fmt::format("[{}", role.bucket.value());
54
+ spec += fmt::format("[{}", utils::string_codec::v2::path_escape(role.bucket.value()));
55
55
  if (role.scope) {
56
- spec += fmt::format(":{}", role.scope.value());
56
+ spec += fmt::format(":{}", utils::string_codec::v2::path_escape(role.scope.value()));
57
57
  if (role.collection) {
58
- spec += fmt::format(":{}", role.collection.value());
58
+ spec += fmt::format(":{}", utils::string_codec::v2::path_escape(role.collection.value()));
59
59
  }
60
60
  }
61
61
  spec += "]";
@@ -37,6 +37,7 @@ struct user_upsert_request {
37
37
  using encoded_response_type = io::http_response;
38
38
  using error_context_type = error_context::http;
39
39
 
40
+ static const inline std::string observability_identifier = "manager_users_upsert_user";
40
41
  static const inline service_type type = service_type::management;
41
42
 
42
43
  couchbase::core::management::rbac::auth_domain domain{
@@ -37,6 +37,7 @@ struct view_index_drop_request {
37
37
  using error_context_type = error_context::http;
38
38
 
39
39
  static const inline service_type type = service_type::view;
40
+ static const inline std::string observability_identifier = "manager_views_drop_design_document";
40
41
 
41
42
  std::string bucket_name;
42
43
  std::string document_name;
@@ -38,6 +38,7 @@ struct view_index_get_request {
38
38
  using error_context_type = error_context::http;
39
39
 
40
40
  static const inline service_type type = service_type::view;
41
+ static const inline std::string observability_identifier = "manager_views_get_design_document";
41
42
 
42
43
  std::string bucket_name;
43
44
  std::string document_name;
@@ -38,6 +38,8 @@ struct view_index_get_all_request {
38
38
  using error_context_type = error_context::http;
39
39
 
40
40
  static const inline service_type type = service_type::management;
41
+ static const inline std::string observability_identifier =
42
+ "manager_views_get_all_design_documents";
41
43
 
42
44
  std::string bucket_name;
43
45
  design_document_namespace ns;
@@ -37,6 +37,7 @@ struct view_index_upsert_request {
37
37
  using error_context_type = error_context::http;
38
38
 
39
39
  static const inline service_type type = service_type::view;
40
+ static const inline std::string observability_identifier = "manager_views_upsert_design_document";
40
41
 
41
42
  std::string bucket_name;
42
43
  couchbase::core::management::views::design_document document;
@@ -42,7 +42,9 @@ public:
42
42
  using VoidCallback = std::function<void(std::exception_ptr)>;
43
43
  using QueryCallback =
44
44
  std::function<void(std::exception_ptr, std::optional<core::operations::query_response>)>;
45
+
45
46
  virtual ~async_attempt_context() = default;
47
+
46
48
  /**
47
49
  * Gets a document from the specified Couchbase collection matching the
48
50
  * specified id.
@@ -91,6 +93,7 @@ public:
91
93
  *
92
94
  * If the mutation fails, the transaction will automatically rollback this
93
95
  * attempt, then retry.
96
+ *
94
97
  * @param document the doc to be updated
95
98
  * @param content the content to replace the doc with.
96
99
  * @param cb callback function called with the updated @ref
@@ -98,11 +101,10 @@ public:
98
101
  * transaction_operation_failed
99
102
  *
100
103
  */
101
- template<typename Transcoder = codec::default_json_transcoder, typename Content>
102
- void replace(const transaction_get_result& document, const Content& content, Callback&& cb)
103
- {
104
- return replace_raw(document, Transcoder::encode(content), std::move(cb));
105
- }
104
+ virtual void replace(const transaction_get_result& document,
105
+ codec::encoded_value content,
106
+ Callback&& cb) = 0;
107
+
106
108
  /**
107
109
  * Inserts a new document into the specified Couchbase collection.
108
110
  *
@@ -119,11 +121,8 @@ public:
119
121
  * @param cb callback function called with a @ref transaction_get_result with
120
122
  * the new CAS value when successful, or @ref transaction_operation_failed
121
123
  */
122
- template<typename Transcoder = codec::default_json_transcoder, typename Content>
123
- void insert(const core::document_id& id, const Content& content, Callback&& cb)
124
- {
125
- return insert_raw(id, Transcoder::encode(content), std::move(cb));
126
- }
124
+ virtual void insert(const core::document_id& id, codec::encoded_value content, Callback&& cb) = 0;
125
+
127
126
  /**
128
127
  * Removes the specified document, using the document's last
129
128
  * TransactionDocument#cas
@@ -195,17 +194,6 @@ public:
195
194
  * @param cb callback which is called when the rollback succeeds
196
195
  */
197
196
  virtual void rollback(VoidCallback&& cb) = 0;
198
-
199
- protected:
200
- /** @internal */
201
- virtual void insert_raw(const core::document_id& id,
202
- codec::encoded_value content,
203
- Callback&& cb) = 0;
204
-
205
- /** @internal */
206
- virtual void replace_raw(const transaction_get_result& document,
207
- codec::encoded_value content,
208
- Callback&& cb) = 0;
209
197
  };
210
198
 
211
199
  } // namespace couchbase::core::transactions
@@ -101,19 +101,8 @@ public:
101
101
  * @throws transaction_operation_failed which either should not be caught by
102
102
  * the lambda, or rethrown if it is caught.
103
103
  */
104
- template<typename Transcoder = codec::default_json_transcoder, typename Content>
105
- auto replace(const transaction_get_result& document,
106
- const Content& content) -> transaction_get_result
107
- {
108
- codec::encoded_value data;
109
- try {
110
- data = Transcoder::encode(content);
111
- } catch (std::runtime_error& e) {
112
- throw transaction_operation_failed(
113
- FAIL_OTHER, std::string("failed to encode content as JSON: ") + e.what());
114
- }
115
- return replace_raw(document, data);
116
- }
104
+ virtual auto replace(const transaction_get_result& document,
105
+ codec::encoded_value content) -> transaction_get_result = 0;
117
106
 
118
107
  /**
119
108
  * Inserts a new document into the specified Couchbase collection.
@@ -135,18 +124,9 @@ public:
135
124
  * @throws transaction_operation_failed which either should not be caught by
136
125
  * the lambda, or rethrown if it is caught.
137
126
  */
138
- template<typename Transcoder = codec::default_json_transcoder, typename Content>
139
- auto insert(const core::document_id& id, const Content& content) -> transaction_get_result
140
- {
141
- codec::encoded_value data;
142
- try {
143
- data = Transcoder::encode(content);
144
- } catch (std::runtime_error& e) {
145
- throw transaction_operation_failed(
146
- FAIL_OTHER, std::string("failed to encode content as JSON: ") + e.what());
147
- }
148
- return insert_raw(id, data);
149
- }
127
+ virtual auto insert(const core::document_id& id,
128
+ codec::encoded_value content) -> transaction_get_result = 0;
129
+
150
130
  /**
151
131
  * Removes the specified document, using the document's last
152
132
  * TransactionDocument#cas
@@ -179,6 +159,7 @@ public:
179
159
  {
180
160
  return do_core_query(statement, opts, query_context);
181
161
  };
162
+
182
163
  /**
183
164
  * Performs a Query, within the current transaction.
184
165
  *
@@ -218,14 +199,6 @@ public:
218
199
  virtual void rollback() = 0;
219
200
 
220
201
  protected:
221
- /** @internal */
222
- virtual auto insert_raw(const core::document_id& id,
223
- codec::encoded_value content) -> transaction_get_result = 0;
224
-
225
- /** @internal */
226
- virtual auto replace_raw(const transaction_get_result& document,
227
- codec::encoded_value content) -> transaction_get_result = 0;
228
-
229
202
  virtual auto do_core_query(const std::string&,
230
203
  const couchbase::transactions::transaction_query_options& opts,
231
204
  std::optional<std::string> query_context)
@@ -587,9 +587,9 @@ attempt_context_impl::create_document_metadata(
587
587
  }
588
588
 
589
589
  void
590
- attempt_context_impl::replace_raw(const transaction_get_result& document,
591
- codec::encoded_value content,
592
- Callback&& cb)
590
+ attempt_context_impl::replace(const transaction_get_result& document,
591
+ codec::encoded_value content,
592
+ Callback&& cb)
593
593
  {
594
594
 
595
595
  if (op_list_.get_mode().is_query()) {
@@ -852,19 +852,19 @@ attempt_context_impl::create_staged_replace(const transaction_get_result& docume
852
852
  }
853
853
 
854
854
  auto
855
- attempt_context_impl::replace_raw(const transaction_get_result& document,
856
- codec::encoded_value content) -> transaction_get_result
855
+ attempt_context_impl::replace(const transaction_get_result& document,
856
+ codec::encoded_value content) -> transaction_get_result
857
857
  {
858
858
  auto barrier = std::make_shared<std::promise<transaction_get_result>>();
859
859
  auto f = barrier->get_future();
860
- replace_raw(document,
861
- std::move(content),
862
- [barrier](const std::exception_ptr& err, std::optional<transaction_get_result> res) {
863
- if (err) {
864
- return barrier->set_exception(err);
865
- }
866
- barrier->set_value(std::move(*res));
867
- });
860
+ replace(document,
861
+ std::move(content),
862
+ [barrier](const std::exception_ptr& err, std::optional<transaction_get_result> res) {
863
+ if (err) {
864
+ return barrier->set_exception(err);
865
+ }
866
+ barrier->set_value(std::move(*res));
867
+ });
868
868
  return f.get();
869
869
  }
870
870
 
@@ -873,12 +873,12 @@ attempt_context_impl::replace_raw(couchbase::transactions::transaction_get_resul
873
873
  codec::encoded_value content,
874
874
  couchbase::transactions::async_result_handler&& handler)
875
875
  {
876
- replace_raw(core::transactions::transaction_get_result(doc),
877
- std::move(content),
878
- [handler = std::move(handler)](const std::exception_ptr& err,
879
- std::optional<transaction_get_result> res) mutable {
880
- wrap_callback_for_async_public_api(err, std::move(res), std::move(handler));
881
- });
876
+ replace(core::transactions::transaction_get_result(doc),
877
+ std::move(content),
878
+ [handler = std::move(handler)](const std::exception_ptr& err,
879
+ std::optional<transaction_get_result> res) mutable {
880
+ wrap_callback_for_async_public_api(err, std::move(res), std::move(handler));
881
+ });
882
882
  }
883
883
 
884
884
  auto
@@ -888,7 +888,7 @@ attempt_context_impl::replace_raw(const couchbase::transactions::transaction_get
888
888
  {
889
889
  return wrap_call_for_public_api(
890
890
  [self = shared_from_this(), doc, content = std::move(content)]() -> transaction_get_result {
891
- return self->replace_raw(transaction_get_result(doc), content);
891
+ return self->replace(transaction_get_result(doc), content);
892
892
  });
893
893
  }
894
894
 
@@ -900,8 +900,8 @@ attempt_context_impl::insert_raw(const collection& coll,
900
900
  {
901
901
  return wrap_call_for_public_api(
902
902
  [self = shared_from_this(), coll, &id, content = std::move(content)]() mutable {
903
- return self->insert_raw({ coll.bucket_name(), coll.scope_name(), coll.name(), id },
904
- std::move(content));
903
+ return self->insert({ coll.bucket_name(), coll.scope_name(), coll.name(), id },
904
+ std::move(content));
905
905
  });
906
906
  }
907
907
 
@@ -911,35 +911,35 @@ attempt_context_impl::insert_raw(const collection& coll,
911
911
  codec::encoded_value content,
912
912
  couchbase::transactions::async_result_handler&& handler)
913
913
  {
914
- insert_raw({ coll.bucket_name(), coll.scope_name(), coll.name(), std::move(id) },
915
- std::move(content),
916
- [handler = std::move(handler)](const std::exception_ptr& err,
917
- std::optional<transaction_get_result> res) mutable {
918
- wrap_callback_for_async_public_api(err, std::move(res), std::move(handler));
919
- });
914
+ insert({ coll.bucket_name(), coll.scope_name(), coll.name(), std::move(id) },
915
+ std::move(content),
916
+ [handler = std::move(handler)](const std::exception_ptr& err,
917
+ std::optional<transaction_get_result> res) mutable {
918
+ wrap_callback_for_async_public_api(err, std::move(res), std::move(handler));
919
+ });
920
920
  }
921
921
 
922
922
  auto
923
- attempt_context_impl::insert_raw(const core::document_id& id,
924
- codec::encoded_value content) -> transaction_get_result
923
+ attempt_context_impl::insert(const core::document_id& id,
924
+ codec::encoded_value content) -> transaction_get_result
925
925
  {
926
926
  auto barrier = std::make_shared<std::promise<transaction_get_result>>();
927
927
  auto f = barrier->get_future();
928
- insert_raw(id,
929
- std::move(content),
930
- [barrier](const std::exception_ptr& err, std::optional<transaction_get_result> res) {
931
- if (err) {
932
- return barrier->set_exception(err);
933
- }
934
- barrier->set_value(std::move(*res));
935
- });
928
+ insert(id,
929
+ std::move(content),
930
+ [barrier](const std::exception_ptr& err, std::optional<transaction_get_result> res) {
931
+ if (err) {
932
+ return barrier->set_exception(err);
933
+ }
934
+ barrier->set_value(std::move(*res));
935
+ });
936
936
  return f.get();
937
937
  }
938
938
 
939
939
  void
940
- attempt_context_impl::insert_raw(const core::document_id& id,
941
- codec::encoded_value content,
942
- Callback&& cb)
940
+ attempt_context_impl::insert(const core::document_id& id,
941
+ codec::encoded_value content,
942
+ Callback&& cb)
943
943
  {
944
944
  if (op_list_.get_mode().is_query()) {
945
945
  return insert_raw_with_query(id, std::move(content), std::move(cb));
@@ -92,37 +92,36 @@ private:
92
92
  // transaction_context needs access to the two functions below
93
93
  friend class transaction_context;
94
94
 
95
+ void insert(const core::document_id& id,
96
+ codec::encoded_value content,
97
+ core::transactions::async_attempt_context::Callback&& cb) override;
98
+
99
+ auto insert(const core::document_id& id,
100
+ codec::encoded_value content) -> core::transactions::transaction_get_result override;
101
+
102
+ void replace(const transaction_get_result& document,
103
+ codec::encoded_value content,
104
+ core::transactions::async_attempt_context::Callback&& cb) override;
105
+
106
+ auto replace(const transaction_get_result& document,
107
+ codec::encoded_value content) -> transaction_get_result override;
108
+
95
109
  auto insert_raw(const collection& coll, const std::string& id, codec::encoded_value content)
96
110
  -> std::pair<couchbase::error, couchbase::transactions::transaction_get_result> override;
97
- auto insert_raw(const core::document_id& id, codec::encoded_value content)
98
- -> core::transactions::transaction_get_result override;
99
111
 
100
112
  void insert_raw(const collection& coll,
101
113
  std::string id,
102
114
  codec::encoded_value content,
103
115
  couchbase::transactions::async_result_handler&& handler) override;
104
116
 
105
- void insert_raw(
106
- const core::document_id& id,
107
- codec::encoded_value content,
108
- std::function<void(std::exception_ptr, std::optional<transaction_get_result>)>&& cb) override;
109
-
110
117
  auto replace_raw(const couchbase::transactions::transaction_get_result& doc,
111
118
  codec::encoded_value content)
112
119
  -> std::pair<couchbase::error, couchbase::transactions::transaction_get_result> override;
113
120
 
114
- auto replace_raw(const transaction_get_result& document,
115
- codec::encoded_value content) -> transaction_get_result override;
116
-
117
121
  void replace_raw(couchbase::transactions::transaction_get_result doc,
118
122
  codec::encoded_value content,
119
123
  couchbase::transactions::async_result_handler&& handler) override;
120
124
 
121
- void replace_raw(
122
- const transaction_get_result& document,
123
- codec::encoded_value content,
124
- std::function<void(std::exception_ptr, std::optional<transaction_get_result>)>&& cb) override;
125
-
126
125
  void remove_staged_insert(const core::document_id& id, VoidCallback&& cb);
127
126
 
128
127
  void get_with_query(
@@ -200,7 +199,7 @@ private:
200
199
  std::exception_ptr&& err)
201
200
  {
202
201
  try {
203
- std::rethrow_exception(std::move(err));
202
+ std::rethrow_exception(err);
204
203
  } catch (const transaction_operation_failed& e) {
205
204
  // if this is a transaction_operation_failed, we need to cache it before
206
205
  // moving on...
@@ -180,7 +180,7 @@ transaction_context::insert(const core::document_id& id,
180
180
  async_attempt_context::Callback&& cb)
181
181
  {
182
182
  if (current_attempt_context_) {
183
- return current_attempt_context_->insert_raw(id, std::move(content), std::move(cb));
183
+ return current_attempt_context_->insert(id, std::move(content), std::move(cb));
184
184
  }
185
185
  throw transaction_operation_failed(FAIL_OTHER, "no current attempt context");
186
186
  }
@@ -191,7 +191,7 @@ transaction_context::replace(const transaction_get_result& doc,
191
191
  async_attempt_context::Callback&& cb)
192
192
  {
193
193
  if (current_attempt_context_) {
194
- return current_attempt_context_->replace_raw(doc, std::move(content), std::move(cb));
194
+ return current_attempt_context_->replace(doc, std::move(content), std::move(cb));
195
195
  }
196
196
  throw transaction_operation_failed(FAIL_OTHER, "no current attempt context");
197
197
  }
@@ -199,26 +199,6 @@ public:
199
199
  return os;
200
200
  }
201
201
 
202
- /**
203
- * Content of the document.
204
- *
205
- * @return content of the document.
206
- */
207
- template<typename Document,
208
- typename Transcoder = codec::default_json_transcoder,
209
- std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
210
- std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
211
- [[nodiscard]] auto content() const -> Document
212
- {
213
- return Transcoder::template decode<Document>(content_);
214
- }
215
-
216
- template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
217
- [[nodiscard]] auto content() const -> typename Transcoder::document_type
218
- {
219
- return Transcoder::decode(content_);
220
- }
221
-
222
202
  /**
223
203
  * Content of the document as raw byte vector
224
204
  *
@@ -18,6 +18,7 @@
18
18
  #pragma once
19
19
 
20
20
  #include <couchbase/retry_strategy.hxx>
21
+ #include <couchbase/tracing/request_span.hxx>
21
22
 
22
23
  #include <chrono>
23
24
  #include <memory>
@@ -69,6 +70,18 @@ public:
69
70
  return self();
70
71
  }
71
72
 
73
+ /**
74
+ * @param span
75
+ *
76
+ * @since 1.0.4
77
+ * @volatile
78
+ */
79
+ auto parent_span(std::shared_ptr<tracing::request_span> span) -> derived_class&
80
+ {
81
+ parent_span_ = std::move(span);
82
+ return self();
83
+ }
84
+
72
85
  /**
73
86
  * Immutable value object representing consistent options.
74
87
  *
@@ -78,6 +91,7 @@ public:
78
91
  struct built {
79
92
  const std::optional<std::chrono::milliseconds> timeout;
80
93
  const std::shared_ptr<couchbase::retry_strategy> retry_strategy;
94
+ const std::shared_ptr<tracing::request_span> parent_span;
81
95
  };
82
96
 
83
97
  protected:
@@ -88,7 +102,7 @@ protected:
88
102
  */
89
103
  [[nodiscard]] auto build_common_options() const -> built
90
104
  {
91
- return { timeout_, retry_strategy_ };
105
+ return { timeout_, retry_strategy_, parent_span_ };
92
106
  }
93
107
 
94
108
  /**
@@ -107,6 +121,7 @@ protected:
107
121
  private:
108
122
  std::optional<std::chrono::milliseconds> timeout_{};
109
123
  std::shared_ptr<couchbase::retry_strategy> retry_strategy_{ nullptr };
124
+ std::shared_ptr<tracing::request_span> parent_span_{ nullptr };
110
125
  };
111
126
 
112
127
  } // namespace couchbase
@@ -20,6 +20,7 @@
20
20
  #include "opentelemetry/sdk/metrics/meter.h"
21
21
  #include <couchbase/metrics/meter.hxx>
22
22
 
23
+ #include <algorithm>
23
24
  #include <iostream>
24
25
  #include <thread>
25
26
  #include <utility>
@@ -37,44 +38,39 @@ namespace couchbase::metrics
37
38
  class otel_sync_histogram
38
39
  {
39
40
  public:
40
- otel_sync_histogram(nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter)
41
+ otel_sync_histogram(nostd::shared_ptr<metrics_api::Histogram<std::uint64_t>> histogram_counter)
41
42
  : histogram_counter_(histogram_counter)
42
43
  {
43
44
  }
44
- void record(uint64_t value,
45
+
46
+ void record(std::uint64_t value,
45
47
  const opentelemetry::common::KeyValueIterable& tags,
46
48
  opentelemetry::context::Context& ctx)
47
49
  {
48
- // overflow
49
- if (value > LONG_MAX) {
50
- value = LONG_MAX;
51
- }
52
- long lvalue = static_cast<long>(value);
53
- histogram_counter_->Record(lvalue, tags, ctx);
50
+ histogram_counter_->Record(value, tags, ctx);
54
51
  }
55
52
 
56
53
  private:
57
- nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter_;
54
+ nostd::shared_ptr<metrics_api::Histogram<std::uint64_t>> histogram_counter_;
58
55
  std::mutex mutex_;
59
56
  };
60
57
 
61
58
  class otel_value_recorder : public couchbase::metrics::value_recorder
62
59
  {
63
60
  public:
64
- explicit otel_value_recorder(nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter,
65
- const std::map<std::string, std::string>& tags)
61
+ explicit otel_value_recorder(
62
+ nostd::shared_ptr<metrics_api::Histogram<std::uint64_t>> histogram_counter,
63
+ const std::map<std::string, std::string>& tags)
66
64
  : histogram_counter_(histogram_counter)
67
65
  , tags_(tags)
68
66
  {
69
67
  }
70
68
  void record_value(std::int64_t value) override
71
69
  {
72
- if (value > LONG_MAX) {
73
- value = LONG_MAX;
74
- }
75
- long lvalue = static_cast<long>(value);
70
+ value = std::max<int64_t>(value, 0);
71
+ auto uvalue = static_cast<std::uint64_t>(value);
76
72
  histogram_counter_->Record(
77
- value, opentelemetry::common::KeyValueIterableView<decltype(tags_)>{ tags_ }, context_);
73
+ uvalue, opentelemetry::common::KeyValueIterableView<decltype(tags_)>{ tags_ }, context_);
78
74
  }
79
75
 
80
76
  const std::map<std::string, std::string> tags()
@@ -82,13 +78,13 @@ public:
82
78
  return tags_;
83
79
  }
84
80
 
85
- nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter()
81
+ nostd::shared_ptr<metrics_api::Histogram<std::uint64_t>> histogram_counter()
86
82
  {
87
83
  return histogram_counter_;
88
84
  }
89
85
 
90
86
  private:
91
- nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter_;
87
+ nostd::shared_ptr<metrics_api::Histogram<std::uint64_t>> histogram_counter_;
92
88
  const std::map<std::string, std::string> tags_;
93
89
  opentelemetry::context::Context context_{};
94
90
  std::mutex mutex_;
@@ -115,8 +111,8 @@ public:
115
111
  // api doesn't seem to allow this.
116
112
  return recorders_
117
113
  .insert({ name,
118
- std::make_shared<otel_value_recorder>(meter_->CreateLongHistogram(name, "", "us"),
119
- tags) })
114
+ std::make_shared<otel_value_recorder>(
115
+ meter_->CreateUInt64Histogram(name, "", "us"), tags) })
120
116
  ->second;
121
117
  }
122
118
  // so it is already, lets see if we already have one with those tags, or need