couchbase 4.7.0-dev.1 → 4.7.1
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.
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +3 -575
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
- package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
- package/deps/couchbase-cxx-client/README.md +2 -2
- package/deps/couchbase-cxx-client/core/error_context/base_error_context.hxx +32 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +1 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +23 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value_error_context.hxx +35 -0
- package/deps/couchbase-cxx-client/core/error_context/subdocument_error_context.hxx +41 -0
- package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +123 -88
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +416 -189
- package/deps/couchbase-cxx-client/core/impl/error.cxx +29 -4
- package/deps/couchbase-cxx-client/core/impl/invoke_with_node_id.hxx +44 -0
- package/deps/couchbase-cxx-client/core/impl/node_id.cxx +110 -0
- package/deps/couchbase-cxx-client/core/impl/node_id.hxx +40 -0
- package/deps/couchbase-cxx-client/core/io/configuration_belongs_to_session.hxx +67 -0
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -57
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +7 -16
- package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +14 -4
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -4
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +4 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -12
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +11 -11
- package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +11 -11
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +11 -11
- package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +9 -6
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +5 -4
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +7 -6
- package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +12 -13
- package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +8 -9
- package/deps/couchbase-cxx-client/core/topology/configuration.cxx +21 -0
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +28 -0
- package/deps/couchbase-cxx-client/core/utils/contains_string.cxx +61 -0
- package/deps/couchbase-cxx-client/core/utils/contains_string.hxx +26 -0
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +73 -0
- package/deps/couchbase-cxx-client/couchbase/error.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/node_id.hxx +123 -0
- package/deps/couchbase-cxx-client/couchbase/node_id_for_options.hxx +61 -0
- package/deps/couchbase-cxx-client/couchbase/node_ids_options.hxx +62 -0
- package/deps/couchbase-cxx-client/couchbase/result.hxx +42 -0
- package/dist/binding.d.ts +1 -0
- package/dist/bucket.d.ts +9 -1
- package/dist/bucket.js +21 -0
- package/dist/cluster.d.ts +10 -1
- package/dist/cluster.js +22 -0
- package/dist/collection.d.ts +3 -3
- package/dist/collection.js +161 -123
- package/dist/diagnosticsexecutor.js +2 -2
- package/dist/diagnosticstypes.d.ts +36 -0
- package/dist/diagnosticstypes.js +22 -1
- package/dist/observability.d.ts +5 -1
- package/dist/observability.js +11 -3
- package/dist/observabilityhandler.d.ts +6 -0
- package/dist/observabilityhandler.js +51 -14
- package/dist/observabilitytypes.js +19 -42
- package/dist/observabilityutilities.js +1 -1
- package/dist/oteltracer.d.ts +5 -0
- package/dist/oteltracer.js +7 -0
- package/dist/queryindexmanager.js +15 -0
- package/dist/thresholdlogging.d.ts +5 -0
- package/dist/thresholdlogging.js +7 -0
- package/dist/tracing.d.ts +6 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/waituntilreadyexecutor.d.ts +37 -0
- package/dist/waituntilreadyexecutor.js +156 -0
- package/package.json +8 -8
- package/scripts/prebuilds.js +13 -0
- package/src/binding.cpp +1 -1
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
#include "core/cluster_options.hxx"
|
|
21
21
|
#include "core/logger/logger.hxx"
|
|
22
22
|
#include "core/operations/management/error_utils.hxx"
|
|
23
|
+
#include "core/utils/contains_string.hxx"
|
|
23
24
|
#include "core/utils/duration_parser.hxx"
|
|
24
25
|
#include "core/utils/json.hxx"
|
|
25
26
|
|
|
@@ -28,13 +29,11 @@
|
|
|
28
29
|
#include <gsl/assert>
|
|
29
30
|
#include <tao/json/value.hpp>
|
|
30
31
|
|
|
31
|
-
#include <regex>
|
|
32
|
-
|
|
33
32
|
namespace couchbase::core::operations
|
|
34
33
|
{
|
|
35
34
|
auto
|
|
36
|
-
query_request::encode_to(query_request::encoded_request_type& encoded,
|
|
37
|
-
|
|
35
|
+
query_request::encode_to(query_request::encoded_request_type& encoded, http_context& context)
|
|
36
|
+
-> std::error_code
|
|
38
37
|
{
|
|
39
38
|
ctx_.emplace(context);
|
|
40
39
|
tao::json::value body{
|
|
@@ -209,8 +208,8 @@ query_request::encode_to(query_request::encoded_request_type& encoded,
|
|
|
209
208
|
}
|
|
210
209
|
|
|
211
210
|
auto
|
|
212
|
-
query_request::make_response(error_context::query&& ctx,
|
|
213
|
-
|
|
211
|
+
query_request::make_response(error_context::query&& ctx, const encoded_response_type& encoded)
|
|
212
|
+
-> query_response
|
|
214
213
|
{
|
|
215
214
|
query_response response{ std::move(ctx) };
|
|
216
215
|
response.ctx.statement = statement;
|
|
@@ -374,13 +373,14 @@ query_request::make_response(error_context::query&& ctx,
|
|
|
374
373
|
response.ctx.ec = errc::common::index_exists;
|
|
375
374
|
break;
|
|
376
375
|
case 5000: /* IKey: "Internal Error" */
|
|
377
|
-
if (
|
|
378
|
-
|
|
376
|
+
if (utils::contains_string(response.ctx.first_error_message, "index", true) &&
|
|
377
|
+
utils::contains_string(response.ctx.first_error_message, "already exist", true)) {
|
|
379
378
|
response.ctx.ec = errc::common::index_exists;
|
|
380
|
-
} else if (response.ctx.first_error_message
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
379
|
+
} else if (utils::contains_string(response.ctx.first_error_message,
|
|
380
|
+
"Index does not exist") ||
|
|
381
|
+
(utils::contains_string(response.ctx.first_error_message, "index", true) &&
|
|
382
|
+
utils::contains_string(
|
|
383
|
+
response.ctx.first_error_message, "not found", true))) {
|
|
384
384
|
response.ctx.ec = errc::common::index_not_found;
|
|
385
385
|
} else if (response.ctx.first_error_message.find("Bucket Not Found") !=
|
|
386
386
|
std::string::npos) {
|
|
@@ -24,13 +24,11 @@
|
|
|
24
24
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
25
|
#include <tao/json/value.hpp>
|
|
26
26
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
27
|
namespace couchbase::core::operations::management
|
|
30
28
|
{
|
|
31
29
|
auto
|
|
32
|
-
collection_create_request::encode_to(encoded_request_type& encoded,
|
|
33
|
-
|
|
30
|
+
collection_create_request::encode_to(encoded_request_type& encoded, http_context& /*context*/) const
|
|
31
|
+
-> std::error_code
|
|
34
32
|
{
|
|
35
33
|
encoded.method = "POST";
|
|
36
34
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections",
|
|
@@ -58,18 +56,20 @@ collection_create_request::make_response(error_context::http&& ctx,
|
|
|
58
56
|
{
|
|
59
57
|
collection_create_response response{ std::move(ctx) };
|
|
60
58
|
if (!response.ctx.ec) {
|
|
61
|
-
switch (encoded.status_code) {
|
|
59
|
+
switch (const auto& body = encoded.body.data(); encoded.status_code) {
|
|
62
60
|
case 400: {
|
|
63
|
-
const
|
|
64
|
-
if (std::
|
|
61
|
+
const auto prefix_pos = body.find("Collection with name ");
|
|
62
|
+
if (prefix_pos != std::string_view::npos &&
|
|
63
|
+
body.find(" already exists", prefix_pos) != std::string_view::npos) {
|
|
65
64
|
response.ctx.ec = errc::management::collection_exists;
|
|
66
65
|
} else {
|
|
67
66
|
response.ctx.ec = errc::common::invalid_argument;
|
|
68
67
|
}
|
|
69
68
|
} break;
|
|
70
69
|
case 404: {
|
|
71
|
-
const
|
|
72
|
-
if (std::
|
|
70
|
+
const auto prefix_pos = body.find("Scope with name ");
|
|
71
|
+
if (prefix_pos != std::string_view::npos &&
|
|
72
|
+
body.find(" is not found", prefix_pos) != std::string_view::npos) {
|
|
73
73
|
response.ctx.ec = errc::common::scope_not_found;
|
|
74
74
|
} else {
|
|
75
75
|
response.ctx.ec = errc::common::bucket_not_found;
|
|
@@ -78,7 +78,7 @@ collection_create_request::make_response(error_context::http&& ctx,
|
|
|
78
78
|
case 200: {
|
|
79
79
|
tao::json::value payload{};
|
|
80
80
|
try {
|
|
81
|
-
payload = utils::json::parse(
|
|
81
|
+
payload = utils::json::parse(body);
|
|
82
82
|
} catch (const tao::pegtl::parse_error&) {
|
|
83
83
|
response.ctx.ec = errc::common::parsing_failure;
|
|
84
84
|
return response;
|
|
@@ -86,7 +86,7 @@ collection_create_request::make_response(error_context::http&& ctx,
|
|
|
86
86
|
response.uid = std::stoull(payload.at("uid").get_string(), nullptr, 16);
|
|
87
87
|
} break;
|
|
88
88
|
default:
|
|
89
|
-
response.ctx.ec = extract_common_error_code(encoded.status_code,
|
|
89
|
+
response.ctx.ec = extract_common_error_code(encoded.status_code, body);
|
|
90
90
|
break;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -24,13 +24,11 @@
|
|
|
24
24
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
25
|
#include <tao/json/value.hpp>
|
|
26
26
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
27
|
namespace couchbase::core::operations::management
|
|
30
28
|
{
|
|
31
29
|
auto
|
|
32
|
-
collection_drop_request::encode_to(encoded_request_type& encoded,
|
|
33
|
-
|
|
30
|
+
collection_drop_request::encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
|
31
|
+
-> std::error_code
|
|
34
32
|
{
|
|
35
33
|
encoded.method = "DELETE";
|
|
36
34
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections/{}",
|
|
@@ -47,16 +45,18 @@ collection_drop_request::make_response(error_context::http&& ctx,
|
|
|
47
45
|
{
|
|
48
46
|
collection_drop_response response{ std::move(ctx) };
|
|
49
47
|
if (!response.ctx.ec) {
|
|
50
|
-
switch (encoded.status_code) {
|
|
48
|
+
switch (const auto& body = encoded.body.data(); encoded.status_code) {
|
|
51
49
|
case 400:
|
|
52
50
|
response.ctx.ec = errc::common::unsupported_operation;
|
|
53
51
|
break;
|
|
54
52
|
case 404: {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
if (std::
|
|
53
|
+
const auto collection_prefix_pos = body.find("Collection with name ");
|
|
54
|
+
const auto scope_prefix_pos = body.find("Scope with name ");
|
|
55
|
+
if (collection_prefix_pos != std::string_view::npos &&
|
|
56
|
+
body.find(" is not found", collection_prefix_pos) != std::string_view::npos) {
|
|
58
57
|
response.ctx.ec = errc::common::collection_not_found;
|
|
59
|
-
} else if (std::
|
|
58
|
+
} else if (scope_prefix_pos != std::string_view::npos &&
|
|
59
|
+
body.find(" is not found", scope_prefix_pos) != std::string_view::npos) {
|
|
60
60
|
response.ctx.ec = errc::common::scope_not_found;
|
|
61
61
|
} else {
|
|
62
62
|
response.ctx.ec = errc::common::bucket_not_found;
|
|
@@ -65,7 +65,7 @@ collection_drop_request::make_response(error_context::http&& ctx,
|
|
|
65
65
|
case 200: {
|
|
66
66
|
tao::json::value payload{};
|
|
67
67
|
try {
|
|
68
|
-
payload = utils::json::parse(
|
|
68
|
+
payload = utils::json::parse(body);
|
|
69
69
|
} catch (const tao::pegtl::parse_error&) {
|
|
70
70
|
response.ctx.ec = errc::common::parsing_failure;
|
|
71
71
|
return response;
|
|
@@ -73,7 +73,7 @@ collection_drop_request::make_response(error_context::http&& ctx,
|
|
|
73
73
|
response.uid = std::stoull(payload.at("uid").get_string(), nullptr, 16);
|
|
74
74
|
} break;
|
|
75
75
|
default:
|
|
76
|
-
response.ctx.ec = extract_common_error_code(encoded.status_code,
|
|
76
|
+
response.ctx.ec = extract_common_error_code(encoded.status_code, body);
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -24,13 +24,11 @@
|
|
|
24
24
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
25
|
#include <tao/json/value.hpp>
|
|
26
26
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
27
|
namespace couchbase::core::operations::management
|
|
30
28
|
{
|
|
31
29
|
auto
|
|
32
|
-
collection_update_request::encode_to(encoded_request_type& encoded,
|
|
33
|
-
|
|
30
|
+
collection_update_request::encode_to(encoded_request_type& encoded, http_context& /*context*/) const
|
|
31
|
+
-> std::error_code
|
|
34
32
|
{
|
|
35
33
|
encoded.method = "PATCH";
|
|
36
34
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections/{}",
|
|
@@ -60,16 +58,18 @@ collection_update_request::make_response(error_context::http&& ctx,
|
|
|
60
58
|
{
|
|
61
59
|
collection_update_response response{ std::move(ctx) };
|
|
62
60
|
if (!response.ctx.ec) {
|
|
63
|
-
switch (encoded.status_code) {
|
|
61
|
+
switch (const auto& body = encoded.body.data(); encoded.status_code) {
|
|
64
62
|
case 400: {
|
|
65
63
|
response.ctx.ec = errc::common::invalid_argument;
|
|
66
64
|
} break;
|
|
67
65
|
case 404: {
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
if (std::
|
|
66
|
+
const auto collection_prefix_pos = body.find("Collection with name ");
|
|
67
|
+
const auto scope_prefix_pos = body.find("Scope with name ");
|
|
68
|
+
if (collection_prefix_pos != std::string_view::npos &&
|
|
69
|
+
body.find(" is not found", collection_prefix_pos) != std::string_view::npos) {
|
|
71
70
|
response.ctx.ec = errc::common::collection_not_found;
|
|
72
|
-
} else if (std::
|
|
71
|
+
} else if (scope_prefix_pos != std::string_view::npos &&
|
|
72
|
+
body.find(" is not found", scope_prefix_pos) != std::string_view::npos) {
|
|
73
73
|
response.ctx.ec = errc::common::scope_not_found;
|
|
74
74
|
} else {
|
|
75
75
|
response.ctx.ec = errc::common::bucket_not_found;
|
|
@@ -78,7 +78,7 @@ collection_update_request::make_response(error_context::http&& ctx,
|
|
|
78
78
|
case 200: {
|
|
79
79
|
tao::json::value payload{};
|
|
80
80
|
try {
|
|
81
|
-
payload = utils::json::parse(
|
|
81
|
+
payload = utils::json::parse(body);
|
|
82
82
|
} catch (const tao::pegtl::parse_error&) {
|
|
83
83
|
response.ctx.ec = errc::common::parsing_failure;
|
|
84
84
|
return response;
|
|
@@ -86,7 +86,7 @@ collection_update_request::make_response(error_context::http&& ctx,
|
|
|
86
86
|
response.uid = std::stoull(payload.at("uid").get_string(), nullptr, 16);
|
|
87
87
|
} break;
|
|
88
88
|
default:
|
|
89
|
-
response.ctx.ec = extract_common_error_code(encoded.status_code,
|
|
89
|
+
response.ctx.ec = extract_common_error_code(encoded.status_code, body);
|
|
90
90
|
break;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
#include "error_utils.hxx"
|
|
19
|
+
#include "core/utils/contains_string.hxx"
|
|
19
20
|
#include "core/utils/json.hxx"
|
|
20
21
|
|
|
21
22
|
#include <tao/json/value.hpp>
|
|
22
23
|
|
|
23
|
-
#include <regex>
|
|
24
|
-
|
|
25
24
|
namespace couchbase::core::operations::management
|
|
26
25
|
{
|
|
27
26
|
|
|
@@ -143,12 +142,16 @@ translate_query_error_code(std::uint64_t error, const std::string& message, std:
|
|
|
143
142
|
{
|
|
144
143
|
switch (error) {
|
|
145
144
|
case 5000: /* IKey: "Internal Error" */
|
|
146
|
-
if (
|
|
145
|
+
if (utils::contains_string(message, "index", true) &&
|
|
146
|
+
utils::contains_string(message, "already exist", true)) {
|
|
147
147
|
return errc::common::index_exists;
|
|
148
|
-
}
|
|
149
|
-
|
|
148
|
+
}
|
|
149
|
+
if (utils::contains_string(message, "Index does not exist") ||
|
|
150
|
+
(utils::contains_string(message, "index", true) &&
|
|
151
|
+
utils::contains_string(message, "not found", true))) {
|
|
150
152
|
return errc::common::index_not_found;
|
|
151
|
-
}
|
|
153
|
+
}
|
|
154
|
+
if (message.find("Bucket Not Found") != std::string::npos) {
|
|
152
155
|
return errc::common::bucket_not_found;
|
|
153
156
|
}
|
|
154
157
|
break;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#include "query_index_create.hxx"
|
|
19
19
|
|
|
20
|
+
#include "core/utils/contains_string.hxx"
|
|
20
21
|
#include "core/utils/json.hxx"
|
|
21
22
|
#include "core/utils/keyspace.hxx"
|
|
22
23
|
#include "error_utils.hxx"
|
|
@@ -24,8 +25,6 @@
|
|
|
24
25
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
26
|
#include <tao/json/value.hpp>
|
|
26
27
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
28
|
namespace couchbase::core::operations::management
|
|
30
29
|
{
|
|
31
30
|
auto
|
|
@@ -118,13 +117,15 @@ query_index_create_request::make_response(error_context::http&& ctx,
|
|
|
118
117
|
error.message = entry.at("msg").get_string();
|
|
119
118
|
switch (error.code) {
|
|
120
119
|
case 5000: /* IKey: "Internal Error" */
|
|
121
|
-
|
|
120
|
+
{
|
|
121
|
+
if (utils::contains_string(error.message, "index", true) &&
|
|
122
|
+
utils::contains_string(error.message, "already exist", true)) {
|
|
122
123
|
index_already_exists = true;
|
|
123
124
|
}
|
|
124
125
|
if (error.message.find("Bucket Not Found") != std::string::npos) {
|
|
125
126
|
bucket_not_found = true;
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
+
} break;
|
|
128
129
|
|
|
129
130
|
case 12003: /* IKey: "datastore.couchbase.keyspace_not_found" */
|
|
130
131
|
if (error.message.find("missing_collection") != std::string::npos) {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#include "query_index_drop.hxx"
|
|
19
19
|
|
|
20
|
+
#include "core/utils/contains_string.hxx"
|
|
20
21
|
#include "core/utils/json.hxx"
|
|
21
22
|
#include "core/utils/keyspace.hxx"
|
|
22
23
|
#include "error_utils.hxx"
|
|
@@ -24,13 +25,11 @@
|
|
|
24
25
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
26
|
#include <tao/json/value.hpp>
|
|
26
27
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
28
|
namespace couchbase::core::operations::management
|
|
30
29
|
{
|
|
31
30
|
auto
|
|
32
|
-
query_index_drop_request::encode_to(encoded_request_type& encoded,
|
|
33
|
-
|
|
31
|
+
query_index_drop_request::encode_to(encoded_request_type& encoded, http_context& /*context*/) const
|
|
32
|
+
-> std::error_code
|
|
34
33
|
{
|
|
35
34
|
if (!utils::check_query_management_request(*this)) {
|
|
36
35
|
return errc::common::invalid_argument;
|
|
@@ -87,10 +86,12 @@ query_index_drop_request::make_response(error_context::http&& ctx,
|
|
|
87
86
|
error.message = entry.at("msg").get_string();
|
|
88
87
|
switch (error.code) {
|
|
89
88
|
case 5000: /* IKey: "Internal Error" */
|
|
90
|
-
|
|
89
|
+
{
|
|
90
|
+
if (utils::contains_string(error.message, "index", true) &&
|
|
91
|
+
utils::contains_string(error.message, "not found", true)) {
|
|
91
92
|
index_not_found = true;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
} break;
|
|
94
95
|
|
|
95
96
|
case 12003: /* IKey: "datastore.couchbase.keyspace_not_found" */
|
|
96
97
|
if (error.message.find("missing_collection") != std::string::npos) {
|
|
@@ -24,13 +24,11 @@
|
|
|
24
24
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
25
|
#include <tao/json/value.hpp>
|
|
26
26
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
27
|
namespace couchbase::core::operations::management
|
|
30
28
|
{
|
|
31
29
|
auto
|
|
32
|
-
scope_create_request::encode_to(encoded_request_type& encoded,
|
|
33
|
-
|
|
30
|
+
scope_create_request::encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
|
31
|
+
-> std::error_code
|
|
34
32
|
{
|
|
35
33
|
encoded.method = "POST";
|
|
36
34
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes",
|
|
@@ -41,18 +39,19 @@ scope_create_request::encode_to(encoded_request_type& encoded,
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
auto
|
|
44
|
-
scope_create_request::make_response(error_context::http&& ctx,
|
|
45
|
-
|
|
42
|
+
scope_create_request::make_response(error_context::http&& ctx,
|
|
43
|
+
const encoded_response_type& encoded) const
|
|
44
|
+
-> scope_create_response
|
|
46
45
|
{
|
|
47
46
|
scope_create_response response{ std::move(ctx) };
|
|
48
47
|
if (!response.ctx.ec) {
|
|
49
|
-
switch (encoded.status_code) {
|
|
48
|
+
switch (const auto& body = encoded.body.data(); encoded.status_code) {
|
|
50
49
|
case 400: {
|
|
51
|
-
const
|
|
52
|
-
if (std::
|
|
50
|
+
const auto prefix_pos = body.find("Scope with name ");
|
|
51
|
+
if (prefix_pos != std::string_view::npos &&
|
|
52
|
+
body.find(" already exists", prefix_pos) != std::string_view::npos) {
|
|
53
53
|
response.ctx.ec = errc::management::scope_exists;
|
|
54
|
-
} else if (
|
|
55
|
-
std::string::npos) {
|
|
54
|
+
} else if (body.find("Not allowed on this version of cluster") != std::string::npos) {
|
|
56
55
|
response.ctx.ec = errc::common::feature_not_available;
|
|
57
56
|
} else {
|
|
58
57
|
response.ctx.ec = errc::common::invalid_argument;
|
|
@@ -64,7 +63,7 @@ scope_create_request::make_response(error_context::http&& ctx, const encoded_res
|
|
|
64
63
|
case 200: {
|
|
65
64
|
tao::json::value payload{};
|
|
66
65
|
try {
|
|
67
|
-
payload = utils::json::parse(
|
|
66
|
+
payload = utils::json::parse(body);
|
|
68
67
|
} catch (const tao::pegtl::parse_error&) {
|
|
69
68
|
response.ctx.ec = errc::common::parsing_failure;
|
|
70
69
|
return response;
|
|
@@ -72,7 +71,7 @@ scope_create_request::make_response(error_context::http&& ctx, const encoded_res
|
|
|
72
71
|
response.uid = std::stoull(payload.at("uid").get_string(), nullptr, 16);
|
|
73
72
|
} break;
|
|
74
73
|
default:
|
|
75
|
-
response.ctx.ec = extract_common_error_code(encoded.status_code,
|
|
74
|
+
response.ctx.ec = extract_common_error_code(encoded.status_code, body);
|
|
76
75
|
break;
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -24,13 +24,11 @@
|
|
|
24
24
|
#include <spdlog/fmt/bundled/core.h>
|
|
25
25
|
#include <tao/json/value.hpp>
|
|
26
26
|
|
|
27
|
-
#include <regex>
|
|
28
|
-
|
|
29
27
|
namespace couchbase::core::operations::management
|
|
30
28
|
{
|
|
31
29
|
auto
|
|
32
|
-
scope_drop_request::encode_to(encoded_request_type& encoded,
|
|
33
|
-
|
|
30
|
+
scope_drop_request::encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
|
31
|
+
-> std::error_code
|
|
34
32
|
{
|
|
35
33
|
encoded.method = "DELETE";
|
|
36
34
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}",
|
|
@@ -45,13 +43,14 @@ scope_drop_request::make_response(error_context::http&& ctx,
|
|
|
45
43
|
{
|
|
46
44
|
scope_drop_response response{ std::move(ctx) };
|
|
47
45
|
if (!response.ctx.ec) {
|
|
48
|
-
switch (encoded.status_code) {
|
|
46
|
+
switch (const auto& body = encoded.body.data(); encoded.status_code) {
|
|
49
47
|
case 400:
|
|
50
48
|
response.ctx.ec = errc::common::unsupported_operation;
|
|
51
49
|
break;
|
|
52
50
|
case 404: {
|
|
53
|
-
const
|
|
54
|
-
if (std::
|
|
51
|
+
const auto prefix_pos = body.find("Scope with name ");
|
|
52
|
+
if (prefix_pos != std::string_view::npos &&
|
|
53
|
+
body.find(" is not found", prefix_pos) != std::string_view::npos) {
|
|
55
54
|
response.ctx.ec = errc::common::scope_not_found;
|
|
56
55
|
} else {
|
|
57
56
|
response.ctx.ec = errc::common::bucket_not_found;
|
|
@@ -60,7 +59,7 @@ scope_drop_request::make_response(error_context::http&& ctx,
|
|
|
60
59
|
case 200: {
|
|
61
60
|
tao::json::value payload{};
|
|
62
61
|
try {
|
|
63
|
-
payload = utils::json::parse(
|
|
62
|
+
payload = utils::json::parse(body);
|
|
64
63
|
} catch (const tao::pegtl::parse_error&) {
|
|
65
64
|
response.ctx.ec = errc::common::parsing_failure;
|
|
66
65
|
return response;
|
|
@@ -68,7 +67,7 @@ scope_drop_request::make_response(error_context::http&& ctx,
|
|
|
68
67
|
response.uid = std::stoull(payload.at("uid").get_string(), nullptr, 16);
|
|
69
68
|
} break;
|
|
70
69
|
default:
|
|
71
|
-
response.ctx.ec = extract_common_error_code(encoded.status_code,
|
|
70
|
+
response.ctx.ec = extract_common_error_code(encoded.status_code, body);
|
|
72
71
|
break;
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#include "configuration.hxx"
|
|
19
19
|
|
|
20
|
+
#include "core/impl/node_id.hxx"
|
|
20
21
|
#include "core/logger/logger.hxx"
|
|
21
22
|
#include "core/service_type_fmt.hxx"
|
|
22
23
|
#include "core/utils/crc32.hxx"
|
|
@@ -171,6 +172,26 @@ configuration::node::endpoint(const std::string& network, service_type type, boo
|
|
|
171
172
|
return fmt::format("{}:{}", hostname_for(network), p);
|
|
172
173
|
}
|
|
173
174
|
|
|
175
|
+
auto
|
|
176
|
+
configuration::node::effective_node_id(bool is_tls) const -> couchbase::node_id
|
|
177
|
+
{
|
|
178
|
+
return internal_node_id::build(node_uuid, hostname, port_or(service_type::key_value, is_tls, 0));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
auto
|
|
182
|
+
configuration::effective_node_ids(bool is_tls) const -> std::vector<couchbase::node_id>
|
|
183
|
+
{
|
|
184
|
+
std::vector<couchbase::node_id> result;
|
|
185
|
+
result.reserve(nodes.size());
|
|
186
|
+
for (const auto& n : nodes) {
|
|
187
|
+
if (n.port_or(service_type::key_value, is_tls, 0) == 0) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
result.push_back(n.effective_node_id(is_tls));
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
|
|
174
195
|
auto
|
|
175
196
|
configuration::has_node(const std::string& network,
|
|
176
197
|
service_type type,
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
#include "core/platform/uuid.h"
|
|
22
22
|
#include "core/service_type.hxx"
|
|
23
23
|
|
|
24
|
+
#include <couchbase/node_id.hxx>
|
|
25
|
+
|
|
24
26
|
#include <map>
|
|
25
27
|
#include <optional>
|
|
26
28
|
#include <set>
|
|
@@ -83,10 +85,36 @@ struct configuration {
|
|
|
83
85
|
|
|
84
86
|
[[nodiscard]] auto endpoint(const std::string& network, service_type type, bool is_tls) const
|
|
85
87
|
-> std::optional<std::string>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns a node_id built from this node's UUID (when available on
|
|
91
|
+
* Server 8.0.1+) with fallback to a deterministic hash of hostname +
|
|
92
|
+
* KV port for older servers.
|
|
93
|
+
*
|
|
94
|
+
* The KV port selected mirrors what mcbp_session uses for the same node
|
|
95
|
+
* (TLS port when @p is_tls, plain port otherwise), ensuring that the
|
|
96
|
+
* node_id surfaced on the request side via collection::node_id_for
|
|
97
|
+
* matches the node_id attached to results and errors.
|
|
98
|
+
*/
|
|
99
|
+
[[nodiscard]] auto effective_node_id(bool is_tls) const -> couchbase::node_id;
|
|
86
100
|
};
|
|
87
101
|
|
|
88
102
|
[[nodiscard]] auto select_network(const std::string& bootstrap_hostname) const -> std::string;
|
|
89
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Returns one node_id per cluster node that currently serves the
|
|
106
|
+
* key-value service over the requested transport. Nodes that do not
|
|
107
|
+
* expose a KV port for @p is_tls are filtered out — without a KV port
|
|
108
|
+
* the fallback hash would be derived from a meaningless port=0 and
|
|
109
|
+
* could collide with a sibling node that is also missing its KV port.
|
|
110
|
+
*
|
|
111
|
+
* The returned vector preserves topology order; callers that want a
|
|
112
|
+
* set semantic should hash the entries themselves (couchbase::node_id
|
|
113
|
+
* is hashable). Topology nodes are unique by construction, so no
|
|
114
|
+
* dedup is performed here.
|
|
115
|
+
*/
|
|
116
|
+
[[nodiscard]] auto effective_node_ids(bool is_tls) const -> std::vector<couchbase::node_id>;
|
|
117
|
+
|
|
90
118
|
using vbucket_map = typename std::vector<std::vector<std::int16_t>>;
|
|
91
119
|
|
|
92
120
|
std::optional<std::int64_t> epoch{};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2021-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 "contains_string.hxx"
|
|
19
|
+
|
|
20
|
+
namespace couchbase::core::utils
|
|
21
|
+
{
|
|
22
|
+
|
|
23
|
+
namespace
|
|
24
|
+
{
|
|
25
|
+
constexpr auto ascii_lower = [](unsigned char c) -> unsigned char {
|
|
26
|
+
return (c >= 'A' && c <= 'Z') ? static_cast<unsigned char>(c + ('a' - 'A')) : c;
|
|
27
|
+
};
|
|
28
|
+
} // namespace
|
|
29
|
+
|
|
30
|
+
auto
|
|
31
|
+
contains_string(std::string_view input, std::string_view substr, bool ignore_case) -> bool
|
|
32
|
+
{
|
|
33
|
+
if (substr.empty()) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (input.empty() || substr.size() > input.size()) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!ignore_case) {
|
|
42
|
+
return input.find(substr) != std::string_view::npos;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const auto end = input.size() - substr.size() + 1;
|
|
46
|
+
for (std::size_t i = 0; i < end; i++) {
|
|
47
|
+
bool match = true;
|
|
48
|
+
for (std::size_t j = 0; j < substr.size(); j++) {
|
|
49
|
+
if (ascii_lower(static_cast<unsigned char>(input[i + j])) !=
|
|
50
|
+
ascii_lower(static_cast<unsigned char>(substr[j]))) {
|
|
51
|
+
match = false;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (match) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
} // namespace couchbase::core::utils
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2021-Present Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include <string_view>
|
|
21
|
+
|
|
22
|
+
namespace couchbase::core::utils
|
|
23
|
+
{
|
|
24
|
+
auto
|
|
25
|
+
contains_string(std::string_view input, std::string_view substr, bool ignore_case = false) -> bool;
|
|
26
|
+
} // namespace couchbase::core::utils
|