couchbase 4.2.5-dev.3 → 4.2.6-dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. package/README.md +81 -9
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +9 -1
  3. package/deps/couchbase-cxx-client/bin/api.rb +234 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +18 -135
  5. package/deps/couchbase-cxx-client/bin/init-cluster +17 -139
  6. package/deps/couchbase-cxx-client/bin/load-sample-buckets +54 -0
  7. package/deps/couchbase-cxx-client/core/cluster.hxx +33 -12
  8. package/deps/couchbase-cxx-client/core/cluster_options.hxx +3 -0
  9. package/deps/couchbase-cxx-client/core/crud_component.cxx +51 -22
  10. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +115 -50
  11. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +6 -0
  12. package/deps/couchbase-cxx-client/core/impl/create_bucket.cxx +155 -0
  13. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +172 -59
  14. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +2 -1
  15. package/deps/couchbase-cxx-client/core/impl/drop_bucket.cxx +66 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +138 -59
  17. package/deps/couchbase-cxx-client/core/impl/flush_bucket.cxx +66 -0
  18. package/deps/couchbase-cxx-client/core/impl/get_all_buckets.cxx +163 -0
  19. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +67 -37
  20. package/deps/couchbase-cxx-client/core/impl/get_bucket.cxx +153 -0
  21. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.cxx +113 -0
  22. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.hxx +60 -0
  23. package/deps/couchbase-cxx-client/core/impl/key_value_error_category.cxx +2 -4
  24. package/deps/couchbase-cxx-client/core/impl/manager_error_context.cxx +100 -0
  25. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  26. package/deps/couchbase-cxx-client/core/impl/update_bucket.cxx +130 -0
  27. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +53 -29
  28. package/deps/couchbase-cxx-client/core/io/dns_client.cxx +71 -38
  29. package/deps/couchbase-cxx-client/core/io/dns_config.cxx +5 -4
  30. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +5 -6
  31. package/deps/couchbase-cxx-client/core/meta/features.hxx +6 -0
  32. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  34. package/deps/couchbase-cxx-client/core/origin.cxx +270 -0
  35. package/deps/couchbase-cxx-client/core/origin.hxx +2 -0
  36. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -2
  37. package/deps/couchbase-cxx-client/core/range_scan_options.cxx +3 -27
  38. package/deps/couchbase-cxx-client/core/range_scan_options.hxx +13 -17
  39. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +367 -170
  40. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +13 -2
  41. package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +5 -3
  42. package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -19
  43. package/deps/couchbase-cxx-client/core/scan_result.cxx +19 -5
  44. package/deps/couchbase-cxx-client/core/scan_result.hxx +5 -2
  45. package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +2 -3
  46. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +1 -0
  47. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/topology/collections_manifest_fmt.hxx +1 -1
  49. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +5 -0
  50. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +4 -0
  52. package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +19 -2
  53. package/deps/couchbase-cxx-client/couchbase/bucket_manager.hxx +135 -0
  54. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +0 -30
  55. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +14 -0
  56. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +7 -48
  57. package/deps/couchbase-cxx-client/couchbase/create_bucket_options.hxx +41 -0
  58. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +0 -29
  59. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +0 -33
  60. package/deps/couchbase-cxx-client/couchbase/drop_bucket_options.hxx +41 -0
  61. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +0 -30
  62. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +0 -31
  63. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -2
  64. package/deps/couchbase-cxx-client/couchbase/flush_bucket_options.hxx +41 -0
  65. package/deps/couchbase-cxx-client/couchbase/get_all_buckets_options.hxx +44 -0
  66. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +0 -30
  67. package/deps/couchbase-cxx-client/couchbase/get_bucket_options.hxx +43 -0
  68. package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +116 -0
  69. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +29 -53
  70. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +16 -83
  71. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +18 -0
  72. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +15 -0
  73. package/deps/couchbase-cxx-client/couchbase/update_bucket_options.hxx +41 -0
  74. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +0 -31
  75. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +1 -0
  76. package/deps/couchbase-cxx-client/docs/cbc-get.md +1 -0
  77. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +1 -0
  78. package/deps/couchbase-cxx-client/docs/cbc-query.md +1 -0
  79. package/deps/couchbase-cxx-client/docs/cbc.md +10 -0
  80. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  81. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +6 -0
  82. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +5 -0
  83. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +137 -1
  84. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +709 -266
  85. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +19 -7
  86. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +351 -112
  87. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +10 -1
  88. package/deps/couchbase-cxx-client/test/test_transaction_public_async_api.cxx +13 -12
  89. package/deps/couchbase-cxx-client/test/test_transaction_public_blocking_api.cxx +27 -21
  90. package/deps/couchbase-cxx-client/test/test_unit_query.cxx +75 -0
  91. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +5 -0
  92. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +29 -10
  93. package/deps/couchbase-cxx-client/test/utils/wait_until.hxx +3 -1
  94. package/deps/couchbase-cxx-client/tools/utils.cxx +4 -1
  95. package/dist/binding.d.ts +21 -16
  96. package/dist/binding.js +1 -4
  97. package/dist/bindingutilities.d.ts +6 -1
  98. package/dist/bindingutilities.js +36 -1
  99. package/dist/collection.d.ts +65 -3
  100. package/dist/collection.js +107 -0
  101. package/dist/crudoptypes.d.ts +34 -0
  102. package/dist/crudoptypes.js +18 -1
  103. package/dist/queryexecutor.js +1 -0
  104. package/dist/querytypes.d.ts +7 -0
  105. package/dist/rangeScan.d.ts +107 -0
  106. package/dist/rangeScan.js +91 -0
  107. package/dist/streamablepromises.d.ts +6 -0
  108. package/dist/streamablepromises.js +25 -1
  109. package/package.json +13 -14
  110. package/scripts/createPlatformPackages.js +1 -4
  111. package/src/addondata.hpp +1 -0
  112. package/src/binding.cpp +5 -2
  113. package/src/connection.cpp +108 -2
  114. package/src/connection.hpp +1 -0
  115. package/src/constants.cpp +2 -12
  116. package/src/jstocbpp_autogen.hpp +49 -22
  117. package/src/jstocbpp_basic.hpp +2 -8
  118. package/src/mutationtoken.cpp +13 -0
  119. package/src/scan_iterator.cpp +90 -0
  120. package/src/scan_iterator.hpp +30 -0
  121. package/tools/gen-bindings-json.py +9 -8
  122. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +0 -93
@@ -20,44 +20,116 @@
20
20
 
21
21
  #include "core/cluster.hxx"
22
22
  #include "core/operations/management/query_index_build.hxx"
23
- #include "core/operations/management/query_index_get_all_deferred.hxx"
24
- #include "core/utils/json.hxx"
23
+ #include "core/operations/management/query_index_build_deferred.hxx"
25
24
 
26
- namespace couchbase::core::impl
25
+ namespace couchbase
27
26
  {
28
27
  template<typename Response>
29
28
  static manager_error_context
30
29
  build_context(Response& resp)
31
30
  {
32
- return { resp.ctx.ec,
33
- resp.ctx.last_dispatched_to,
34
- resp.ctx.last_dispatched_from,
35
- resp.ctx.retry_attempts,
36
- std::move(resp.ctx.retry_reasons),
37
- std::move(resp.ctx.client_context_id),
38
- resp.ctx.http_status,
39
- std::move(resp.ctx.http_body),
40
- std::move(resp.ctx.path) };
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) });
41
40
  }
41
+
42
+ static core::operations::management::query_index_build_request
43
+ build_build_index_request(std::string bucket_name,
44
+ core::operations::management::query_index_get_all_deferred_response list_resp,
45
+ const build_query_index_options::built& options)
46
+ {
47
+ core::operations::management::query_index_build_request request{
48
+ std::move(bucket_name), {}, {}, {}, std::move(list_resp.index_names), {}, options.timeout
49
+ };
50
+ return request;
51
+ }
52
+
53
+ static core::operations::management::query_index_get_all_deferred_request
54
+ build_get_all_request(std::string bucket_name, const build_query_index_options::built& options)
55
+ {
56
+ core::operations::management::query_index_get_all_deferred_request request{ std::move(bucket_name), {}, {}, {}, {}, options.timeout };
57
+ return request;
58
+ }
59
+
60
+ static core::operations::management::query_index_build_request
61
+ build_build_index_request(std::string bucket_name,
62
+ std::string scope_name,
63
+ std::string collection_name,
64
+ core::operations::management::query_index_get_all_deferred_response list_resp,
65
+ const build_query_index_options::built& options)
66
+ {
67
+ core::operations::management::query_index_build_request request{ "",
68
+ "",
69
+ std::move(collection_name),
70
+ core::query_context{ std::move(bucket_name), std::move(scope_name) },
71
+ std::move(list_resp.index_names),
72
+ {},
73
+ options.timeout };
74
+ return request;
75
+ }
76
+
77
+ static core::operations::management::query_index_get_all_deferred_request
78
+ build_get_all_request(std::string bucket_name,
79
+ std::string scope_name,
80
+ std::string collection_name,
81
+ const build_query_index_options::built& options)
82
+ {
83
+ core::operations::management::query_index_get_all_deferred_request request{
84
+ "", "", std::move(collection_name), core::query_context{ std::move(bucket_name), std::move(scope_name) }, {}, options.timeout
85
+ };
86
+ return request;
87
+ }
88
+
42
89
  void
43
- initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> core,
44
- std::string bucket_name,
45
- build_query_index_options::built options,
46
- query_context query_ctx,
47
- std::string collection_name,
48
- build_deferred_query_indexes_handler&& handler)
90
+ query_index_manager::build_deferred_indexes(std::string bucket_name,
91
+ const couchbase::build_query_index_options& options,
92
+ couchbase::build_deferred_query_indexes_handler&& handler) const
93
+ {
94
+
95
+ auto get_all_request = build_get_all_request(bucket_name, options.build());
96
+ core_->execute(std::move(get_all_request),
97
+ [handler = std::move(handler), this, bucket_name, options](
98
+ core::operations::management::query_index_get_all_deferred_response resp1) mutable {
99
+ auto list_resp = std::move(resp1);
100
+ if (list_resp.ctx.ec) {
101
+ return handler(build_context(list_resp));
102
+ }
103
+ if (list_resp.index_names.empty()) {
104
+ return handler(build_context(list_resp));
105
+ }
106
+ auto build_request = build_build_index_request(std::move(bucket_name), list_resp, options.build());
107
+ core_->execute(
108
+ std::move(build_request),
109
+ [handler = std::move(handler)](core::operations::management::query_index_build_response resp2) mutable {
110
+ auto build_resp = std::move(resp2);
111
+ return handler(build_context(build_resp));
112
+ });
113
+ });
114
+ }
115
+
116
+ auto
117
+ query_index_manager::build_deferred_indexes(std::string bucket_name, const couchbase::build_query_index_options& options) const
118
+ -> std::future<manager_error_context>
49
119
  {
50
- core->execute(
51
- operations::management::query_index_get_all_deferred_request{
52
- bucket_name,
53
- "",
54
- collection_name,
55
- query_ctx,
56
- {},
57
- options.timeout,
58
- },
59
- [core, bucket_name, collection_name, options = std::move(options), query_ctx, handler = std::move(handler)](
60
- operations::management::query_index_get_all_deferred_response resp1) mutable {
120
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
121
+ build_deferred_indexes(std::move(bucket_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
122
+ return barrier->get_future();
123
+ }
124
+
125
+ void
126
+ collection_query_index_manager::build_deferred_indexes(const build_query_index_options& options,
127
+ build_deferred_query_indexes_handler&& handler) const
128
+ {
129
+ auto get_all_request = build_get_all_request(bucket_name_, scope_name_, collection_name_, options.build());
130
+ core_->execute(
131
+ std::move(get_all_request),
132
+ [handler = std::move(handler), this, options](core::operations::management::query_index_get_all_deferred_response resp1) mutable {
61
133
  auto list_resp = std::move(resp1);
62
134
  if (list_resp.ctx.ec) {
63
135
  return handler(build_context(list_resp));
@@ -65,28 +137,21 @@ initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> core,
65
137
  if (list_resp.index_names.empty()) {
66
138
  return handler(build_context(list_resp));
67
139
  }
68
- core->execute(
69
- operations::management::query_index_build_request{
70
- std::move(bucket_name),
71
- "",
72
- collection_name,
73
- query_ctx,
74
- std::move(list_resp.index_names),
75
- {},
76
- options.timeout,
77
- },
78
- [handler = std::move(handler)](operations::management::query_index_build_response resp2) {
79
- auto build_resp = std::move(resp2);
80
- return handler(build_context(build_resp));
81
- });
140
+ auto build_request = build_build_index_request(bucket_name_, scope_name_, collection_name_, list_resp, options.build());
141
+ core_->execute(std::move(build_request),
142
+ [handler = std::move(handler)](core::operations::management::query_index_build_response resp2) mutable {
143
+ auto build_resp = std::move(resp2);
144
+ return handler(build_context(build_resp));
145
+ });
82
146
  });
83
147
  }
84
- void
85
- initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> core,
86
- std::string bucket_name,
87
- build_query_index_options::built options,
88
- build_deferred_query_indexes_handler&& handler)
148
+
149
+ auto
150
+ collection_query_index_manager::build_deferred_indexes(const couchbase::build_query_index_options& options) const
151
+ -> std::future<manager_error_context>
89
152
  {
90
- return initiate_build_deferred_indexes(core, std::move(bucket_name), options, {}, "", std::move(handler));
153
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
154
+ build_deferred_indexes(options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
155
+ return barrier->get_future();
91
156
  }
92
- } // namespace couchbase::core::impl
157
+ } // namespace couchbase
@@ -82,6 +82,9 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
82
82
  if (opts.security.trust_certificate.has_value()) {
83
83
  user_options.trust_certificate = opts.security.trust_certificate.value();
84
84
  }
85
+ if (opts.security.trust_certificate_value.has_value()) {
86
+ user_options.trust_certificate_value = opts.security.trust_certificate_value.value();
87
+ }
85
88
  switch (opts.security.tls_verify) {
86
89
  case couchbase::tls_verify_mode::none:
87
90
  user_options.tls_verify = core::tls_verify_mode::none;
@@ -91,6 +94,8 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
91
94
  break;
92
95
  }
93
96
  user_options.disable_mozilla_ca_certificates = opts.security.disable_mozilla_ca_certificates;
97
+ user_options.tls_disable_deprecated_protocols = opts.security.disable_deprecated_protocols;
98
+ user_options.tls_disable_v1_2 = opts.security.disable_tls_v1_2;
94
99
  }
95
100
 
96
101
  if (opts.dns.nameserver) {
@@ -103,6 +108,7 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
103
108
  user_options.enable_mutation_tokens = opts.behavior.enable_mutation_tokens;
104
109
  user_options.enable_unordered_execution = opts.behavior.enable_unordered_execution;
105
110
  user_options.user_agent_extra = opts.behavior.user_agent_extra;
111
+ user_options.network = opts.behavior.network;
106
112
 
107
113
  user_options.enable_tcp_keep_alive = opts.network.enable_tcp_keep_alive;
108
114
  user_options.tcp_keep_alive_interval = opts.network.tcp_keep_alive_interval;
@@ -0,0 +1,155 @@
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 "couchbase/bucket_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::bucket_create_request
42
+ build_create_bucket_request(couchbase::core::management::cluster::bucket_settings bucket_settings,
43
+ const create_bucket_options::built& options)
44
+ {
45
+ core::operations::management::bucket_create_request request{ std::move(bucket_settings), {}, options.timeout };
46
+ return request;
47
+ }
48
+
49
+ static couchbase::core::management::cluster::bucket_settings
50
+ map_bucket_settings(const couchbase::management::cluster::bucket_settings& bucket)
51
+ {
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.compression_mode) {
94
+ case management::cluster::bucket_compression::unknown:
95
+ bucket_settings.compression_mode = core::management::cluster::bucket_compression::unknown;
96
+ break;
97
+ case management::cluster::bucket_compression::active:
98
+ bucket_settings.compression_mode = core::management::cluster::bucket_compression::active;
99
+ break;
100
+ case management::cluster::bucket_compression::passive:
101
+ bucket_settings.compression_mode = core::management::cluster::bucket_compression::passive;
102
+ break;
103
+ case management::cluster::bucket_compression::off:
104
+ bucket_settings.compression_mode = core::management::cluster::bucket_compression::off;
105
+ break;
106
+ }
107
+ switch (bucket.bucket_type) {
108
+ case management::cluster::bucket_type::unknown:
109
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::unknown;
110
+ break;
111
+ case management::cluster::bucket_type::couchbase:
112
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::couchbase;
113
+ break;
114
+ case management::cluster::bucket_type::memcached:
115
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::memcached;
116
+ break;
117
+ case management::cluster::bucket_type::ephemeral:
118
+ bucket_settings.bucket_type = core::management::cluster::bucket_type::ephemeral;
119
+ break;
120
+ }
121
+ switch (bucket.storage_backend) {
122
+ case management::cluster::bucket_storage_backend::unknown:
123
+ bucket_settings.storage_backend = core::management::cluster::bucket_storage_backend::unknown;
124
+ break;
125
+ case management::cluster::bucket_storage_backend::magma:
126
+ bucket_settings.storage_backend = core::management::cluster::bucket_storage_backend::magma;
127
+ break;
128
+ case management::cluster::bucket_storage_backend::couchstore:
129
+ bucket_settings.storage_backend = core::management::cluster::bucket_storage_backend::couchstore;
130
+ break;
131
+ }
132
+ return bucket_settings;
133
+ }
134
+
135
+ void
136
+ bucket_manager::create_bucket(const management::cluster::bucket_settings& bucket_settings,
137
+ const create_bucket_options& options,
138
+ create_bucket_handler&& handler) const
139
+ {
140
+ auto request = build_create_bucket_request(map_bucket_settings(bucket_settings), options.build());
141
+
142
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::bucket_create_response resp) mutable {
143
+ return handler(build_context(resp));
144
+ });
145
+ }
146
+
147
+ auto
148
+ bucket_manager::create_bucket(const management::cluster::bucket_settings& bucket_settings, const create_bucket_options& options) const
149
+ -> std::future<manager_error_context>
150
+ {
151
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
152
+ create_bucket(bucket_settings, options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
153
+ return barrier->get_future();
154
+ }
155
+ } // namespace couchbase
@@ -21,41 +21,36 @@
21
21
  #include "core/cluster.hxx"
22
22
  #include "core/operations/management/query_index_create.hxx"
23
23
 
24
- namespace couchbase::core::impl
24
+ namespace couchbase
25
25
  {
26
26
  template<typename Response>
27
27
  static manager_error_context
28
28
  build_context(Response& resp)
29
29
  {
30
- return { 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) };
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
39
  }
40
40
 
41
- void
42
- initiate_create_query_index(std::shared_ptr<couchbase::core::cluster> core,
43
- std::string bucket_name,
44
- std::string index_name,
45
- std::vector<std::string> fields,
46
- couchbase::create_query_index_options::built options,
47
- query_context query_ctx,
48
- std::string collection_name,
49
- create_query_index_handler&& handler)
41
+ static core::operations::management::query_index_create_request
42
+ build_create_index_request(std::string bucket_name,
43
+ std::string index_name,
44
+ std::vector<std::string> fields,
45
+ create_query_index_options::built options)
50
46
  {
51
- core->execute(
52
- operations::management::query_index_create_request{
53
- bucket_name,
47
+ core::operations::management::query_index_create_request request{
48
+ std::move(bucket_name),
49
+ "",
54
50
  "",
55
- collection_name,
56
- index_name,
57
- fields,
58
- query_ctx,
51
+ std::move(index_name),
52
+ std::move(fields),
53
+ {},
59
54
  false,
60
55
  options.ignore_if_exists,
61
56
  options.condition,
@@ -63,39 +58,70 @@ initiate_create_query_index(std::shared_ptr<couchbase::core::cluster> core,
63
58
  options.num_replicas,
64
59
  {},
65
60
  options.timeout,
66
- },
67
- [core, bucket_name, options = std::move(options), handler = std::move(handler)](
68
- operations::management::query_index_create_response resp) { handler(build_context(resp)); });
61
+ };
62
+ return request;
69
63
  }
70
64
 
71
- void
72
- initiate_create_query_index(std::shared_ptr<couchbase::core::cluster> core,
73
- std::string bucket_name,
74
- std::string index_name,
75
- std::vector<std::string> fields,
76
- couchbase::create_query_index_options::built options,
77
- create_query_index_handler&& handler)
65
+ static core::operations::management::query_index_create_request
66
+ build_create_primary_index_request(std::string bucket_name, create_primary_query_index_options::built options)
78
67
  {
79
- initiate_create_query_index(
80
- core, std::move(bucket_name), std::move(index_name), std::move(fields), options, {}, "", std::move(handler));
68
+ core::operations::management::query_index_create_request request{
69
+ std::move(bucket_name),
70
+ "",
71
+ "",
72
+ options.index_name.value_or(""),
73
+ {},
74
+ {},
75
+ true,
76
+ options.ignore_if_exists,
77
+ {},
78
+ options.deferred,
79
+ options.num_replicas,
80
+ {},
81
+ options.timeout,
82
+ };
83
+ return request;
81
84
  }
82
85
 
83
- void
84
- initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
85
- std::string bucket_name,
86
- couchbase::create_primary_query_index_options::built options,
87
- query_context query_ctx,
88
- std::string collection_name,
89
- create_primary_query_index_handler&& handler)
86
+ static core::operations::management::query_index_create_request
87
+ build_create_index_request(std::string bucket_name,
88
+ std::string scope_name,
89
+ std::string collection_name,
90
+ std::string index_name,
91
+ std::vector<std::string> fields,
92
+ create_query_index_options::built options)
93
+ {
94
+ core::operations::management::query_index_create_request request{
95
+ "",
96
+ "",
97
+ std::move(collection_name),
98
+ std::move(index_name),
99
+ std::move(fields),
100
+ core::query_context(std::move(bucket_name), std::move(scope_name)),
101
+ false,
102
+ options.ignore_if_exists,
103
+ options.condition,
104
+ options.deferred,
105
+ options.num_replicas,
106
+ {},
107
+ options.timeout,
108
+ };
109
+ return request;
110
+ }
111
+
112
+ static core::operations::management::query_index_create_request
113
+ build_create_primary_index_request(std::string bucket_name,
114
+ std::string scope_name,
115
+ std::string collection_name,
116
+ create_primary_query_index_options::built options)
90
117
  {
91
- core->execute(
92
- operations::management::query_index_create_request{
93
- bucket_name,
118
+ core::operations::management::query_index_create_request request{
94
119
  "",
95
- collection_name,
120
+ "",
121
+ std::move(collection_name),
96
122
  options.index_name.value_or(""),
97
123
  {},
98
- query_ctx,
124
+ core::query_context(std::move(bucket_name), std::move(scope_name)),
99
125
  true,
100
126
  options.ignore_if_exists,
101
127
  {},
@@ -103,17 +129,104 @@ initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> co
103
129
  options.num_replicas,
104
130
  {},
105
131
  options.timeout,
106
- },
107
- [core, bucket_name, options = std::move(options), handler = std::move(handler)](
108
- operations::management::query_index_create_response resp) { handler(build_context(resp)); });
132
+ };
133
+ return request;
109
134
  }
110
135
 
111
136
  void
112
- initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
113
- std::string bucket_name,
114
- couchbase::create_primary_query_index_options::built options,
115
- create_primary_query_index_handler&& handler)
137
+ query_index_manager::create_index(std::string bucket_name,
138
+ std::string index_name,
139
+ std::vector<std::string> fields,
140
+ const couchbase::create_query_index_options& options,
141
+ couchbase::create_primary_query_index_handler&& handler) const
142
+ {
143
+ auto request = build_create_index_request(std::move(bucket_name), std::move(index_name), std::move(fields), options.build());
144
+
145
+ core_->execute(std::move(request),
146
+ [handler = std::move(handler)](core::operations::management::query_index_create_response resp) mutable {
147
+ return handler(build_context(resp));
148
+ });
149
+ }
150
+
151
+ auto
152
+ query_index_manager::create_index(std::string bucket_name,
153
+ std::string index_name,
154
+ std::vector<std::string> fields,
155
+ const couchbase::create_query_index_options& options) const -> std::future<manager_error_context>
156
+ {
157
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
158
+ create_index(std::move(bucket_name), std::move(index_name), std::move(fields), options, [barrier](auto ctx) mutable {
159
+ barrier->set_value(std::move(ctx));
160
+ });
161
+ return barrier->get_future();
162
+ }
163
+
164
+ void
165
+ query_index_manager::create_primary_index(std::string bucket_name,
166
+ const create_primary_query_index_options& options,
167
+ create_query_index_handler&& handler)
168
+ {
169
+ auto request = build_create_primary_index_request(std::move(bucket_name), options.build());
170
+
171
+ core_->execute(std::move(request),
172
+ [handler = std::move(handler)](core::operations::management::query_index_create_response resp) mutable {
173
+ return handler(build_context(resp));
174
+ });
175
+ }
176
+
177
+ auto
178
+ query_index_manager::create_primary_index(std::string bucket_name, const create_primary_query_index_options& options)
179
+ -> std::future<manager_error_context>
180
+ {
181
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
182
+ create_primary_index(std::move(bucket_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
183
+ return barrier->get_future();
184
+ }
185
+
186
+ void
187
+ collection_query_index_manager::create_index(std::string index_name,
188
+ std::vector<std::string> fields,
189
+ const create_query_index_options& options,
190
+ create_query_index_handler&& handler) const
191
+ {
192
+ auto request =
193
+ build_create_index_request(bucket_name_, scope_name_, collection_name_, std::move(index_name), std::move(fields), options.build());
194
+
195
+ core_->execute(std::move(request),
196
+ [handler = std::move(handler)](core::operations::management::query_index_create_response resp) mutable {
197
+ return handler(build_context(resp));
198
+ });
199
+ }
200
+
201
+ auto
202
+ collection_query_index_manager::create_index(std::string index_name,
203
+ std::vector<std::string> fields,
204
+ const couchbase::create_query_index_options& options) const
205
+ -> std::future<manager_error_context>
206
+ {
207
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
208
+ create_index(std::move(index_name), std::move(fields), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
209
+ return barrier->get_future();
210
+ }
211
+
212
+ void
213
+ collection_query_index_manager::create_primary_index(const create_primary_query_index_options& options,
214
+ create_query_index_handler&& handler) const
215
+ {
216
+ auto request = build_create_primary_index_request(bucket_name_, scope_name_, collection_name_, options.build());
217
+
218
+ core_->execute(std::move(request),
219
+ [handler = std::move(handler)](core::operations::management::query_index_create_response resp) mutable {
220
+ return handler(build_context(resp));
221
+ });
222
+ }
223
+
224
+ auto
225
+ collection_query_index_manager::create_primary_index(const couchbase::create_primary_query_index_options& options)
226
+ -> std::future<manager_error_context>
116
227
  {
117
- initiate_create_primary_query_index(core, std::move(bucket_name), std::move(options), {}, "", std::move(handler));
228
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
229
+ create_primary_index(options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
230
+ return barrier->get_future();
118
231
  }
119
- } // namespace couchbase::core::impl
232
+ } // namespace couchbase
@@ -41,7 +41,8 @@ dns_srv_tracker::dns_srv_tracker(asio::io_context& ctx, std::string address, con
41
41
  void
42
42
  dns_srv_tracker::get_srv_nodes(utils::movable_function<void(origin::node_list, std::error_code)> callback)
43
43
  {
44
- CB_LOG_TRACE("query DNS-SRV: address=\"{}\", service=\"{}\"", address_, service_);
44
+ CB_LOG_DEBUG(
45
+ "Query DNS-SRV: address=\"{}\", service=\"{}\", nameserver=\"{}:{}\"", address_, service_, config_.nameserver(), config_.port());
45
46
  dns_client_.query_srv(
46
47
  address_,
47
48
  service_,