couchbase 4.2.5 → 4.2.6-dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +9 -1
  2. package/deps/couchbase-cxx-client/bin/api.rb +234 -0
  3. package/deps/couchbase-cxx-client/bin/create-search-index +18 -135
  4. package/deps/couchbase-cxx-client/bin/init-cluster +17 -139
  5. package/deps/couchbase-cxx-client/bin/load-sample-buckets +54 -0
  6. package/deps/couchbase-cxx-client/core/cluster.hxx +33 -12
  7. package/deps/couchbase-cxx-client/core/cluster_options.hxx +3 -0
  8. package/deps/couchbase-cxx-client/core/crud_component.cxx +51 -22
  9. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +115 -50
  10. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +6 -0
  11. package/deps/couchbase-cxx-client/core/impl/create_bucket.cxx +155 -0
  12. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +172 -59
  13. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +2 -1
  14. package/deps/couchbase-cxx-client/core/impl/drop_bucket.cxx +66 -0
  15. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +138 -59
  16. package/deps/couchbase-cxx-client/core/impl/flush_bucket.cxx +66 -0
  17. package/deps/couchbase-cxx-client/core/impl/get_all_buckets.cxx +163 -0
  18. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +67 -37
  19. package/deps/couchbase-cxx-client/core/impl/get_bucket.cxx +153 -0
  20. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.cxx +113 -0
  21. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.hxx +60 -0
  22. package/deps/couchbase-cxx-client/core/impl/key_value_error_category.cxx +2 -4
  23. package/deps/couchbase-cxx-client/core/impl/manager_error_context.cxx +100 -0
  24. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  25. package/deps/couchbase-cxx-client/core/impl/update_bucket.cxx +130 -0
  26. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +53 -29
  27. package/deps/couchbase-cxx-client/core/io/dns_client.cxx +71 -38
  28. package/deps/couchbase-cxx-client/core/io/dns_config.cxx +5 -4
  29. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +5 -6
  30. package/deps/couchbase-cxx-client/core/meta/features.hxx +6 -0
  31. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +11 -0
  32. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  33. package/deps/couchbase-cxx-client/core/origin.cxx +270 -0
  34. package/deps/couchbase-cxx-client/core/origin.hxx +2 -0
  35. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -2
  36. package/deps/couchbase-cxx-client/core/range_scan_options.cxx +3 -27
  37. package/deps/couchbase-cxx-client/core/range_scan_options.hxx +13 -17
  38. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +367 -170
  39. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +13 -2
  40. package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +5 -3
  41. package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -19
  42. package/deps/couchbase-cxx-client/core/scan_result.cxx +19 -5
  43. package/deps/couchbase-cxx-client/core/scan_result.hxx +5 -2
  44. package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +2 -3
  45. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +1 -0
  46. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +2 -0
  47. package/deps/couchbase-cxx-client/core/topology/collections_manifest_fmt.hxx +1 -1
  48. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +5 -0
  49. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +2 -0
  50. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +4 -0
  51. package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +19 -2
  52. package/deps/couchbase-cxx-client/couchbase/bucket_manager.hxx +135 -0
  53. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +0 -30
  54. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +14 -0
  55. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +7 -48
  56. package/deps/couchbase-cxx-client/couchbase/create_bucket_options.hxx +41 -0
  57. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +0 -29
  58. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +0 -33
  59. package/deps/couchbase-cxx-client/couchbase/drop_bucket_options.hxx +41 -0
  60. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +0 -30
  61. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +0 -31
  62. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -2
  63. package/deps/couchbase-cxx-client/couchbase/flush_bucket_options.hxx +41 -0
  64. package/deps/couchbase-cxx-client/couchbase/get_all_buckets_options.hxx +44 -0
  65. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +0 -30
  66. package/deps/couchbase-cxx-client/couchbase/get_bucket_options.hxx +43 -0
  67. package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +116 -0
  68. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +29 -53
  69. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +16 -83
  70. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +18 -0
  71. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +15 -0
  72. package/deps/couchbase-cxx-client/couchbase/update_bucket_options.hxx +41 -0
  73. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +0 -31
  74. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +1 -0
  75. package/deps/couchbase-cxx-client/docs/cbc-get.md +1 -0
  76. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +1 -0
  77. package/deps/couchbase-cxx-client/docs/cbc-query.md +1 -0
  78. package/deps/couchbase-cxx-client/docs/cbc.md +10 -0
  79. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  80. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +6 -0
  81. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +5 -0
  82. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +137 -1
  83. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +709 -266
  84. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +19 -7
  85. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +351 -112
  86. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +10 -1
  87. package/deps/couchbase-cxx-client/test/test_transaction_public_async_api.cxx +13 -12
  88. package/deps/couchbase-cxx-client/test/test_transaction_public_blocking_api.cxx +27 -21
  89. package/deps/couchbase-cxx-client/test/test_unit_query.cxx +75 -0
  90. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +5 -0
  91. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +29 -10
  92. package/deps/couchbase-cxx-client/test/utils/wait_until.hxx +3 -1
  93. package/deps/couchbase-cxx-client/tools/utils.cxx +4 -1
  94. package/dist/binding.d.ts +21 -16
  95. package/dist/binding.js +1 -4
  96. package/dist/bindingutilities.d.ts +6 -1
  97. package/dist/bindingutilities.js +36 -1
  98. package/dist/collection.d.ts +65 -3
  99. package/dist/collection.js +107 -0
  100. package/dist/crudoptypes.d.ts +34 -0
  101. package/dist/crudoptypes.js +18 -1
  102. package/dist/queryexecutor.js +1 -0
  103. package/dist/querytypes.d.ts +7 -0
  104. package/dist/rangeScan.d.ts +107 -0
  105. package/dist/rangeScan.js +91 -0
  106. package/dist/streamablepromises.d.ts +6 -0
  107. package/dist/streamablepromises.js +25 -1
  108. package/package.json +12 -13
  109. package/src/addondata.hpp +1 -0
  110. package/src/binding.cpp +5 -2
  111. package/src/connection.cpp +108 -2
  112. package/src/connection.hpp +1 -0
  113. package/src/constants.cpp +2 -12
  114. package/src/jstocbpp_autogen.hpp +49 -22
  115. package/src/jstocbpp_basic.hpp +2 -8
  116. package/src/mutationtoken.cpp +13 -0
  117. package/src/scan_iterator.cpp +90 -0
  118. package/src/scan_iterator.hpp +30 -0
  119. package/tools/gen-bindings-json.py +9 -8
  120. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +0 -93
@@ -0,0 +1,153 @@
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
+ #include <couchbase/manager_error_context.hxx>
19
+ #include <utility>
20
+
21
+ #include "core/cluster.hxx"
22
+ #include "core/operations/management/bucket_get.hxx"
23
+ #include "couchbase/bucket_manager.hxx"
24
+
25
+ namespace couchbase
26
+ {
27
+ template<typename Response>
28
+ static manager_error_context
29
+ build_context(Response& resp)
30
+ {
31
+ return manager_error_context(internal_manager_error_context{ resp.ctx.ec,
32
+ resp.ctx.last_dispatched_to,
33
+ resp.ctx.last_dispatched_from,
34
+ resp.ctx.retry_attempts,
35
+ std::move(resp.ctx.retry_reasons),
36
+ std::move(resp.ctx.client_context_id),
37
+ resp.ctx.http_status,
38
+ std::move(resp.ctx.http_body),
39
+ std::move(resp.ctx.path) });
40
+ }
41
+
42
+ static core::operations::management::bucket_get_request
43
+ build_get_bucket_request(std::string bucket_name, const get_bucket_options::built& options)
44
+ {
45
+ core::operations::management::bucket_get_request request{ std::move(bucket_name), {}, options.timeout };
46
+ return request;
47
+ }
48
+
49
+ static couchbase::management::cluster::bucket_settings
50
+ map_bucket_settings(const couchbase::core::management::cluster::bucket_settings& bucket)
51
+ {
52
+ couchbase::management::cluster::bucket_settings bucket_settings{};
53
+ bucket_settings.name = bucket.name;
54
+ bucket_settings.ram_quota_mb = bucket.ram_quota_mb;
55
+ bucket_settings.max_expiry = bucket.max_expiry;
56
+ bucket_settings.minimum_durability_level = bucket.minimum_durability_level;
57
+ bucket_settings.num_replicas = bucket.num_replicas;
58
+ bucket_settings.replica_indexes = bucket.replica_indexes;
59
+ bucket_settings.flush_enabled = bucket.flush_enabled;
60
+ switch (bucket.conflict_resolution_type) {
61
+ case core::management::cluster::bucket_conflict_resolution::unknown:
62
+ bucket_settings.conflict_resolution_type = management::cluster::bucket_conflict_resolution::unknown;
63
+ break;
64
+ case core::management::cluster::bucket_conflict_resolution::timestamp:
65
+ bucket_settings.conflict_resolution_type = management::cluster::bucket_conflict_resolution::timestamp;
66
+ break;
67
+ case core::management::cluster::bucket_conflict_resolution::sequence_number:
68
+ bucket_settings.conflict_resolution_type = management::cluster::bucket_conflict_resolution::sequence_number;
69
+ break;
70
+ case core::management::cluster::bucket_conflict_resolution::custom:
71
+ bucket_settings.conflict_resolution_type = management::cluster::bucket_conflict_resolution::custom;
72
+ break;
73
+ }
74
+ switch (bucket.eviction_policy) {
75
+ case core::management::cluster::bucket_eviction_policy::unknown:
76
+ bucket_settings.eviction_policy = management::cluster::bucket_eviction_policy::unknown;
77
+ break;
78
+ case core::management::cluster::bucket_eviction_policy::full:
79
+ bucket_settings.eviction_policy = management::cluster::bucket_eviction_policy::full;
80
+ break;
81
+ case core::management::cluster::bucket_eviction_policy::value_only:
82
+ bucket_settings.eviction_policy = management::cluster::bucket_eviction_policy::value_only;
83
+ break;
84
+ case core::management::cluster::bucket_eviction_policy::no_eviction:
85
+ bucket_settings.eviction_policy = management::cluster::bucket_eviction_policy::no_eviction;
86
+ break;
87
+ case core::management::cluster::bucket_eviction_policy::not_recently_used:
88
+ bucket_settings.eviction_policy = management::cluster::bucket_eviction_policy::not_recently_used;
89
+ break;
90
+ }
91
+ switch (bucket.compression_mode) {
92
+ case core::management::cluster::bucket_compression::unknown:
93
+ bucket_settings.compression_mode = management::cluster::bucket_compression::unknown;
94
+ break;
95
+ case core::management::cluster::bucket_compression::off:
96
+ bucket_settings.compression_mode = management::cluster::bucket_compression::off;
97
+ break;
98
+ case core::management::cluster::bucket_compression::active:
99
+ bucket_settings.compression_mode = management::cluster::bucket_compression::active;
100
+ break;
101
+ case core::management::cluster::bucket_compression::passive:
102
+ bucket_settings.compression_mode = management::cluster::bucket_compression::passive;
103
+ break;
104
+ }
105
+ switch (bucket.bucket_type) {
106
+ case core::management::cluster::bucket_type::unknown:
107
+ bucket_settings.bucket_type = management::cluster::bucket_type::unknown;
108
+ break;
109
+ case core::management::cluster::bucket_type::couchbase:
110
+ bucket_settings.bucket_type = management::cluster::bucket_type::couchbase;
111
+ break;
112
+ case core::management::cluster::bucket_type::memcached:
113
+ bucket_settings.bucket_type = management::cluster::bucket_type::memcached;
114
+ break;
115
+ case core::management::cluster::bucket_type::ephemeral:
116
+ bucket_settings.bucket_type = management::cluster::bucket_type::ephemeral;
117
+ break;
118
+ }
119
+ switch (bucket.storage_backend) {
120
+ case core::management::cluster::bucket_storage_backend::unknown:
121
+ bucket_settings.storage_backend = management::cluster::bucket_storage_backend::unknown;
122
+ break;
123
+ case core::management::cluster::bucket_storage_backend::couchstore:
124
+ bucket_settings.storage_backend = management::cluster::bucket_storage_backend::couchstore;
125
+ break;
126
+ case core::management::cluster::bucket_storage_backend::magma:
127
+ bucket_settings.storage_backend = management::cluster::bucket_storage_backend::magma;
128
+ break;
129
+ }
130
+ return bucket_settings;
131
+ }
132
+
133
+ void
134
+ bucket_manager::get_bucket(std::string bucket_name, const get_bucket_options& options, get_bucket_handler&& handler) const
135
+ {
136
+ auto request = build_get_bucket_request(std::move(bucket_name), options.build());
137
+
138
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::bucket_get_response resp) mutable {
139
+ return handler(build_context(resp), map_bucket_settings(resp.bucket));
140
+ });
141
+ }
142
+
143
+ auto
144
+ bucket_manager::get_bucket(std::string bucket_name, const get_bucket_options& options) const
145
+ -> std::future<std::pair<manager_error_context, management::cluster::bucket_settings>>
146
+ {
147
+ auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, management::cluster::bucket_settings>>>();
148
+ get_bucket(std::move(bucket_name), options, [barrier](auto ctx, auto result) mutable {
149
+ barrier->set_value(std::make_pair(std::move(ctx), std::move(result)));
150
+ });
151
+ return barrier->get_future();
152
+ }
153
+ } // namespace couchbase
@@ -0,0 +1,113 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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
+ #include "internal_manager_error_context.hxx"
19
+ #include <couchbase/error_context.hxx>
20
+
21
+ #include <optional>
22
+
23
+ namespace couchbase
24
+ {
25
+ internal_manager_error_context::internal_manager_error_context(internal_manager_error_context&& other) noexcept = default;
26
+
27
+ internal_manager_error_context&
28
+ internal_manager_error_context::operator=(internal_manager_error_context&& other) noexcept = default;
29
+
30
+ internal_manager_error_context::internal_manager_error_context(std::error_code ec,
31
+ std::optional<std::string> last_dispatched_to,
32
+ std::optional<std::string> last_dispatched_from,
33
+ std::size_t retry_attempts,
34
+ std::set<retry_reason> retry_reasons,
35
+ std::string client_context_id,
36
+ std::uint32_t http_status,
37
+ std::string content,
38
+ std::string path)
39
+ : ctx_{ ec,
40
+ std::move(client_context_id),
41
+ {},
42
+ std::move(path),
43
+ http_status,
44
+ { std::move(content) },
45
+ {},
46
+ {},
47
+ std::move(last_dispatched_to),
48
+ std::move(last_dispatched_from),
49
+ retry_attempts,
50
+ std::move(retry_reasons) }
51
+ {
52
+ }
53
+
54
+ auto
55
+ internal_manager_error_context::path() const -> const std::string&
56
+ {
57
+ return ctx_.path;
58
+ }
59
+
60
+ auto
61
+ internal_manager_error_context::content() const -> const std::string&
62
+ {
63
+ return ctx_.http_body;
64
+ }
65
+
66
+ auto
67
+ internal_manager_error_context::client_context_id() const -> const std::string&
68
+ {
69
+ return ctx_.client_context_id;
70
+ }
71
+
72
+ auto
73
+ internal_manager_error_context::http_status() const -> std::uint32_t
74
+ {
75
+ return ctx_.http_status;
76
+ }
77
+
78
+ auto
79
+ internal_manager_error_context::ec() const -> std::error_code
80
+ {
81
+ return ctx_.ec;
82
+ }
83
+
84
+ auto
85
+ internal_manager_error_context::last_dispatched_to() const -> const std::optional<std::string>&
86
+ {
87
+ return ctx_.last_dispatched_to;
88
+ }
89
+
90
+ auto
91
+ internal_manager_error_context::last_dispatched_from() const -> const std::optional<std::string>&
92
+ {
93
+ return ctx_.last_dispatched_from;
94
+ }
95
+
96
+ auto
97
+ internal_manager_error_context::retry_attempts() const -> std::size_t
98
+ {
99
+ return ctx_.retry_attempts;
100
+ }
101
+
102
+ auto
103
+ internal_manager_error_context::retry_reasons() const -> const std::set<retry_reason>&
104
+ {
105
+ return ctx_.retry_reasons;
106
+ }
107
+
108
+ auto
109
+ internal_manager_error_context::retried_because_of(retry_reason reason) const -> bool
110
+ {
111
+ return ctx_.retry_reasons.count(reason) > 0;
112
+ }
113
+ } // namespace couchbase
@@ -0,0 +1,60 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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 "core/error_context/http.hxx"
21
+
22
+ #include <cstdint>
23
+ #include <optional>
24
+ #include <string>
25
+
26
+ namespace couchbase
27
+ {
28
+ class internal_manager_error_context
29
+ {
30
+ public:
31
+ explicit internal_manager_error_context(std::error_code ec,
32
+ std::optional<std::string> last_dispatched_to,
33
+ std::optional<std::string> last_dispatched_from,
34
+ std::size_t retry_attempts,
35
+ std::set<retry_reason> retry_reasons,
36
+ std::string client_context_id,
37
+ std::uint32_t http_status,
38
+ std::string content,
39
+ std::string path);
40
+ internal_manager_error_context(internal_manager_error_context&& other) noexcept;
41
+ internal_manager_error_context& operator=(internal_manager_error_context&& other) noexcept;
42
+ internal_manager_error_context(const internal_manager_error_context& other) = delete;
43
+ internal_manager_error_context& operator=(const internal_manager_error_context& other) = delete;
44
+
45
+ [[nodiscard]] auto path() const -> const std::string&;
46
+ [[nodiscard]] auto content() const -> const std::string&;
47
+ [[nodiscard]] auto client_context_id() const -> const std::string&;
48
+ [[nodiscard]] auto http_status() const -> std::uint32_t;
49
+
50
+ [[nodiscard]] auto ec() const -> std::error_code;
51
+ [[nodiscard]] auto last_dispatched_to() const -> const std::optional<std::string>&;
52
+ [[nodiscard]] auto last_dispatched_from() const -> const std::optional<std::string>&;
53
+ [[nodiscard]] auto retry_attempts() const -> std::size_t;
54
+ [[nodiscard]] auto retry_reasons() const -> const std::set<retry_reason>&;
55
+ [[nodiscard]] auto retried_because_of(retry_reason reason) const -> bool;
56
+
57
+ private:
58
+ core::error_context::http ctx_;
59
+ };
60
+ } // namespace couchbase
@@ -84,10 +84,8 @@ struct key_value_error_category : std::error_category {
84
84
  return "cannot_revive_living_document (131)";
85
85
  case errc::key_value::xattr_no_access:
86
86
  return "xattr_no_access (130)";
87
- case errc::key_value::range_scan_cancelled:
88
- return "range_scan_cancelled (132)";
89
- case errc::key_value::range_scan_vb_uuid_not_equal:
90
- return "range_scan_vb_uuid_not_equal (133)";
87
+ case errc::key_value::mutation_token_outdated:
88
+ return "mutation_token_outdated (133)";
91
89
  case errc::key_value::range_scan_completed:
92
90
  return "range_scan_completed (134)";
93
91
  }
@@ -0,0 +1,100 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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
+ #include "internal_manager_error_context.hxx"
19
+
20
+ #include <couchbase/manager_error_context.hxx>
21
+
22
+ namespace couchbase
23
+ {
24
+ manager_error_context::manager_error_context()
25
+ : internal_{ nullptr }
26
+ {
27
+ }
28
+
29
+ manager_error_context::manager_error_context(internal_manager_error_context ctx)
30
+ : internal_{ std::make_unique<internal_manager_error_context>(std::move(ctx)) }
31
+ {
32
+ }
33
+
34
+ manager_error_context::manager_error_context(manager_error_context&& other) = default;
35
+
36
+ manager_error_context&
37
+ manager_error_context::operator=(manager_error_context&& other) = default;
38
+
39
+ manager_error_context::~manager_error_context() = default;
40
+
41
+ auto
42
+ manager_error_context::ec() const -> std::error_code
43
+ {
44
+ return internal_->ec();
45
+ }
46
+
47
+ auto
48
+ manager_error_context::last_dispatched_from() const -> const std::optional<std::string>&
49
+ {
50
+ return internal_->last_dispatched_from();
51
+ }
52
+
53
+ auto
54
+ manager_error_context::last_dispatched_to() const -> const std::optional<std::string>&
55
+ {
56
+ return internal_->last_dispatched_to();
57
+ }
58
+
59
+ auto
60
+ manager_error_context::retry_attempts() const -> std::size_t
61
+ {
62
+ return internal_->retry_attempts();
63
+ }
64
+
65
+ auto
66
+ manager_error_context::retry_reasons() const -> const std::set<retry_reason>&
67
+ {
68
+ return internal_->retry_reasons();
69
+ }
70
+
71
+ auto
72
+ manager_error_context::retried_because_of(couchbase::retry_reason reason) const -> bool
73
+ {
74
+ return internal_->retried_because_of(reason);
75
+ }
76
+
77
+ auto
78
+ manager_error_context::path() const -> const std::string&
79
+ {
80
+ return internal_->path();
81
+ }
82
+
83
+ auto
84
+ manager_error_context::content() const -> const std::string&
85
+ {
86
+ return internal_->content();
87
+ }
88
+
89
+ auto
90
+ manager_error_context::client_context_id() const -> const std::string&
91
+ {
92
+ return internal_->client_context_id();
93
+ }
94
+
95
+ auto
96
+ manager_error_context::http_status() const -> std::uint32_t
97
+ {
98
+ return internal_->http_status();
99
+ }
100
+ } // namespace couchbase
@@ -161,6 +161,7 @@ build_query_request(std::string statement, query_options::built options)
161
161
  options.readonly,
162
162
  options.flex_index,
163
163
  options.preserve_expiry,
164
+ options.use_replica,
164
165
  options.max_parallelism,
165
166
  options.scan_cap,
166
167
  options.scan_wait,
@@ -0,0 +1,130 @@
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
+ #include <couchbase/manager_error_context.hxx>
19
+ #include <utility>
20
+
21
+ #include "core/cluster.hxx"
22
+ #include "core/operations/management/bucket_update.hxx"
23
+ #include "couchbase/bucket_manager.hxx"
24
+
25
+ namespace couchbase
26
+ {
27
+ template<typename Response>
28
+ static manager_error_context
29
+ build_context(Response& resp)
30
+ {
31
+ return manager_error_context(internal_manager_error_context{ resp.ctx.ec,
32
+ resp.ctx.last_dispatched_to,
33
+ resp.ctx.last_dispatched_from,
34
+ resp.ctx.retry_attempts,
35
+ std::move(resp.ctx.retry_reasons),
36
+ std::move(resp.ctx.client_context_id),
37
+ resp.ctx.http_status,
38
+ std::move(resp.ctx.http_body),
39
+ std::move(resp.ctx.path) });
40
+ }
41
+
42
+ static core::operations::management::bucket_update_request
43
+ build_update_bucket_request(couchbase::core::management::cluster::bucket_settings bucket_settings,
44
+ const update_bucket_options::built& options)
45
+ {
46
+ core::operations::management::bucket_update_request request{ std::move(bucket_settings), {}, options.timeout };
47
+ return request;
48
+ }
49
+
50
+ static couchbase::core::management::cluster::bucket_settings
51
+ map_bucket_settings(const couchbase::management::cluster::bucket_settings& bucket)
52
+ {
53
+ couchbase::core::management::cluster::bucket_settings bucket_settings{};
54
+
55
+ bucket_settings.name = bucket.name;
56
+ bucket_settings.ram_quota_mb = bucket.ram_quota_mb;
57
+ bucket_settings.max_expiry = bucket.max_expiry;
58
+ bucket_settings.minimum_durability_level = bucket.minimum_durability_level;
59
+ bucket_settings.num_replicas = bucket.num_replicas;
60
+ bucket_settings.replica_indexes = bucket.replica_indexes;
61
+ bucket_settings.flush_enabled = bucket.flush_enabled;
62
+ switch (bucket.conflict_resolution_type) {
63
+ case management::cluster::bucket_conflict_resolution::unknown:
64
+ bucket_settings.conflict_resolution_type = core::management::cluster::bucket_conflict_resolution::unknown;
65
+ break;
66
+ case management::cluster::bucket_conflict_resolution::timestamp:
67
+ bucket_settings.conflict_resolution_type = core::management::cluster::bucket_conflict_resolution::timestamp;
68
+ break;
69
+ case management::cluster::bucket_conflict_resolution::sequence_number:
70
+ bucket_settings.conflict_resolution_type = core::management::cluster::bucket_conflict_resolution::sequence_number;
71
+ break;
72
+ case management::cluster::bucket_conflict_resolution::custom:
73
+ bucket_settings.conflict_resolution_type = core::management::cluster::bucket_conflict_resolution::custom;
74
+ break;
75
+ }
76
+ switch (bucket.eviction_policy) {
77
+ case management::cluster::bucket_eviction_policy::unknown:
78
+ bucket_settings.eviction_policy = core::management::cluster::bucket_eviction_policy::unknown;
79
+ break;
80
+ case management::cluster::bucket_eviction_policy::full:
81
+ bucket_settings.eviction_policy = core::management::cluster::bucket_eviction_policy::full;
82
+ break;
83
+ case management::cluster::bucket_eviction_policy::value_only:
84
+ bucket_settings.eviction_policy = core::management::cluster::bucket_eviction_policy::value_only;
85
+ break;
86
+ case management::cluster::bucket_eviction_policy::no_eviction:
87
+ bucket_settings.eviction_policy = core::management::cluster::bucket_eviction_policy::no_eviction;
88
+ break;
89
+ case management::cluster::bucket_eviction_policy::not_recently_used:
90
+ bucket_settings.eviction_policy = core::management::cluster::bucket_eviction_policy::not_recently_used;
91
+ break;
92
+ }
93
+ switch (bucket.bucket_type) {
94
+ case management::cluster::bucket_type::unknown:
95
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::unknown;
96
+ break;
97
+ case management::cluster::bucket_type::couchbase:
98
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::couchbase;
99
+ break;
100
+ case management::cluster::bucket_type::memcached:
101
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::memcached;
102
+ break;
103
+ case management::cluster::bucket_type::ephemeral:
104
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::ephemeral;
105
+ break;
106
+ }
107
+ return bucket_settings;
108
+ }
109
+
110
+ void
111
+ bucket_manager::update_bucket(const management::cluster::bucket_settings& bucket_settings,
112
+ const update_bucket_options& options,
113
+ update_bucket_handler&& handler) const
114
+ {
115
+ auto request = build_update_bucket_request(map_bucket_settings(bucket_settings), options.build());
116
+
117
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::bucket_update_response resp) mutable {
118
+ return handler(build_context(resp));
119
+ });
120
+ }
121
+
122
+ auto
123
+ bucket_manager::update_bucket(const management::cluster::bucket_settings& bucket_settings, const update_bucket_options& options) const
124
+ -> std::future<manager_error_context>
125
+ {
126
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
127
+ update_bucket(bucket_settings, options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
128
+ return barrier->get_future();
129
+ }
130
+ } // namespace couchbase