couchbase 3.4.3 → 3.4.5

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 (179) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/couchbase/CMakeLists.txt +22 -1
  4. data/ext/couchbase/core/bucket.cxx +183 -152
  5. data/ext/couchbase/core/bucket.hxx +17 -4
  6. data/ext/couchbase/core/cluster.hxx +41 -13
  7. data/ext/couchbase/core/cluster_options.hxx +3 -0
  8. data/ext/couchbase/core/crud_component.cxx +51 -22
  9. data/ext/couchbase/core/error_context/key_value.cxx +2 -1
  10. data/ext/couchbase/core/error_context/key_value.hxx +10 -12
  11. data/ext/couchbase/core/impl/build_deferred_query_indexes.cxx +115 -50
  12. data/ext/couchbase/core/impl/cluster.cxx +6 -0
  13. data/ext/couchbase/core/impl/create_bucket.cxx +158 -0
  14. data/ext/couchbase/core/impl/create_collection.cxx +83 -0
  15. data/ext/couchbase/core/impl/create_query_index.cxx +172 -59
  16. data/ext/couchbase/core/impl/create_scope.cxx +69 -0
  17. data/ext/couchbase/core/impl/dns_srv_tracker.cxx +2 -1
  18. data/ext/couchbase/core/impl/drop_bucket.cxx +66 -0
  19. data/ext/couchbase/core/impl/drop_collection.cxx +76 -0
  20. data/ext/couchbase/core/impl/drop_query_index.cxx +138 -59
  21. data/ext/couchbase/core/impl/drop_scope.cxx +68 -0
  22. data/ext/couchbase/core/impl/flush_bucket.cxx +66 -0
  23. data/ext/couchbase/core/impl/get_all_buckets.cxx +178 -0
  24. data/ext/couchbase/core/impl/get_all_query_indexes.cxx +67 -37
  25. data/ext/couchbase/core/impl/get_all_scopes.cxx +94 -0
  26. data/ext/couchbase/core/impl/get_bucket.cxx +168 -0
  27. data/ext/couchbase/core/impl/internal_manager_error_context.cxx +113 -0
  28. data/ext/couchbase/core/impl/internal_manager_error_context.hxx +60 -0
  29. data/ext/couchbase/core/impl/key_value_error_category.cxx +2 -4
  30. data/ext/couchbase/core/impl/key_value_error_context.cxx +98 -0
  31. data/ext/couchbase/core/impl/lookup_in.cxx +1 -0
  32. data/ext/couchbase/core/impl/lookup_in_all_replicas.cxx +178 -0
  33. data/ext/couchbase/core/impl/lookup_in_all_replicas.hxx +80 -0
  34. data/ext/couchbase/core/impl/lookup_in_any_replica.cxx +169 -0
  35. data/ext/couchbase/core/impl/lookup_in_any_replica.hxx +75 -0
  36. data/ext/couchbase/core/impl/lookup_in_replica.cxx +104 -0
  37. data/ext/couchbase/core/impl/lookup_in_replica.hxx +67 -0
  38. data/ext/couchbase/core/impl/manager_error_context.cxx +100 -0
  39. data/ext/couchbase/core/impl/query.cxx +1 -0
  40. data/ext/couchbase/core/impl/query_error_context.cxx +75 -0
  41. data/ext/couchbase/core/impl/update_bucket.cxx +133 -0
  42. data/ext/couchbase/core/impl/update_collection.cxx +83 -0
  43. data/ext/couchbase/core/impl/watch_query_indexes.cxx +53 -29
  44. data/ext/couchbase/core/io/dns_client.cxx +111 -40
  45. data/ext/couchbase/core/io/dns_config.cxx +5 -4
  46. data/ext/couchbase/core/io/http_session.hxx +24 -1
  47. data/ext/couchbase/core/io/mcbp_command.hxx +9 -2
  48. data/ext/couchbase/core/io/mcbp_session.cxx +80 -43
  49. data/ext/couchbase/core/io/mcbp_session.hxx +4 -3
  50. data/ext/couchbase/core/logger/custom_rotating_file_sink.cxx +1 -1
  51. data/ext/couchbase/core/logger/logger.cxx +80 -20
  52. data/ext/couchbase/core/logger/logger.hxx +31 -0
  53. data/ext/couchbase/core/management/bucket_settings.hxx +8 -5
  54. data/ext/couchbase/core/management/bucket_settings_json.hxx +12 -2
  55. data/ext/couchbase/core/meta/features.hxx +42 -0
  56. data/ext/couchbase/core/operations/document_lookup_in.cxx +8 -1
  57. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +192 -0
  58. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +188 -0
  59. data/ext/couchbase/core/operations/document_query.cxx +11 -0
  60. data/ext/couchbase/core/operations/document_query.hxx +1 -0
  61. data/ext/couchbase/core/operations/management/CMakeLists.txt +1 -0
  62. data/ext/couchbase/core/operations/management/bucket_create.cxx +30 -9
  63. data/ext/couchbase/core/operations/management/bucket_update.cxx +27 -6
  64. data/ext/couchbase/core/operations/management/collection_create.cxx +5 -1
  65. data/ext/couchbase/core/operations/management/collection_create.hxx +1 -0
  66. data/ext/couchbase/core/operations/management/collection_update.cxx +87 -0
  67. data/ext/couchbase/core/operations/management/collection_update.hxx +54 -0
  68. data/ext/couchbase/core/operations/management/collections.hxx +1 -0
  69. data/ext/couchbase/core/operations.hxx +2 -0
  70. data/ext/couchbase/core/origin.cxx +270 -0
  71. data/ext/couchbase/core/origin.hxx +2 -0
  72. data/ext/couchbase/core/protocol/client_response.hxx +1 -0
  73. data/ext/couchbase/core/protocol/cmd_hello.hxx +1 -0
  74. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +107 -0
  75. data/ext/couchbase/core/protocol/cmd_lookup_in_replica.hxx +137 -0
  76. data/ext/couchbase/core/protocol/hello_feature.hxx +6 -0
  77. data/ext/couchbase/core/protocol/hello_feature_fmt.hxx +3 -0
  78. data/ext/couchbase/core/protocol/status.cxx +2 -2
  79. data/ext/couchbase/core/range_scan_options.cxx +3 -27
  80. data/ext/couchbase/core/range_scan_options.hxx +13 -17
  81. data/ext/couchbase/core/range_scan_orchestrator.cxx +388 -170
  82. data/ext/couchbase/core/range_scan_orchestrator.hxx +13 -2
  83. data/ext/couchbase/core/range_scan_orchestrator_options.hxx +5 -3
  84. data/ext/couchbase/core/scan_options.hxx +0 -19
  85. data/ext/couchbase/core/scan_result.cxx +19 -5
  86. data/ext/couchbase/core/scan_result.hxx +5 -2
  87. data/ext/couchbase/core/timeout_defaults.hxx +3 -4
  88. data/ext/couchbase/core/topology/capabilities.hxx +4 -0
  89. data/ext/couchbase/core/topology/capabilities_fmt.hxx +11 -0
  90. data/ext/couchbase/core/topology/collections_manifest.hxx +2 -0
  91. data/ext/couchbase/core/topology/collections_manifest_fmt.hxx +1 -1
  92. data/ext/couchbase/core/topology/collections_manifest_json.hxx +3 -0
  93. data/ext/couchbase/core/topology/configuration.hxx +20 -0
  94. data/ext/couchbase/core/topology/configuration_json.hxx +8 -1
  95. data/ext/couchbase/core/utils/connection_string.cxx +62 -47
  96. data/ext/couchbase/core/utils/connection_string.hxx +1 -0
  97. data/ext/couchbase/couchbase/analytics_error_context.hxx +1 -1
  98. data/ext/couchbase/couchbase/behavior_options.hxx +19 -2
  99. data/ext/couchbase/couchbase/bucket.hxx +14 -0
  100. data/ext/couchbase/couchbase/bucket_manager.hxx +135 -0
  101. data/ext/couchbase/couchbase/build_query_index_options.hxx +0 -30
  102. data/ext/couchbase/couchbase/cluster.hxx +14 -0
  103. data/ext/couchbase/couchbase/collection.hxx +111 -0
  104. data/ext/couchbase/couchbase/collection_manager.hxx +160 -0
  105. data/ext/couchbase/couchbase/collection_query_index_manager.hxx +7 -48
  106. data/ext/couchbase/couchbase/create_bucket_options.hxx +41 -0
  107. data/ext/couchbase/couchbase/create_collection_options.hxx +44 -0
  108. data/ext/couchbase/couchbase/create_primary_query_index_options.hxx +0 -29
  109. data/ext/couchbase/couchbase/create_query_index_options.hxx +0 -33
  110. data/ext/couchbase/couchbase/create_scope_options.hxx +41 -0
  111. data/ext/couchbase/couchbase/drop_bucket_options.hxx +41 -0
  112. data/ext/couchbase/couchbase/drop_collection_options.hxx +41 -0
  113. data/ext/couchbase/couchbase/drop_primary_query_index_options.hxx +0 -30
  114. data/ext/couchbase/couchbase/drop_query_index_options.hxx +0 -31
  115. data/ext/couchbase/couchbase/drop_scope_options.hxx +41 -0
  116. data/ext/couchbase/couchbase/error_codes.hxx +1 -2
  117. data/ext/couchbase/couchbase/error_context.hxx +10 -2
  118. data/ext/couchbase/couchbase/flush_bucket_options.hxx +41 -0
  119. data/ext/couchbase/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  120. data/ext/couchbase/couchbase/get_all_buckets_options.hxx +44 -0
  121. data/ext/couchbase/couchbase/get_all_query_indexes_options.hxx +0 -30
  122. data/ext/couchbase/couchbase/get_all_scopes_options.hxx +44 -0
  123. data/ext/couchbase/couchbase/get_and_lock_options.hxx +2 -2
  124. data/ext/couchbase/couchbase/get_and_touch_options.hxx +2 -2
  125. data/ext/couchbase/couchbase/get_bucket_options.hxx +43 -0
  126. data/ext/couchbase/couchbase/get_options.hxx +2 -2
  127. data/ext/couchbase/couchbase/insert_options.hxx +3 -3
  128. data/ext/couchbase/couchbase/key_value_error_context.hxx +7 -2
  129. data/ext/couchbase/couchbase/lookup_in_all_replicas_options.hxx +109 -0
  130. data/ext/couchbase/couchbase/lookup_in_any_replica_options.hxx +101 -0
  131. data/ext/couchbase/couchbase/lookup_in_options.hxx +2 -2
  132. data/ext/couchbase/couchbase/lookup_in_replica_result.hxx +74 -0
  133. data/ext/couchbase/couchbase/lookup_in_result.hxx +26 -0
  134. data/ext/couchbase/couchbase/management/bucket_settings.hxx +119 -0
  135. data/ext/couchbase/couchbase/management/collection_spec.hxx +29 -0
  136. data/ext/couchbase/couchbase/management/scope_spec.hxx +29 -0
  137. data/ext/couchbase/couchbase/manager_error_context.hxx +29 -53
  138. data/ext/couchbase/couchbase/mutate_in_options.hxx +2 -2
  139. data/ext/couchbase/couchbase/query_error_context.hxx +3 -1
  140. data/ext/couchbase/couchbase/query_index_manager.hxx +16 -83
  141. data/ext/couchbase/couchbase/query_options.hxx +18 -0
  142. data/ext/couchbase/couchbase/remove_options.hxx +2 -2
  143. data/ext/couchbase/couchbase/replace_options.hxx +3 -3
  144. data/ext/couchbase/couchbase/security_options.hxx +15 -0
  145. data/ext/couchbase/couchbase/subdocument_error_context.hxx +4 -2
  146. data/ext/couchbase/couchbase/touch_options.hxx +2 -2
  147. data/ext/couchbase/couchbase/unlock_options.hxx +2 -2
  148. data/ext/couchbase/couchbase/update_bucket_options.hxx +41 -0
  149. data/ext/couchbase/couchbase/update_collection_options.hxx +44 -0
  150. data/ext/couchbase/couchbase/upsert_options.hxx +3 -3
  151. data/ext/couchbase/couchbase/watch_query_indexes_options.hxx +0 -31
  152. data/ext/couchbase/test/CMakeLists.txt +1 -0
  153. data/ext/couchbase/test/test_integration_collections.cxx +6 -0
  154. data/ext/couchbase/test/test_integration_crud.cxx +5 -0
  155. data/ext/couchbase/test/test_integration_examples.cxx +137 -1
  156. data/ext/couchbase/test/test_integration_management.cxx +1009 -309
  157. data/ext/couchbase/test/test_integration_query.cxx +19 -7
  158. data/ext/couchbase/test/test_integration_range_scan.cxx +351 -112
  159. data/ext/couchbase/test/test_integration_search.cxx +10 -1
  160. data/ext/couchbase/test/test_integration_subdoc.cxx +721 -7
  161. data/ext/couchbase/test/test_transaction_public_async_api.cxx +13 -12
  162. data/ext/couchbase/test/test_transaction_public_blocking_api.cxx +27 -21
  163. data/ext/couchbase/test/test_unit_connection_string.cxx +29 -0
  164. data/ext/couchbase/test/test_unit_query.cxx +75 -0
  165. data/ext/couchbase.cxx +735 -60
  166. data/ext/revisions.rb +3 -3
  167. data/lib/couchbase/cluster.rb +1 -1
  168. data/lib/couchbase/collection.rb +108 -0
  169. data/lib/couchbase/collection_options.rb +100 -1
  170. data/lib/couchbase/errors.rb +5 -0
  171. data/lib/couchbase/key_value_scan.rb +125 -0
  172. data/lib/couchbase/management/bucket_manager.rb +22 -15
  173. data/lib/couchbase/management/collection_manager.rb +158 -9
  174. data/lib/couchbase/options.rb +151 -0
  175. data/lib/couchbase/scope.rb +1 -1
  176. data/lib/couchbase/utils/time.rb +14 -1
  177. data/lib/couchbase/version.rb +1 -1
  178. metadata +59 -8
  179. data/ext/couchbase/core/impl/collection_query_index_manager.cxx +0 -93
@@ -0,0 +1,29 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ namespace couchbase::management::bucket
21
+ {
22
+ struct collection_spec {
23
+ std::string name;
24
+ std::string scope_name;
25
+ std::uint32_t max_expiry{};
26
+ std::optional<bool> history{};
27
+ };
28
+
29
+ } // namespace couchbase::management::bucket
@@ -0,0 +1,29 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <couchbase/management/collection_spec.hxx>
21
+
22
+ namespace couchbase::management::bucket
23
+ {
24
+ struct scope_spec {
25
+ std::string name;
26
+ std::vector<collection_spec> collections;
27
+ };
28
+
29
+ } // namespace couchbase::management::bucket
@@ -17,14 +17,20 @@
17
17
 
18
18
  #pragma once
19
19
 
20
+ #include "core/impl/internal_manager_error_context.hxx"
20
21
  #include <couchbase/error_context.hxx>
21
22
 
22
23
  #include <cstdint>
24
+ #include <memory>
23
25
  #include <optional>
24
26
  #include <string>
25
27
 
26
28
  namespace couchbase
27
29
  {
30
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
31
+ class internal_manager_error_context;
32
+ #endif
33
+
28
34
  /**
29
35
  * The error context returned with manager operations.
30
36
  *
@@ -40,40 +46,25 @@ class manager_error_context : public error_context
40
46
  * @since 1.0.0
41
47
  * @committed
42
48
  */
43
- manager_error_context() = default;
49
+ manager_error_context();
50
+ explicit manager_error_context(internal_manager_error_context ctx);
51
+ manager_error_context(manager_error_context&& other);
52
+ manager_error_context& operator=(manager_error_context&& other);
53
+ manager_error_context(const manager_error_context& other) = delete;
54
+ manager_error_context& operator=(const manager_error_context& other) = delete;
55
+ ~manager_error_context() override;
44
56
 
45
- /**
46
- * Creates and initializes error context with given parameters.
47
- *
48
- * @param ec
49
- * @param last_dispatched_to
50
- * @param last_dispatched_from
51
- * @param retry_attempts
52
- * @param retry_reasons
53
- * @param client_context_id
54
- * @param http_status
55
- * @param content
56
- * @param path
57
- *
58
- * @since 1.0.0
59
- * @internal
60
- */
61
- manager_error_context(std::error_code ec,
62
- std::optional<std::string> last_dispatched_to,
63
- std::optional<std::string> last_dispatched_from,
64
- std::size_t retry_attempts,
65
- std::set<retry_reason> retry_reasons,
66
- std::string client_context_id,
67
- std::uint32_t http_status,
68
- std::string content,
69
- std::string path)
70
- : error_context{ ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
71
- , client_context_id_{ std::move(client_context_id) }
72
- , http_status_{ http_status }
73
- , content_{ std::move(content) }
74
- , path_{ std::move(path) }
75
- {
76
- }
57
+ [[nodiscard]] auto ec() const -> std::error_code override;
58
+
59
+ [[nodiscard]] auto last_dispatched_to() const -> const std::optional<std::string>& override;
60
+
61
+ [[nodiscard]] auto last_dispatched_from() const -> const std::optional<std::string>& override;
62
+
63
+ [[nodiscard]] auto retry_attempts() const -> std::size_t override;
64
+
65
+ [[nodiscard]] auto retry_reasons() const -> const std::set<retry_reason>& override;
66
+
67
+ [[nodiscard]] auto retried_because_of(retry_reason reason) const -> bool override;
77
68
 
78
69
  /**
79
70
  * Returns request path.
@@ -83,10 +74,7 @@ class manager_error_context : public error_context
83
74
  * @since 1.0.0
84
75
  * @uncommitted
85
76
  */
86
- [[nodiscard]] auto path() const -> const std::string&
87
- {
88
- return path_;
89
- }
77
+ [[nodiscard]] auto path() const -> const std::string&;
90
78
 
91
79
  /**
92
80
  * Returns response body.
@@ -96,10 +84,7 @@ class manager_error_context : public error_context
96
84
  * @since 1.0.0
97
85
  * @committed
98
86
  */
99
- [[nodiscard]] auto content() const -> const std::string&
100
- {
101
- return content_;
102
- }
87
+ [[nodiscard]] auto content() const -> const std::string&;
103
88
 
104
89
  /**
105
90
  * Returns the unique
@@ -109,10 +94,7 @@ class manager_error_context : public error_context
109
94
  * @since 1.0.0
110
95
  * @uncommitted
111
96
  */
112
- [[nodiscard]] auto client_context_id() const -> const std::string&
113
- {
114
- return client_context_id_;
115
- }
97
+ [[nodiscard]] auto client_context_id() const -> const std::string&;
116
98
 
117
99
  /**
118
100
  * Returns HTTP status of response
@@ -122,15 +104,9 @@ class manager_error_context : public error_context
122
104
  * @since 1.0.0
123
105
  * @committed
124
106
  */
125
- [[nodiscard]] auto http_status() const -> std::uint32_t
126
- {
127
- return http_status_;
128
- }
107
+ [[nodiscard]] auto http_status() const -> std::uint32_t;
129
108
 
130
109
  private:
131
- std::string client_context_id_{};
132
- std::uint32_t http_status_{};
133
- std::string content_{};
134
- std::string path_{};
110
+ std::unique_ptr<internal_manager_error_context> internal_;
135
111
  };
136
112
  } // namespace couchbase
@@ -225,8 +225,8 @@ initiate_mutate_in_operation(std::shared_ptr<couchbase::core::cluster> core,
225
225
  std::string collection_name,
226
226
  std::string document_key,
227
227
  const std::vector<couchbase::core::impl::subdoc::command>& specs,
228
- mutate_in_options::built options,
229
- mutate_in_handler&& handler);
228
+ couchbase::mutate_in_options::built options,
229
+ couchbase::mutate_in_handler&& handler);
230
230
  #endif
231
231
  } // namespace impl
232
232
  } // namespace core
@@ -57,7 +57,7 @@ class query_error_context : public error_context
57
57
  std::string http_body,
58
58
  std::string hostname,
59
59
  std::uint16_t port)
60
- : error_context{ ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
60
+ : error_context{ {}, ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
61
61
  , first_error_code_{ first_error_code }
62
62
  , first_error_message_{ std::move(first_error_message) }
63
63
  , client_context_id_{ std::move(client_context_id) }
@@ -127,6 +127,8 @@ class query_error_context : public error_context
127
127
  return port_;
128
128
  }
129
129
 
130
+ [[nodiscard]] auto to_json() const -> std::string;
131
+
130
132
  private:
131
133
  std::uint64_t first_error_code_{};
132
134
  std::string first_error_message_{};
@@ -61,19 +61,11 @@ class query_index_manager
61
61
  */
62
62
  void get_all_indexes(std::string bucket_name,
63
63
  const get_all_query_indexes_options& options,
64
- get_all_query_indexes_handler&& handler) const
65
- {
66
- return core::impl::initiate_get_all_query_indexes(
67
- core_, std::move(bucket_name), options.build(), std::forward<get_all_query_indexes_handler>(handler));
68
- }
64
+ get_all_query_indexes_handler&& handler) const;
65
+
69
66
  [[nodiscard]] auto get_all_indexes(std::string bucket_name, const get_all_query_indexes_options& options) const
70
- -> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>
71
- {
72
- auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>>();
73
- auto future = barrier->get_future();
74
- get_all_indexes(std::move(bucket_name), options, [barrier](auto ctx, auto resp) { barrier->set_value({ ctx, resp }); });
75
- return future;
76
- }
67
+ -> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>;
68
+
77
69
  /**
78
70
  * Create an index on a bucket.
79
71
  *
@@ -90,23 +82,12 @@ class query_index_manager
90
82
  std::string index_name,
91
83
  std::vector<std::string> fields,
92
84
  const create_query_index_options& options,
93
- create_query_index_handler&& handler) const
94
- {
95
- core::impl::initiate_create_query_index(
96
- core_, std::move(bucket_name), std::move(index_name), std::move(fields), options.build(), std::move(handler));
97
- }
85
+ create_query_index_handler&& handler) const;
98
86
 
99
87
  [[nodiscard]] auto create_index(std::string bucket_name,
100
88
  std::string index_name,
101
89
  std::vector<std::string> fields,
102
- const create_query_index_options& options) const -> std::future<manager_error_context>
103
- {
104
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
105
- auto future = barrier->get_future();
106
- create_index(
107
- std::move(bucket_name), std::move(index_name), std::move(fields), options, [barrier](auto ctx) { barrier->set_value(ctx); });
108
- return future;
109
- }
90
+ const create_query_index_options& options) const -> std::future<manager_error_context>;
110
91
 
111
92
  /**
112
93
  * Create a primary index on a bucket.
@@ -120,19 +101,10 @@ class query_index_manager
120
101
  */
121
102
  void create_primary_index(std::string bucket_name,
122
103
  const create_primary_query_index_options& options,
123
- create_query_index_handler&& handler)
124
- {
125
- return core::impl::initiate_create_primary_query_index(core_, std::move(bucket_name), options.build(), std::move(handler));
126
- }
104
+ create_query_index_handler&& handler);
127
105
 
128
106
  [[nodiscard]] auto create_primary_index(std::string bucket_name, const create_primary_query_index_options& options)
129
- -> std::future<manager_error_context>
130
- {
131
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
132
- auto future = barrier->get_future();
133
- create_primary_index(std::move(bucket_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
134
- return future;
135
- }
107
+ -> std::future<manager_error_context>;
136
108
  /**
137
109
  * Drop primary index on a bucket.
138
110
  *
@@ -143,19 +115,10 @@ class query_index_manager
143
115
  * @since 1.0.0
144
116
  * @committed
145
117
  */
146
- void drop_primary_index(std::string bucket_name, const drop_primary_query_index_options& options, drop_query_index_handler&& handler)
147
- {
148
- return core::impl::initiate_drop_primary_query_index(core_, std::move(bucket_name), options.build(), std::move(handler));
149
- }
118
+ void drop_primary_index(std::string bucket_name, const drop_primary_query_index_options& options, drop_query_index_handler&& handler);
150
119
 
151
120
  [[nodiscard]] auto drop_primary_index(std::string bucket_name, const drop_primary_query_index_options& options)
152
- -> std::future<manager_error_context>
153
- {
154
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
155
- auto future = barrier->get_future();
156
- drop_primary_index(std::move(bucket_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
157
- return future;
158
- }
121
+ -> std::future<manager_error_context>;
159
122
 
160
123
  /**
161
124
  *
@@ -170,20 +133,10 @@ class query_index_manager
170
133
  void drop_index(std::string bucket_name,
171
134
  std::string index_name,
172
135
  const drop_query_index_options& options,
173
- drop_query_index_handler&& handler)
174
- {
175
- return core::impl::initiate_drop_query_index(
176
- core_, std::move(bucket_name), std::move(index_name), options.build(), std::move(handler));
177
- }
136
+ drop_query_index_handler&& handler);
178
137
 
179
138
  [[nodiscard]] auto drop_index(std::string bucket_name, std::string index_name, const drop_query_index_options& options)
180
- -> std::future<manager_error_context>
181
- {
182
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
183
- auto future = barrier->get_future();
184
- drop_index(std::move(bucket_name), std::move(index_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
185
- return future;
186
- }
139
+ -> std::future<manager_error_context>;
187
140
  /**
188
141
  * Builds all currently deferred indexes.
189
142
  *
@@ -198,20 +151,10 @@ class query_index_manager
198
151
  */
199
152
  void build_deferred_indexes(std::string bucket_name,
200
153
  const build_query_index_options& options,
201
- build_deferred_query_indexes_handler&& handler) const
202
- {
203
- return core::impl::initiate_build_deferred_indexes(
204
- core_, std::move(bucket_name), options.build(), std::forward<build_deferred_query_indexes_handler>(handler));
205
- }
154
+ build_deferred_query_indexes_handler&& handler) const;
206
155
 
207
156
  [[nodiscard]] auto build_deferred_indexes(std::string bucket_name, const build_query_index_options& options) const
208
- -> std::future<manager_error_context>
209
- {
210
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
211
- auto future = barrier->get_future();
212
- build_deferred_indexes(std::move(bucket_name), options, [barrier](auto ctx) { barrier->set_value(std::move(ctx)); });
213
- return future;
214
- }
157
+ -> std::future<manager_error_context>;
215
158
 
216
159
  /**
217
160
  * Polls the state of a set of indexes, until they all are online.
@@ -227,21 +170,11 @@ class query_index_manager
227
170
  void watch_indexes(std::string bucket_name,
228
171
  std::vector<std::string> index_names,
229
172
  const watch_query_indexes_options& options,
230
- watch_query_indexes_handler&& handler)
231
- {
232
- return core::impl::initiate_watch_query_indexes(
233
- core_, std::move(bucket_name), std::move(index_names), options.build(), std::move(handler));
234
- }
173
+ watch_query_indexes_handler&& handler);
235
174
 
236
175
  [[nodiscard]] auto watch_indexes(std::string bucket_name,
237
176
  std::vector<std::string> index_names,
238
- const watch_query_indexes_options& options)
239
- {
240
- auto barrier = std::make_shared<std::promise<manager_error_context>>();
241
- auto future = barrier->get_future();
242
- watch_indexes(std::move(bucket_name), std::move(index_names), options, [barrier](auto ctx) { barrier->set_value(ctx); });
243
- return future;
244
- }
177
+ const watch_query_indexes_options& options) -> std::future<manager_error_context>;
245
178
 
246
179
  private:
247
180
  friend class cluster;
@@ -51,6 +51,7 @@ struct query_options : public common_options<query_options> {
51
51
  const bool readonly;
52
52
  const bool flex_index;
53
53
  const bool preserve_expiry;
54
+ std::optional<bool> use_replica;
54
55
  std::optional<std::uint64_t> max_parallelism;
55
56
  std::optional<std::uint64_t> scan_cap;
56
57
  std::optional<std::chrono::milliseconds> scan_wait;
@@ -84,6 +85,7 @@ struct query_options : public common_options<query_options> {
84
85
  readonly_,
85
86
  flex_index_,
86
87
  preserve_expiry_,
88
+ use_replica_,
87
89
  max_parallelism_,
88
90
  scan_cap_,
89
91
  scan_wait_,
@@ -225,6 +227,21 @@ struct query_options : public common_options<query_options> {
225
227
  return self();
226
228
  }
227
229
 
230
+ /**
231
+ * Specifies that the query engine should use replica nodes for KV fetches if the active node is down.
232
+ *
233
+ * @param use_replica whether replica nodes should be used if the active node is down. If not provided, the server default will be used.
234
+ * @return the options builder for chaining purposes.
235
+ *
236
+ * @since 1.0.0
237
+ * @committed
238
+ */
239
+ auto use_replica(bool use_replica) -> query_options&
240
+ {
241
+ use_replica_ = use_replica;
242
+ return self();
243
+ }
244
+
228
245
  /**
229
246
  * Allows overriding the default maximum parallelism for the query execution on the server side.
230
247
  *
@@ -529,6 +546,7 @@ struct query_options : public common_options<query_options> {
529
546
  bool readonly_{ false };
530
547
  bool flex_index_{ false };
531
548
  bool preserve_expiry_{ false };
549
+ std::optional<bool> use_replica_{};
532
550
  std::optional<std::uint64_t> max_parallelism_{};
533
551
  std::optional<std::uint64_t> scan_cap_{};
534
552
  std::optional<std::uint64_t> pipeline_batch_{};
@@ -115,8 +115,8 @@ initiate_remove_operation(std::shared_ptr<couchbase::core::cluster> core,
115
115
  std::string scope_name,
116
116
  std::string collection_name,
117
117
  std::string document_key,
118
- remove_options::built options,
119
- remove_handler&& handler);
118
+ couchbase::remove_options::built options,
119
+ couchbase::remove_handler&& handler);
120
120
  #endif
121
121
  } // namespace impl
122
122
  } // namespace core
@@ -175,9 +175,9 @@ initiate_replace_operation(std::shared_ptr<couchbase::core::cluster> core,
175
175
  std::string scope_name,
176
176
  std::string collection_name,
177
177
  std::string document_key,
178
- codec::encoded_value encoded,
179
- replace_options::built options,
180
- replace_handler&& handler);
178
+ couchbase::codec::encoded_value encoded,
179
+ couchbase::replace_options::built options,
180
+ couchbase::replace_handler&& handler);
181
181
  #endif
182
182
  } // namespace impl
183
183
  } // namespace core
@@ -45,11 +45,20 @@ class security_options
45
45
  return *this;
46
46
  }
47
47
 
48
+ auto trust_certificate_value(std::string certificate_value) -> security_options&
49
+ {
50
+ trust_certificate_value_ = certificate_value;
51
+ return *this;
52
+ }
53
+
48
54
  struct built {
49
55
  bool enabled;
50
56
  tls_verify_mode tls_verify;
51
57
  std::optional<std::string> trust_certificate;
58
+ std::optional<std::string> trust_certificate_value;
52
59
  bool disable_mozilla_ca_certificates;
60
+ bool disable_deprecated_protocols;
61
+ bool disable_tls_v1_2;
53
62
  };
54
63
 
55
64
  [[nodiscard]] auto build() const -> built
@@ -58,7 +67,10 @@ class security_options
58
67
  enabled_,
59
68
  tls_verify_,
60
69
  trust_certificate_,
70
+ trust_certificate_value_,
61
71
  disable_mozilla_ca_certificates_,
72
+ disable_deprecated_protocols,
73
+ disable_tls_v1_2,
62
74
  };
63
75
  }
64
76
 
@@ -66,6 +78,9 @@ class security_options
66
78
  bool enabled_{ true };
67
79
  tls_verify_mode tls_verify_{ tls_verify_mode::peer };
68
80
  std::optional<std::string> trust_certificate_{};
81
+ std::optional<std::string> trust_certificate_value_{};
69
82
  bool disable_mozilla_ca_certificates_{ false };
83
+ bool disable_deprecated_protocols{ true };
84
+ bool disable_tls_v1_2{ false };
70
85
  };
71
86
  } // namespace couchbase
@@ -62,7 +62,8 @@ class subdocument_error_context : public key_value_error_context
62
62
  * @since 1.0.0
63
63
  * @internal
64
64
  */
65
- subdocument_error_context(std::error_code ec,
65
+ subdocument_error_context(std::string operation_id,
66
+ std::error_code ec,
66
67
  std::optional<std::string> last_dispatched_to,
67
68
  std::optional<std::string> last_dispatched_from,
68
69
  std::size_t retry_attempts,
@@ -79,7 +80,8 @@ class subdocument_error_context : public key_value_error_context
79
80
  std::optional<std::string> first_error_path,
80
81
  std::optional<std::uint64_t> first_error_index,
81
82
  bool deleted)
82
- : key_value_error_context{ ec,
83
+ : key_value_error_context{ std::move(operation_id),
84
+ ec,
83
85
  std::move(last_dispatched_to),
84
86
  std::move(last_dispatched_from),
85
87
  retry_attempts,
@@ -86,8 +86,8 @@ initiate_touch_operation(std::shared_ptr<couchbase::core::cluster> core,
86
86
  std::string collection_name,
87
87
  std::string document_key,
88
88
  std::uint32_t expiry,
89
- touch_options::built options,
90
- touch_handler&& handler);
89
+ couchbase::touch_options::built options,
90
+ couchbase::touch_handler&& handler);
91
91
  #endif
92
92
  } // namespace impl
93
93
  } // namespace core
@@ -89,8 +89,8 @@ initiate_unlock_operation(std::shared_ptr<couchbase::core::cluster> core,
89
89
  std::string collection_name,
90
90
  std::string document_key,
91
91
  couchbase::cas cas,
92
- unlock_options::built options,
93
- unlock_handler&& handler);
92
+ couchbase::unlock_options::built options,
93
+ couchbase::unlock_handler&& handler);
94
94
  #endif
95
95
  } // namespace impl
96
96
  } // namespace core
@@ -0,0 +1,41 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <functional>
21
+ #include <memory>
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ struct update_bucket_options : public common_options<update_bucket_options> {
28
+ public:
29
+ struct built : public common_options<update_bucket_options>::built {
30
+ };
31
+
32
+ [[nodiscard]] auto build() const -> built
33
+ {
34
+ return { build_common_options() };
35
+ }
36
+
37
+ private:
38
+ };
39
+
40
+ using update_bucket_handler = std::function<void(couchbase::manager_error_context)>;
41
+ } // namespace couchbase
@@ -0,0 +1,44 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <functional>
21
+ #include <memory>
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ struct update_collection_options : public common_options<update_collection_options> {
28
+ public:
29
+ struct built : public common_options<update_collection_options>::built {
30
+ };
31
+
32
+ [[nodiscard]] auto build() const -> built
33
+ {
34
+ return { build_common_options() };
35
+ }
36
+ };
37
+
38
+ struct update_collection_settings {
39
+ std::optional<std::uint32_t> max_expiry{};
40
+ std::optional<bool> history{};
41
+ };
42
+
43
+ using update_collection_handler = std::function<void(couchbase::manager_error_context)>;
44
+ } // namespace couchbase
@@ -149,9 +149,9 @@ initiate_upsert_operation(std::shared_ptr<couchbase::core::cluster> core,
149
149
  std::string scope_name,
150
150
  std::string collection_name,
151
151
  std::string document_key,
152
- codec::encoded_value encoded,
153
- upsert_options::built options,
154
- upsert_handler&& handler);
152
+ couchbase::codec::encoded_value encoded,
153
+ couchbase::upsert_options::built options,
154
+ couchbase::upsert_handler&& handler);
155
155
  #endif
156
156
  } // namespace impl
157
157
  } // namespace core