couchbase 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/CMakeLists.txt +3 -0
- data/ext/build_version.hxx.in +1 -1
- data/ext/cmake/CompilerWarnings.cmake +1 -0
- data/ext/cmake/PreventInSourceBuilds.cmake +4 -1
- data/ext/couchbase/bucket.hxx +28 -2
- data/ext/couchbase/cluster.hxx +8 -2
- data/ext/couchbase/couchbase.cxx +955 -511
- data/ext/couchbase/error_context/analytics.hxx +46 -0
- data/ext/couchbase/error_context/http.hxx +44 -0
- data/ext/couchbase/error_context/key_value.hxx +47 -0
- data/ext/couchbase/error_context/query.hxx +46 -0
- data/ext/couchbase/error_context/search.hxx +47 -0
- data/ext/couchbase/error_context/view.hxx +47 -0
- data/ext/couchbase/io/dns_codec.hxx +1 -2
- data/ext/couchbase/io/http_command.hxx +16 -3
- data/ext/couchbase/io/http_context.hxx +1 -1
- data/ext/couchbase/io/http_session.hxx +12 -6
- data/ext/couchbase/io/http_session_manager.hxx +25 -24
- data/ext/couchbase/io/mcbp_session.hxx +8 -2
- data/ext/couchbase/io/retry_context.hxx +1 -1
- data/ext/couchbase/operations/analytics_dataset_create.hxx +19 -12
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +18 -10
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +16 -10
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +18 -11
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +17 -11
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +17 -10
- data/ext/couchbase/operations/analytics_index_create.hxx +17 -11
- data/ext/couchbase/operations/analytics_index_drop.hxx +16 -10
- data/ext/couchbase/operations/analytics_index_get_all.hxx +14 -10
- data/ext/couchbase/operations/analytics_link_connect.hxx +15 -9
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +16 -10
- data/ext/couchbase/operations/bucket_create.hxx +33 -10
- data/ext/couchbase/operations/bucket_drop.hxx +9 -8
- data/ext/couchbase/operations/bucket_flush.hxx +8 -8
- data/ext/couchbase/operations/bucket_get.hxx +15 -10
- data/ext/couchbase/operations/bucket_get_all.hxx +14 -7
- data/ext/couchbase/operations/bucket_settings.hxx +16 -0
- data/ext/couchbase/operations/bucket_update.hxx +32 -10
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +6 -6
- data/ext/couchbase/operations/collection_create.hxx +19 -13
- data/ext/couchbase/operations/collection_drop.hxx +18 -12
- data/ext/couchbase/operations/collections_manifest_get.hxx +5 -10
- data/ext/couchbase/operations/document_analytics.hxx +39 -17
- data/ext/couchbase/operations/document_append.hxx +5 -10
- data/ext/couchbase/operations/document_decrement.hxx +5 -10
- data/ext/couchbase/operations/document_exists.hxx +4 -6
- data/ext/couchbase/operations/document_get.hxx +6 -10
- data/ext/couchbase/operations/document_get_and_lock.hxx +4 -9
- data/ext/couchbase/operations/document_get_and_touch.hxx +4 -9
- data/ext/couchbase/operations/document_get_projected.hxx +21 -14
- data/ext/couchbase/operations/document_increment.hxx +5 -10
- data/ext/couchbase/operations/document_insert.hxx +5 -10
- data/ext/couchbase/operations/document_lookup_in.hxx +4 -9
- data/ext/couchbase/operations/document_mutate_in.hxx +7 -12
- data/ext/couchbase/operations/document_prepend.hxx +5 -10
- data/ext/couchbase/operations/document_query.hxx +45 -28
- data/ext/couchbase/operations/document_remove.hxx +5 -10
- data/ext/couchbase/operations/document_replace.hxx +5 -10
- data/ext/couchbase/operations/document_search.hxx +37 -16
- data/ext/couchbase/operations/document_touch.hxx +4 -9
- data/ext/couchbase/operations/document_unlock.hxx +4 -9
- data/ext/couchbase/operations/document_upsert.hxx +5 -10
- data/ext/couchbase/operations/document_view.hxx +29 -13
- data/ext/couchbase/operations/group_drop.hxx +7 -7
- data/ext/couchbase/operations/group_get.hxx +14 -10
- data/ext/couchbase/operations/group_get_all.hxx +14 -8
- data/ext/couchbase/operations/group_upsert.hxx +15 -9
- data/ext/couchbase/operations/http_noop.hxx +5 -5
- data/ext/couchbase/operations/mcbp_noop.hxx +3 -9
- data/ext/couchbase/operations/query_index_build_deferred.hxx +15 -9
- data/ext/couchbase/operations/query_index_create.hxx +16 -10
- data/ext/couchbase/operations/query_index_drop.hxx +16 -10
- data/ext/couchbase/operations/query_index_get_all.hxx +13 -7
- data/ext/couchbase/operations/role_get_all.hxx +14 -8
- data/ext/couchbase/operations/scope_create.hxx +19 -13
- data/ext/couchbase/operations/scope_drop.hxx +17 -11
- data/ext/couchbase/operations/scope_get_all.hxx +15 -10
- data/ext/couchbase/operations/search_get_stats.hxx +5 -5
- data/ext/couchbase/operations/search_index_analyze_document.hxx +25 -13
- data/ext/couchbase/operations/search_index_control_ingest.hxx +23 -11
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +23 -11
- data/ext/couchbase/operations/search_index_control_query.hxx +23 -11
- data/ext/couchbase/operations/search_index_drop.hxx +22 -10
- data/ext/couchbase/operations/search_index_get.hxx +22 -10
- data/ext/couchbase/operations/search_index_get_all.hxx +13 -7
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +24 -13
- data/ext/couchbase/operations/search_index_get_stats.hxx +16 -10
- data/ext/couchbase/operations/search_index_upsert.hxx +23 -11
- data/ext/couchbase/operations/user_drop.hxx +8 -8
- data/ext/couchbase/operations/user_get.hxx +14 -10
- data/ext/couchbase/operations/user_get_all.hxx +14 -8
- data/ext/couchbase/operations/user_upsert.hxx +15 -9
- data/ext/couchbase/operations/view_index_drop.hxx +7 -7
- data/ext/couchbase/operations/view_index_get.hxx +15 -9
- data/ext/couchbase/operations/view_index_get_all.hxx +15 -9
- data/ext/couchbase/operations/view_index_upsert.hxx +8 -8
- data/ext/couchbase/origin.hxx +1 -0
- data/ext/couchbase/platform/terminate_handler.cc +12 -8
- data/ext/couchbase/protocol/client_request.hxx +2 -1
- data/ext/couchbase/protocol/client_response.hxx +18 -15
- data/ext/couchbase/protocol/cmd_exists.hxx +1 -0
- data/ext/couchbase/protocol/cmd_get.hxx +1 -1
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +3 -4
- data/ext/couchbase/protocol/enhanced_error_info.hxx +28 -0
- data/ext/couchbase/utils/connection_string.hxx +1 -1
- data/ext/couchbase/version.hxx +1 -1
- data/ext/extconf.rb +1 -1
- data/ext/test/test_native_binary_operations.cxx +18 -18
- data/ext/test/test_native_diagnostics.cxx +2 -2
- data/ext/test/test_native_trivial_crud.cxx +2 -2
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_reader.hpp +1 -5
- data/lib/active_support/cache/couchbase_store.rb +362 -0
- data/lib/couchbase.rb +2 -0
- data/lib/couchbase/authenticator.rb +26 -0
- data/lib/couchbase/binary_collection.rb +1 -0
- data/lib/couchbase/bucket.rb +1 -0
- data/lib/couchbase/cluster.rb +51 -27
- data/lib/couchbase/collection.rb +19 -4
- data/lib/couchbase/collection_options.rb +10 -0
- data/lib/couchbase/configuration.rb +57 -0
- data/lib/couchbase/datastructures.rb +6 -0
- data/lib/couchbase/errors.rb +111 -3
- data/lib/couchbase/management.rb +27 -0
- data/lib/couchbase/management/bucket_manager.rb +9 -2
- data/lib/couchbase/management/collection_manager.rb +1 -1
- data/lib/couchbase/management/user_manager.rb +18 -2
- data/lib/couchbase/options.rb +33 -23
- data/lib/couchbase/railtie.rb +45 -0
- data/lib/couchbase/scope.rb +44 -3
- data/lib/couchbase/utils.rb +21 -0
- data/lib/couchbase/utils/time.rb +52 -0
- data/lib/couchbase/version.rb +1 -1
- data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
- metadata +19 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_control_query_response {
|
27
|
-
|
28
|
-
std::error_code ec;
|
27
|
+
error_context::http ctx;
|
29
28
|
std::string status{};
|
30
29
|
std::string error{};
|
31
30
|
};
|
@@ -34,6 +33,7 @@ struct search_index_control_query_request {
|
|
34
33
|
using response_type = search_index_control_query_response;
|
35
34
|
using encoded_request_type = io::http_request;
|
36
35
|
using encoded_response_type = io::http_response;
|
36
|
+
using error_context_type = error_context::http;
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
@@ -52,28 +52,40 @@ struct search_index_control_query_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
search_index_control_query_response
|
55
|
-
make_response(
|
56
|
-
search_index_control_query_request
|
55
|
+
make_response(error_context::http&& ctx,
|
56
|
+
search_index_control_query_request&,
|
57
57
|
search_index_control_query_request::encoded_response_type&& encoded)
|
58
58
|
{
|
59
|
-
search_index_control_query_response response{
|
60
|
-
if (!ec) {
|
59
|
+
search_index_control_query_response response{ ctx };
|
60
|
+
if (!response.ctx.ec) {
|
61
61
|
if (encoded.status_code == 200) {
|
62
|
-
|
62
|
+
tao::json::value payload{};
|
63
|
+
try {
|
64
|
+
payload = tao::json::from_string(encoded.body);
|
65
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
66
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
67
|
+
return response;
|
68
|
+
}
|
63
69
|
response.status = payload.at("status").get_string();
|
64
70
|
if (response.status == "ok") {
|
65
71
|
return response;
|
66
72
|
}
|
67
73
|
} else if (encoded.status_code == 400) {
|
68
|
-
|
74
|
+
tao::json::value payload{};
|
75
|
+
try {
|
76
|
+
payload = tao::json::from_string(encoded.body);
|
77
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
78
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
79
|
+
return response;
|
80
|
+
}
|
69
81
|
response.status = payload.at("status").get_string();
|
70
82
|
response.error = payload.at("error").get_string();
|
71
83
|
if (response.error.find("index not found") != std::string::npos) {
|
72
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
84
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
73
85
|
return response;
|
74
86
|
}
|
75
87
|
}
|
76
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
88
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
77
89
|
}
|
78
90
|
return response;
|
79
91
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_drop_response {
|
27
|
-
|
28
|
-
std::error_code ec;
|
27
|
+
error_context::http ctx;
|
29
28
|
std::string status{};
|
30
29
|
std::string error{};
|
31
30
|
};
|
@@ -34,6 +33,7 @@ struct search_index_drop_request {
|
|
34
33
|
using response_type = search_index_drop_response;
|
35
34
|
using encoded_request_type = io::http_request;
|
36
35
|
using encoded_response_type = io::http_response;
|
36
|
+
using error_context_type = error_context::http;
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
@@ -51,26 +51,38 @@ struct search_index_drop_request {
|
|
51
51
|
};
|
52
52
|
|
53
53
|
search_index_drop_response
|
54
|
-
make_response(
|
54
|
+
make_response(error_context::http&& ctx, search_index_drop_request&, search_index_drop_request::encoded_response_type&& encoded)
|
55
55
|
{
|
56
|
-
search_index_drop_response response{
|
57
|
-
if (!ec) {
|
56
|
+
search_index_drop_response response{ ctx };
|
57
|
+
if (!response.ctx.ec) {
|
58
58
|
if (encoded.status_code == 200) {
|
59
|
-
|
59
|
+
tao::json::value payload{};
|
60
|
+
try {
|
61
|
+
payload = tao::json::from_string(encoded.body);
|
62
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
63
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
64
|
+
return response;
|
65
|
+
}
|
60
66
|
response.status = payload.at("status").get_string();
|
61
67
|
if (response.status == "ok") {
|
62
68
|
return response;
|
63
69
|
}
|
64
70
|
} else if (encoded.status_code == 400) {
|
65
|
-
|
71
|
+
tao::json::value payload{};
|
72
|
+
try {
|
73
|
+
payload = tao::json::from_string(encoded.body);
|
74
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
75
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
76
|
+
return response;
|
77
|
+
}
|
66
78
|
response.status = payload.at("status").get_string();
|
67
79
|
response.error = payload.at("error").get_string();
|
68
80
|
if (response.error.find("index not found") != std::string::npos) {
|
69
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
81
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
70
82
|
return response;
|
71
83
|
}
|
72
84
|
}
|
73
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
85
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
74
86
|
}
|
75
87
|
return response;
|
76
88
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -25,8 +25,7 @@
|
|
25
25
|
namespace couchbase::operations
|
26
26
|
{
|
27
27
|
struct search_index_get_response {
|
28
|
-
|
29
|
-
std::error_code ec;
|
28
|
+
error_context::http ctx;
|
30
29
|
std::string status{};
|
31
30
|
search_index index{};
|
32
31
|
std::string error{};
|
@@ -36,6 +35,7 @@ struct search_index_get_request {
|
|
36
35
|
using response_type = search_index_get_response;
|
37
36
|
using encoded_request_type = io::http_request;
|
38
37
|
using encoded_response_type = io::http_response;
|
38
|
+
using error_context_type = error_context::http;
|
39
39
|
|
40
40
|
static const inline service_type type = service_type::search;
|
41
41
|
|
@@ -53,27 +53,39 @@ struct search_index_get_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
search_index_get_response
|
56
|
-
make_response(
|
56
|
+
make_response(error_context::http&& ctx, search_index_get_request&, search_index_get_request::encoded_response_type&& encoded)
|
57
57
|
{
|
58
|
-
search_index_get_response response{
|
59
|
-
if (!ec) {
|
58
|
+
search_index_get_response response{ ctx };
|
59
|
+
if (!response.ctx.ec) {
|
60
60
|
if (encoded.status_code == 200) {
|
61
|
-
|
61
|
+
tao::json::value payload{};
|
62
|
+
try {
|
63
|
+
payload = tao::json::from_string(encoded.body);
|
64
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
65
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
66
|
+
return response;
|
67
|
+
}
|
62
68
|
response.status = payload.at("status").get_string();
|
63
69
|
if (response.status == "ok") {
|
64
70
|
response.index = payload.at("indexDef").as<search_index>();
|
65
71
|
return response;
|
66
72
|
}
|
67
73
|
} else if (encoded.status_code == 400) {
|
68
|
-
|
74
|
+
tao::json::value payload{};
|
75
|
+
try {
|
76
|
+
payload = tao::json::from_string(encoded.body);
|
77
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
78
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
79
|
+
return response;
|
80
|
+
}
|
69
81
|
response.status = payload.at("status").get_string();
|
70
82
|
response.error = payload.at("error").get_string();
|
71
83
|
if (response.error.find("index not found") != std::string::npos) {
|
72
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
84
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
73
85
|
return response;
|
74
86
|
}
|
75
87
|
}
|
76
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
88
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
77
89
|
}
|
78
90
|
return response;
|
79
91
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -25,8 +25,7 @@
|
|
25
25
|
namespace couchbase::operations
|
26
26
|
{
|
27
27
|
struct search_index_get_all_response {
|
28
|
-
|
29
|
-
std::error_code ec;
|
28
|
+
error_context::http ctx;
|
30
29
|
std::string status{};
|
31
30
|
std::string impl_version{};
|
32
31
|
std::vector<search_index> indexes{};
|
@@ -36,6 +35,7 @@ struct search_index_get_all_request {
|
|
36
35
|
using response_type = search_index_get_all_response;
|
37
36
|
using encoded_request_type = io::http_request;
|
38
37
|
using encoded_response_type = io::http_response;
|
38
|
+
using error_context_type = error_context::http;
|
39
39
|
|
40
40
|
static const inline service_type type = service_type::search;
|
41
41
|
|
@@ -53,12 +53,18 @@ struct search_index_get_all_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
search_index_get_all_response
|
56
|
-
make_response(
|
56
|
+
make_response(error_context::http&& ctx, search_index_get_all_request&, search_index_get_all_request::encoded_response_type&& encoded)
|
57
57
|
{
|
58
|
-
search_index_get_all_response response{
|
59
|
-
if (!ec) {
|
58
|
+
search_index_get_all_response response{ ctx };
|
59
|
+
if (!response.ctx.ec) {
|
60
60
|
if (encoded.status_code == 200) {
|
61
|
-
|
61
|
+
tao::json::value payload{};
|
62
|
+
try {
|
63
|
+
payload = tao::json::from_string(encoded.body);
|
64
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
65
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
66
|
+
return response;
|
67
|
+
}
|
62
68
|
response.status = payload.at("status").get_string();
|
63
69
|
if (response.status == "ok") {
|
64
70
|
const auto* indexDefs = payload.find("indexDefs");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_get_documents_count_response {
|
27
|
-
|
28
|
-
std::error_code ec;
|
27
|
+
error_context::http ctx;
|
29
28
|
std::string status{};
|
30
29
|
std::uint64_t count{ 0 };
|
31
30
|
std::string error{};
|
@@ -35,6 +34,7 @@ struct search_index_get_documents_count_request {
|
|
35
34
|
using response_type = search_index_get_documents_count_response;
|
36
35
|
using encoded_request_type = io::http_request;
|
37
36
|
using encoded_response_type = io::http_response;
|
37
|
+
using error_context_type = error_context::http;
|
38
38
|
|
39
39
|
static const inline service_type type = service_type::search;
|
40
40
|
|
@@ -52,16 +52,21 @@ struct search_index_get_documents_count_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
search_index_get_documents_count_response
|
55
|
-
make_response(
|
56
|
-
search_index_get_documents_count_request
|
55
|
+
make_response(error_context::http&& ctx,
|
56
|
+
search_index_get_documents_count_request&,
|
57
57
|
search_index_get_documents_count_request::encoded_response_type&& encoded)
|
58
58
|
{
|
59
|
-
search_index_get_documents_count_response response{
|
60
|
-
if (!ec) {
|
59
|
+
search_index_get_documents_count_response response{ ctx };
|
60
|
+
if (!response.ctx.ec) {
|
61
61
|
switch (encoded.status_code) {
|
62
62
|
case 200: {
|
63
|
-
|
64
|
-
|
63
|
+
tao::json::value payload{};
|
64
|
+
try {
|
65
|
+
payload = tao::json::from_string(encoded.body);
|
66
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
67
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
68
|
+
return response;
|
69
|
+
}
|
65
70
|
response.status = payload.at("status").get_string();
|
66
71
|
if (response.status == "ok") {
|
67
72
|
response.count = payload.at("count").get_unsigned();
|
@@ -70,19 +75,25 @@ make_response(std::error_code ec,
|
|
70
75
|
} break;
|
71
76
|
case 400:
|
72
77
|
case 500: {
|
73
|
-
|
78
|
+
tao::json::value payload{};
|
79
|
+
try {
|
80
|
+
payload = tao::json::from_string(encoded.body);
|
81
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
82
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
83
|
+
return response;
|
84
|
+
}
|
74
85
|
response.status = payload.at("status").get_string();
|
75
86
|
response.error = payload.at("error").get_string();
|
76
87
|
if (response.error.find("index not found") != std::string::npos) {
|
77
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
88
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
78
89
|
return response;
|
79
90
|
} else if (response.error.find("no planPIndexes for indexName") != std::string::npos) {
|
80
|
-
response.ec = std::make_error_code(error::search_errc::index_not_ready);
|
91
|
+
response.ctx.ec = std::make_error_code(error::search_errc::index_not_ready);
|
81
92
|
return response;
|
82
93
|
}
|
83
94
|
} break;
|
84
95
|
}
|
85
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
96
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
86
97
|
}
|
87
98
|
return response;
|
88
99
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_get_stats_response {
|
27
|
-
|
28
|
-
std::error_code ec;
|
27
|
+
error_context::http ctx;
|
29
28
|
std::string status{};
|
30
29
|
std::string error{};
|
31
30
|
std::string stats{};
|
@@ -35,6 +34,7 @@ struct search_index_get_stats_request {
|
|
35
34
|
using response_type = search_index_get_stats_response;
|
36
35
|
using encoded_request_type = io::http_request;
|
37
36
|
using encoded_response_type = io::http_response;
|
37
|
+
using error_context_type = error_context::http;
|
38
38
|
|
39
39
|
static const inline service_type type = service_type::search;
|
40
40
|
|
@@ -52,29 +52,35 @@ struct search_index_get_stats_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
search_index_get_stats_response
|
55
|
-
make_response(
|
55
|
+
make_response(error_context::http&& ctx, search_index_get_stats_request&, search_index_get_stats_request::encoded_response_type&& encoded)
|
56
56
|
{
|
57
|
-
search_index_get_stats_response response{
|
58
|
-
if (!ec) {
|
57
|
+
search_index_get_stats_response response{ ctx };
|
58
|
+
if (!response.ctx.ec) {
|
59
59
|
switch (encoded.status_code) {
|
60
60
|
case 200:
|
61
61
|
response.stats = encoded.body;
|
62
62
|
return response;
|
63
63
|
case 400:
|
64
64
|
case 500: {
|
65
|
-
|
65
|
+
tao::json::value payload{};
|
66
|
+
try {
|
67
|
+
payload = tao::json::from_string(encoded.body);
|
68
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
69
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
70
|
+
return response;
|
71
|
+
}
|
66
72
|
response.status = payload.at("status").get_string();
|
67
73
|
response.error = payload.at("error").get_string();
|
68
74
|
if (response.error.find("index not found") != std::string::npos) {
|
69
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
75
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
70
76
|
return response;
|
71
77
|
} else if (response.error.find("no planPIndexes for indexName") != std::string::npos) {
|
72
|
-
response.ec = std::make_error_code(error::search_errc::index_not_ready);
|
78
|
+
response.ctx.ec = std::make_error_code(error::search_errc::index_not_ready);
|
73
79
|
return response;
|
74
80
|
}
|
75
81
|
} break;
|
76
82
|
}
|
77
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
83
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
78
84
|
}
|
79
85
|
return response;
|
80
86
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright 2020 Couchbase, Inc.
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_upsert_response {
|
27
|
-
|
28
|
-
std::error_code ec;
|
27
|
+
error_context::http ctx;
|
29
28
|
std::string status{};
|
30
29
|
std::string error{};
|
31
30
|
};
|
@@ -34,6 +33,7 @@ struct search_index_upsert_request {
|
|
34
33
|
using response_type = search_index_upsert_response;
|
35
34
|
using encoded_request_type = io::http_request;
|
36
35
|
using encoded_response_type = io::http_response;
|
36
|
+
using error_context_type = error_context::http;
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
@@ -77,29 +77,41 @@ struct search_index_upsert_request {
|
|
77
77
|
};
|
78
78
|
|
79
79
|
search_index_upsert_response
|
80
|
-
make_response(
|
80
|
+
make_response(error_context::http&& ctx, search_index_upsert_request&, search_index_upsert_request::encoded_response_type&& encoded)
|
81
81
|
{
|
82
|
-
search_index_upsert_response response{
|
83
|
-
if (!ec) {
|
82
|
+
search_index_upsert_response response{ ctx };
|
83
|
+
if (!response.ctx.ec) {
|
84
84
|
if (encoded.status_code == 200) {
|
85
|
-
|
85
|
+
tao::json::value payload{};
|
86
|
+
try {
|
87
|
+
payload = tao::json::from_string(encoded.body);
|
88
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
89
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
90
|
+
return response;
|
91
|
+
}
|
86
92
|
response.status = payload.at("status").get_string();
|
87
93
|
if (response.status == "ok") {
|
88
94
|
return response;
|
89
95
|
}
|
90
96
|
} else if (encoded.status_code == 400) {
|
91
|
-
|
97
|
+
tao::json::value payload{};
|
98
|
+
try {
|
99
|
+
payload = tao::json::from_string(encoded.body);
|
100
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
101
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
102
|
+
return response;
|
103
|
+
}
|
92
104
|
response.status = payload.at("status").get_string();
|
93
105
|
response.error = payload.at("error").get_string();
|
94
106
|
if (response.error.find("index not found") != std::string::npos) {
|
95
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
107
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
96
108
|
return response;
|
97
109
|
} else if (response.error.find("index with the same name already exists") != std::string::npos) {
|
98
|
-
response.ec = std::make_error_code(error::common_errc::index_exists);
|
110
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_exists);
|
99
111
|
return response;
|
100
112
|
}
|
101
113
|
}
|
102
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
114
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
103
115
|
}
|
104
116
|
return response;
|
105
117
|
}
|