couchbase 3.4.4 → 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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/couchbase/CMakeLists.txt +7 -0
  4. data/ext/couchbase/core/cluster.hxx +7 -0
  5. data/ext/couchbase/core/impl/create_bucket.cxx +3 -0
  6. data/ext/couchbase/core/impl/create_collection.cxx +83 -0
  7. data/ext/couchbase/core/impl/create_scope.cxx +69 -0
  8. data/ext/couchbase/core/impl/drop_collection.cxx +76 -0
  9. data/ext/couchbase/core/impl/drop_scope.cxx +68 -0
  10. data/ext/couchbase/core/impl/get_all_buckets.cxx +19 -4
  11. data/ext/couchbase/core/impl/get_all_scopes.cxx +94 -0
  12. data/ext/couchbase/core/impl/get_bucket.cxx +19 -4
  13. data/ext/couchbase/core/impl/lookup_in_all_replicas.cxx +2 -0
  14. data/ext/couchbase/core/impl/lookup_in_any_replica.cxx +2 -0
  15. data/ext/couchbase/core/impl/lookup_in_replica.cxx +8 -1
  16. data/ext/couchbase/core/impl/update_bucket.cxx +3 -0
  17. data/ext/couchbase/core/impl/update_collection.cxx +83 -0
  18. data/ext/couchbase/core/management/bucket_settings.hxx +8 -5
  19. data/ext/couchbase/core/management/bucket_settings_json.hxx +12 -2
  20. data/ext/couchbase/core/meta/features.hxx +17 -0
  21. data/ext/couchbase/core/operations/document_lookup_in.cxx +8 -1
  22. data/ext/couchbase/core/operations/management/CMakeLists.txt +1 -0
  23. data/ext/couchbase/core/operations/management/bucket_create.cxx +30 -9
  24. data/ext/couchbase/core/operations/management/bucket_update.cxx +27 -6
  25. data/ext/couchbase/core/operations/management/collection_create.cxx +5 -1
  26. data/ext/couchbase/core/operations/management/collection_create.hxx +1 -0
  27. data/ext/couchbase/core/operations/management/collection_update.cxx +87 -0
  28. data/ext/couchbase/core/operations/management/collection_update.hxx +54 -0
  29. data/ext/couchbase/core/operations/management/collections.hxx +1 -0
  30. data/ext/couchbase/core/timeout_defaults.hxx +1 -1
  31. data/ext/couchbase/core/topology/capabilities.hxx +1 -0
  32. data/ext/couchbase/core/topology/capabilities_fmt.hxx +3 -0
  33. data/ext/couchbase/core/topology/collections_manifest.hxx +2 -0
  34. data/ext/couchbase/core/topology/collections_manifest_json.hxx +3 -0
  35. data/ext/couchbase/core/topology/configuration.hxx +5 -0
  36. data/ext/couchbase/core/topology/configuration_json.hxx +2 -0
  37. data/ext/couchbase/couchbase/bucket.hxx +14 -0
  38. data/ext/couchbase/couchbase/collection_manager.hxx +160 -0
  39. data/ext/couchbase/couchbase/create_collection_options.hxx +44 -0
  40. data/ext/couchbase/couchbase/create_scope_options.hxx +41 -0
  41. data/ext/couchbase/couchbase/drop_collection_options.hxx +41 -0
  42. data/ext/couchbase/couchbase/drop_scope_options.hxx +41 -0
  43. data/ext/couchbase/couchbase/get_all_scopes_options.hxx +44 -0
  44. data/ext/couchbase/couchbase/management/bucket_settings.hxx +8 -5
  45. data/ext/couchbase/couchbase/management/collection_spec.hxx +29 -0
  46. data/ext/couchbase/couchbase/management/scope_spec.hxx +29 -0
  47. data/ext/couchbase/couchbase/update_collection_options.hxx +44 -0
  48. data/ext/couchbase/test/test_integration_management.cxx +305 -48
  49. data/ext/couchbase/test/test_integration_subdoc.cxx +81 -22
  50. data/ext/couchbase.cxx +155 -34
  51. data/ext/revisions.rb +3 -3
  52. data/lib/couchbase/collection_options.rb +1 -2
  53. data/lib/couchbase/management/bucket_manager.rb +22 -15
  54. data/lib/couchbase/management/collection_manager.rb +158 -9
  55. data/lib/couchbase/version.rb +1 -1
  56. metadata +23 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3c1e2edfe7f74eb3f3094dd526e7dc1896f3002caca935ddeb76923b593f341
4
- data.tar.gz: b5409f7083156b38aee870037ce0c5d3a14dc7ffe3aa3ac64b5862245b47e4d5
3
+ metadata.gz: 85cf5d55d22898824be380bb1a1da7e8b29e294d06a9c5789964220afcb916f8
4
+ data.tar.gz: c56798cd37877f4b4560d224f7ae31d522c7b84ebf643e6f530e73111bca8347
5
5
  SHA512:
6
- metadata.gz: 16705649dc3954db461a7f8a63ee1168a4b191cacb0744e4e5b5b7b110788491d42fab78611b4898078a0276bbe0d9930352e24b4f95db87ab79ed6b6e8f9101
7
- data.tar.gz: 157af7be99dc745ef7d95ef45490c0025f16ead6abb2f75079188405e82fcec9a64abb681695720e9080fd36b3c17883a56f84bafd06062e56c22ad9286c7ed4
6
+ metadata.gz: d3453198ae619b3ca540fc909688a3132aaf1f2ef47b402eeec7ae63a8110328f4bad6cfec356a218c35a3f1aafc8abf2a51869b2808ec14cc4521064ddb8a41
7
+ data.tar.gz: 05bd481ed690587544062493db78198b07f13728e65df45cdfbb5538c6a3c9f1e25fca5b78e1385d10d88c8a802d146cb363e115f206b679ff4e58bb1cfe0391
data/README.md CHANGED
@@ -23,7 +23,7 @@ The library has been tested with MRI 3.0, 3.1 and 3.2. Supported platforms are L
23
23
  Add this line to your application's Gemfile:
24
24
 
25
25
  ```ruby
26
- gem "couchbase", "3.4.4"
26
+ gem "couchbase", "3.4.5"
27
27
  ```
28
28
 
29
29
  And then execute:
@@ -170,6 +170,7 @@ set(couchbase_cxx_client_FILES
170
170
  core/operations/management/cluster_developer_preview_enable.cxx
171
171
  core/operations/management/collection_create.cxx
172
172
  core/operations/management/collection_drop.cxx
173
+ core/operations/management/collection_update.cxx
173
174
  core/operations/management/collections_manifest_get.cxx
174
175
  core/operations/management/error_utils.cxx
175
176
  core/operations/management/eventing_deploy_function.cxx
@@ -271,7 +272,9 @@ set(couchbase_cxx_client_FILES
271
272
  core/impl/configuration_profiles_registry.cxx
272
273
  core/impl/conjunction_query.cxx
273
274
  core/impl/create_bucket.cxx
275
+ core/impl/create_collection.cxx
274
276
  core/impl/create_query_index.cxx
277
+ core/impl/create_scope.cxx
275
278
  core/impl/date_range.cxx
276
279
  core/impl/date_range_facet.cxx
277
280
  core/impl/date_range_facet_result.cxx
@@ -280,7 +283,9 @@ set(couchbase_cxx_client_FILES
280
283
  core/impl/disjunction_query.cxx
281
284
  core/impl/dns_srv_tracker.cxx
282
285
  core/impl/drop_bucket.cxx
286
+ core/impl/drop_collection.cxx
283
287
  core/impl/drop_query_index.cxx
288
+ core/impl/drop_scope.cxx
284
289
  core/impl/exists.cxx
285
290
  core/impl/expiry.cxx
286
291
  core/impl/fail_fast_retry_strategy.cxx
@@ -293,6 +298,7 @@ set(couchbase_cxx_client_FILES
293
298
  core/impl/get_all_buckets.cxx
294
299
  core/impl/get_all_query_indexes.cxx
295
300
  core/impl/get_all_replicas.cxx
301
+ core/impl/get_all_scopes.cxx
296
302
  core/impl/get_and_lock.cxx
297
303
  core/impl/get_and_touch.cxx
298
304
  core/impl/get_any_replica.cxx
@@ -380,6 +386,7 @@ set(couchbase_cxx_client_FILES
380
386
  core/impl/transaction_op_error_category.cxx
381
387
  core/impl/unlock.cxx
382
388
  core/impl/update_bucket.cxx
389
+ core/impl/update_collection.cxx
383
390
  core/impl/upsert.cxx
384
391
  core/impl/view_error_category.cxx
385
392
  core/impl/watch_query_indexes.cxx
@@ -336,6 +336,13 @@ class cluster : public std::enable_shared_from_this<cluster>
336
336
  template<typename Handler>
337
337
  void do_open(Handler&& handler)
338
338
  {
339
+ // Warn users if idle_http_connection_timeout is too close to server idle timeouts
340
+ if (origin_.options().idle_http_connection_timeout > std::chrono::milliseconds(4'500)) {
341
+ CB_LOG_INFO("[{}]: The SDK may produce trivial warnings due to the idle HTTP connection timeout being set above the idle"
342
+ "timeout of various services",
343
+ id_);
344
+ }
345
+
339
346
  // Warn users if they attempt to use Capella without TLS being enabled.
340
347
  bool has_capella_host = false;
341
348
  {
@@ -59,6 +59,9 @@ map_bucket_settings(const couchbase::management::cluster::bucket_settings& bucke
59
59
  bucket_settings.num_replicas = bucket.num_replicas;
60
60
  bucket_settings.replica_indexes = bucket.replica_indexes;
61
61
  bucket_settings.flush_enabled = bucket.flush_enabled;
62
+ bucket_settings.history_retention_collection_default = bucket.history_retention_collection_default;
63
+ bucket_settings.history_retention_bytes = bucket.history_retention_bytes;
64
+ bucket_settings.history_retention_duration = bucket.history_retention_duration;
62
65
  switch (bucket.conflict_resolution_type) {
63
66
  case management::cluster::bucket_conflict_resolution::unknown:
64
67
  bucket_settings.conflict_resolution_type = core::management::cluster::bucket_conflict_resolution::unknown;
@@ -0,0 +1,83 @@
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
+
20
+ #include "core/cluster.hxx"
21
+ #include "core/operations/management/collection_create.hxx"
22
+ #include "couchbase/collection_manager.hxx"
23
+
24
+ namespace couchbase
25
+ {
26
+ template<typename Response>
27
+ static manager_error_context
28
+ build_context(Response& resp)
29
+ {
30
+ return manager_error_context(internal_manager_error_context{ resp.ctx.ec,
31
+ resp.ctx.last_dispatched_to,
32
+ resp.ctx.last_dispatched_from,
33
+ resp.ctx.retry_attempts,
34
+ std::move(resp.ctx.retry_reasons),
35
+ std::move(resp.ctx.client_context_id),
36
+ resp.ctx.http_status,
37
+ std::move(resp.ctx.http_body),
38
+ std::move(resp.ctx.path) });
39
+ }
40
+
41
+ static core::operations::management::collection_create_request
42
+ build_collection_create_request(std::string bucket_name,
43
+ std::string scope_name,
44
+ std::string collection_name,
45
+ const create_collection_settings& settings,
46
+ const create_collection_options::built& options)
47
+ {
48
+ core::operations::management::collection_create_request request{
49
+ std::move(bucket_name), std::move(scope_name), std::move(collection_name), settings.max_expiry, settings.history, {},
50
+ options.timeout
51
+ };
52
+ return request;
53
+ }
54
+
55
+ void
56
+ collection_manager::create_collection(std::string scope_name,
57
+ std::string collection_name,
58
+ const couchbase::create_collection_settings& settings,
59
+ const couchbase::create_collection_options& options,
60
+ couchbase::create_collection_handler&& handler) const
61
+ {
62
+ auto request =
63
+ build_collection_create_request(bucket_name_, std::move(scope_name), std::move(collection_name), settings, options.build());
64
+
65
+ core_->execute(std::move(request),
66
+ [handler = std::move(handler)](core::operations::management::collection_create_response resp) mutable {
67
+ return handler(build_context(resp));
68
+ });
69
+ }
70
+
71
+ auto
72
+ collection_manager::create_collection(std::string scope_name,
73
+ std::string collection_name,
74
+ const couchbase::create_collection_settings& settings,
75
+ const couchbase::create_collection_options& options) const -> std::future<manager_error_context>
76
+ {
77
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
78
+ create_collection(std::move(scope_name), std::move(collection_name), settings, options, [barrier](auto ctx) mutable {
79
+ barrier->set_value(std::move(ctx));
80
+ });
81
+ return barrier->get_future();
82
+ }
83
+ } // namespace couchbase
@@ -0,0 +1,69 @@
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/scope_create.hxx"
23
+ #include "couchbase/collection_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::scope_create_request
43
+ build_scope_create_request(std::string bucket_name, std::string scope_name, const create_scope_options::built& options)
44
+ {
45
+ core::operations::management::scope_create_request request{ std::move(bucket_name), std::move(scope_name), {}, options.timeout };
46
+ return request;
47
+ }
48
+
49
+ void
50
+ collection_manager::create_scope(std::string scope_name,
51
+ const couchbase::create_scope_options& options,
52
+ couchbase::create_scope_handler&& handler) const
53
+ {
54
+ auto request = build_scope_create_request(bucket_name_, std::move(scope_name), options.build());
55
+
56
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::scope_create_response resp) mutable {
57
+ return handler(build_context(resp));
58
+ });
59
+ }
60
+
61
+ auto
62
+ collection_manager::create_scope(std::string scope_name, const couchbase::create_scope_options& options) const
63
+ -> std::future<manager_error_context>
64
+ {
65
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
66
+ create_scope(std::move(scope_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
67
+ return barrier->get_future();
68
+ }
69
+ } // namespace couchbase
@@ -0,0 +1,76 @@
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
+
20
+ #include "core/cluster.hxx"
21
+ #include "core/operations/management/collection_drop.hxx"
22
+ #include "couchbase/collection_manager.hxx"
23
+
24
+ namespace couchbase
25
+ {
26
+ template<typename Response>
27
+ static manager_error_context
28
+ build_context(Response& resp)
29
+ {
30
+ return manager_error_context(internal_manager_error_context{ resp.ctx.ec,
31
+ resp.ctx.last_dispatched_to,
32
+ resp.ctx.last_dispatched_from,
33
+ resp.ctx.retry_attempts,
34
+ std::move(resp.ctx.retry_reasons),
35
+ std::move(resp.ctx.client_context_id),
36
+ resp.ctx.http_status,
37
+ std::move(resp.ctx.http_body),
38
+ std::move(resp.ctx.path) });
39
+ }
40
+
41
+ static core::operations::management::collection_drop_request
42
+ build_collection_drop_request(std::string bucket_name,
43
+ std::string scope_name,
44
+ std::string collection_name,
45
+ const drop_collection_options::built& options)
46
+ {
47
+ core::operations::management::collection_drop_request request{
48
+ std::move(bucket_name), std::move(scope_name), std::move(collection_name), {}, options.timeout
49
+ };
50
+ return request;
51
+ }
52
+
53
+ void
54
+ collection_manager::drop_collection(std::string scope_name,
55
+ std::string collection_name,
56
+ const couchbase::drop_collection_options& options,
57
+ couchbase::drop_collection_handler&& handler) const
58
+ {
59
+ auto request = build_collection_drop_request(bucket_name_, std::move(scope_name), std::move(collection_name), options.build());
60
+
61
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::collection_drop_response resp) mutable {
62
+ return handler(build_context(resp));
63
+ });
64
+ }
65
+
66
+ auto
67
+ collection_manager::drop_collection(std::string scope_name,
68
+ std::string collection_name,
69
+ const couchbase::drop_collection_options& options) const -> std::future<manager_error_context>
70
+ {
71
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
72
+ drop_collection(
73
+ std::move(scope_name), std::move(collection_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
74
+ return barrier->get_future();
75
+ }
76
+ } // namespace couchbase
@@ -0,0 +1,68 @@
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
+
20
+ #include "core/cluster.hxx"
21
+ #include "core/operations/management/scope_drop.hxx"
22
+ #include "couchbase/collection_manager.hxx"
23
+
24
+ namespace couchbase
25
+ {
26
+ template<typename Response>
27
+ static manager_error_context
28
+ build_context(Response& resp)
29
+ {
30
+ return manager_error_context(internal_manager_error_context{ resp.ctx.ec,
31
+ resp.ctx.last_dispatched_to,
32
+ resp.ctx.last_dispatched_from,
33
+ resp.ctx.retry_attempts,
34
+ std::move(resp.ctx.retry_reasons),
35
+ std::move(resp.ctx.client_context_id),
36
+ resp.ctx.http_status,
37
+ std::move(resp.ctx.http_body),
38
+ std::move(resp.ctx.path) });
39
+ }
40
+
41
+ static core::operations::management::scope_drop_request
42
+ build_drop_scope_request(std::string bucket_name, std::string scope_name, const drop_scope_options::built& options)
43
+ {
44
+ core::operations::management::scope_drop_request request{ std::move(bucket_name), std::move(scope_name), {}, options.timeout };
45
+ return request;
46
+ }
47
+
48
+ void
49
+ collection_manager::drop_scope(std::string scope_name,
50
+ const couchbase::drop_scope_options& options,
51
+ couchbase::drop_scope_handler&& handler) const
52
+ {
53
+ auto request = build_drop_scope_request(bucket_name_, std::move(scope_name), options.build());
54
+
55
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::scope_drop_response resp) mutable {
56
+ return handler(build_context(resp));
57
+ });
58
+ }
59
+
60
+ auto
61
+ collection_manager::drop_scope(std::string scope_name, const couchbase::drop_scope_options& options) const
62
+ -> std::future<manager_error_context>
63
+ {
64
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
65
+ drop_scope(std::move(scope_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
66
+ return barrier->get_future();
67
+ }
68
+ } // namespace couchbase
@@ -52,11 +52,26 @@ map_bucket_settings(const couchbase::core::management::cluster::bucket_settings&
52
52
  couchbase::management::cluster::bucket_settings bucket_settings{};
53
53
  bucket_settings.name = bucket.name;
54
54
  bucket_settings.ram_quota_mb = bucket.ram_quota_mb;
55
- bucket_settings.max_expiry = bucket.max_expiry;
56
55
  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;
56
+ bucket_settings.history_retention_collection_default = bucket.history_retention_collection_default;
57
+ if (bucket.max_expiry.has_value()) {
58
+ bucket_settings.max_expiry = bucket.max_expiry.value();
59
+ }
60
+ if (bucket.num_replicas.has_value()) {
61
+ bucket_settings.num_replicas = bucket.num_replicas.value();
62
+ }
63
+ if (bucket.replica_indexes.has_value()) {
64
+ bucket_settings.replica_indexes = bucket.replica_indexes.value();
65
+ }
66
+ if (bucket.flush_enabled.has_value()) {
67
+ bucket_settings.flush_enabled = bucket.flush_enabled.value();
68
+ }
69
+ if (bucket.history_retention_bytes.has_value()) {
70
+ bucket_settings.history_retention_bytes = bucket.history_retention_bytes.value();
71
+ }
72
+ if (bucket.history_retention_duration.has_value()) {
73
+ bucket_settings.history_retention_duration = bucket.history_retention_duration.value();
74
+ }
60
75
  switch (bucket.conflict_resolution_type) {
61
76
  case core::management::cluster::bucket_conflict_resolution::unknown:
62
77
  bucket_settings.conflict_resolution_type = management::cluster::bucket_conflict_resolution::unknown;
@@ -0,0 +1,94 @@
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
+
20
+ #include "core/cluster.hxx"
21
+ #include "core/operations/management/scope_get_all.hxx"
22
+ #include "couchbase/collection_manager.hxx"
23
+
24
+ namespace couchbase
25
+ {
26
+ template<typename Response>
27
+ static manager_error_context
28
+ build_context(Response& resp)
29
+ {
30
+ return manager_error_context(internal_manager_error_context{ resp.ctx.ec,
31
+ resp.ctx.last_dispatched_to,
32
+ resp.ctx.last_dispatched_from,
33
+ resp.ctx.retry_attempts,
34
+ std::move(resp.ctx.retry_reasons),
35
+ std::move(resp.ctx.client_context_id),
36
+ resp.ctx.http_status,
37
+ std::move(resp.ctx.http_body),
38
+ std::move(resp.ctx.path) });
39
+ }
40
+
41
+ static core::operations::management::scope_get_all_request
42
+ build_get_all_scopes_request(std::string bucket_name, const get_all_scopes_options::built& options)
43
+ {
44
+ core::operations::management::scope_get_all_request request{ std::move(bucket_name), {}, options.timeout };
45
+ return request;
46
+ }
47
+
48
+ static management::bucket::collection_spec
49
+ map_collection(std::string scope_name, const core::topology::collections_manifest::collection& collection)
50
+ {
51
+ management::bucket::collection_spec spec{};
52
+ spec.name = collection.name;
53
+ spec.scope_name = std::move(scope_name);
54
+ spec.max_expiry = collection.max_expiry;
55
+ spec.history = collection.history;
56
+ return spec;
57
+ }
58
+
59
+ static std::vector<couchbase::management::bucket::scope_spec>
60
+ map_scope_specs(core::topology::collections_manifest& manifest)
61
+ {
62
+ std::vector<couchbase::management::bucket::scope_spec> scope_specs{};
63
+ for (const auto& scope : manifest.scopes) {
64
+ couchbase::management::bucket::scope_spec converted_scope{};
65
+ converted_scope.name = scope.name;
66
+ for (const auto& collection : scope.collections) {
67
+ auto collection_spec = map_collection(scope.name, collection);
68
+ converted_scope.collections.emplace_back(collection_spec);
69
+ }
70
+ scope_specs.emplace_back(converted_scope);
71
+ }
72
+ return scope_specs;
73
+ }
74
+
75
+ void
76
+ collection_manager::get_all_scopes(const get_all_scopes_options& options, get_all_scopes_handler&& handler) const
77
+ {
78
+ auto request = build_get_all_scopes_request(bucket_name_, options.build());
79
+
80
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::scope_get_all_response resp) mutable {
81
+ return handler(build_context(resp), map_scope_specs(resp.manifest));
82
+ });
83
+ }
84
+
85
+ auto
86
+ collection_manager::get_all_scopes(const couchbase::get_all_scopes_options& options) const
87
+ -> std::future<std::pair<manager_error_context, std::vector<management::bucket::scope_spec>>>
88
+ {
89
+ auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<management::bucket::scope_spec>>>>();
90
+ get_all_scopes(options,
91
+ [barrier](auto ctx, auto result) mutable { barrier->set_value(std::make_pair(std::move(ctx), std::move(result))); });
92
+ return barrier->get_future();
93
+ }
94
+ } // namespace couchbase
@@ -52,11 +52,26 @@ map_bucket_settings(const couchbase::core::management::cluster::bucket_settings&
52
52
  couchbase::management::cluster::bucket_settings bucket_settings{};
53
53
  bucket_settings.name = bucket.name;
54
54
  bucket_settings.ram_quota_mb = bucket.ram_quota_mb;
55
- bucket_settings.max_expiry = bucket.max_expiry;
56
55
  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;
56
+ bucket_settings.history_retention_collection_default = bucket.history_retention_collection_default;
57
+ if (bucket.max_expiry.has_value()) {
58
+ bucket_settings.max_expiry = bucket.max_expiry.value();
59
+ }
60
+ if (bucket.num_replicas.has_value()) {
61
+ bucket_settings.num_replicas = bucket.num_replicas.value();
62
+ }
63
+ if (bucket.replica_indexes.has_value()) {
64
+ bucket_settings.replica_indexes = bucket.replica_indexes.value();
65
+ }
66
+ if (bucket.flush_enabled.has_value()) {
67
+ bucket_settings.flush_enabled = bucket.flush_enabled.value();
68
+ }
69
+ if (bucket.history_retention_bytes.has_value()) {
70
+ bucket_settings.history_retention_bytes = bucket.history_retention_bytes.value();
71
+ }
72
+ if (bucket.history_retention_duration.has_value()) {
73
+ bucket_settings.history_retention_duration = bucket.history_retention_duration.value();
74
+ }
60
75
  switch (bucket.conflict_resolution_type) {
61
76
  case core::management::cluster::bucket_conflict_resolution::unknown:
62
77
  bucket_settings.conflict_resolution_type = management::cluster::bucket_conflict_resolution::unknown;
@@ -113,6 +113,7 @@ initiate_lookup_in_all_replicas_operation(std::shared_ptr<cluster> core,
113
113
  lookup_in_entry.value = field.value;
114
114
  lookup_in_entry.exists = field.exists;
115
115
  lookup_in_entry.original_index = field.original_index;
116
+ lookup_in_entry.ec = field.ec;
116
117
  entries.emplace_back(lookup_in_entry);
117
118
  }
118
119
  ctx->result_.emplace_back(lookup_in_replica_result{ resp.cas, entries, resp.deleted, true /* replica */ });
@@ -155,6 +156,7 @@ initiate_lookup_in_all_replicas_operation(std::shared_ptr<cluster> core,
155
156
  lookup_in_entry.value = field.value;
156
157
  lookup_in_entry.exists = field.exists;
157
158
  lookup_in_entry.original_index = field.original_index;
159
+ lookup_in_entry.ec = field.ec;
158
160
  entries.emplace_back(lookup_in_entry);
159
161
  }
160
162
  ctx->result_.emplace_back(lookup_in_replica_result{ resp.cas, entries, resp.deleted, false /* active */ });
@@ -118,6 +118,7 @@ initiate_lookup_in_any_replica_operation(std::shared_ptr<cluster> core,
118
118
  entry.original_index = field.original_index;
119
119
  entry.exists = field.exists;
120
120
  entry.value = field.value;
121
+ entry.ec = field.ec;
121
122
  entries.emplace_back(entry);
122
123
  }
123
124
  return local_handler(std::move(resp.ctx),
@@ -156,6 +157,7 @@ initiate_lookup_in_any_replica_operation(std::shared_ptr<cluster> core,
156
157
  entry.original_index = field.original_index;
157
158
  entry.exists = field.exists;
158
159
  entry.value = field.value;
160
+ entry.ec = field.ec;
159
161
  entries.emplace_back(entry);
160
162
  }
161
163
  return local_handler(std::move(resp.ctx),
@@ -70,6 +70,9 @@ lookup_in_replica_request::make_response(key_value_error_context&& ctx, const en
70
70
  fields[i].status = res_entry.status;
71
71
  fields[i].ec =
72
72
  protocol::map_status_code(protocol::client_opcode::subdoc_multi_mutation, static_cast<std::uint16_t>(res_entry.status));
73
+ if (fields[i].opcode == protocol::subdoc_opcode::exists && fields[i].ec == errc::key_value::path_not_found) {
74
+ fields[i].ec.clear();
75
+ }
73
76
  if (!fields[i].ec && !ctx.ec()) {
74
77
  ec = fields[i].ec;
75
78
  }
@@ -79,7 +82,11 @@ lookup_in_replica_request::make_response(key_value_error_context&& ctx, const en
79
82
  }
80
83
  fields[i].exists =
81
84
  res_entry.status == key_value_status_code::success || res_entry.status == key_value_status_code::subdoc_success_deleted;
82
- fields[i].value = utils::to_binary(res_entry.value);
85
+ if (fields[i].opcode == protocol::subdoc_opcode::exists && !fields[i].ec) {
86
+ fields[i].value = utils::json::generate_binary(fields[i].exists);
87
+ } else {
88
+ fields[i].value = utils::to_binary(res_entry.value);
89
+ }
83
90
  }
84
91
  if (!ec) {
85
92
  cas = encoded.cas();
@@ -59,6 +59,9 @@ map_bucket_settings(const couchbase::management::cluster::bucket_settings& bucke
59
59
  bucket_settings.num_replicas = bucket.num_replicas;
60
60
  bucket_settings.replica_indexes = bucket.replica_indexes;
61
61
  bucket_settings.flush_enabled = bucket.flush_enabled;
62
+ bucket_settings.history_retention_collection_default = bucket.history_retention_collection_default;
63
+ bucket_settings.history_retention_bytes = bucket.history_retention_bytes;
64
+ bucket_settings.history_retention_duration = bucket.history_retention_duration;
62
65
  switch (bucket.conflict_resolution_type) {
63
66
  case management::cluster::bucket_conflict_resolution::unknown:
64
67
  bucket_settings.conflict_resolution_type = core::management::cluster::bucket_conflict_resolution::unknown;