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,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_,
@@ -0,0 +1,66 @@
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_drop.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_drop_request
43
+ build_drop_bucket_request(std::string bucket_name, const drop_bucket_options::built& options)
44
+ {
45
+ core::operations::management::bucket_drop_request request{ std::move(bucket_name), {}, options.timeout };
46
+ return request;
47
+ }
48
+
49
+ void
50
+ bucket_manager::drop_bucket(std::string bucket_name, const drop_bucket_options& options, drop_bucket_handler&& handler) const
51
+ {
52
+ auto request = build_drop_bucket_request(std::move(bucket_name), options.build());
53
+
54
+ core_->execute(std::move(request), [handler = std::move(handler)](core::operations::management::bucket_drop_response resp) mutable {
55
+ return handler(build_context(resp));
56
+ });
57
+ }
58
+
59
+ auto
60
+ bucket_manager::drop_bucket(std::string bucket_name, const drop_bucket_options& options) const -> std::future<manager_error_context>
61
+ {
62
+ auto barrier = std::make_shared<std::promise<manager_error_context>>();
63
+ drop_bucket(std::move(bucket_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
64
+ return barrier->get_future();
65
+ }
66
+ } // namespace couchbase