couchbase 3.0.2 → 3.0.3
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.
- 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
|
@@ -19,22 +19,22 @@
|
|
|
19
19
|
|
|
20
20
|
#include <tao/json.hpp>
|
|
21
21
|
|
|
22
|
-
#include <version.hxx>
|
|
23
22
|
#include <operations/rbac.hxx>
|
|
24
23
|
#include <utils/url_codec.hxx>
|
|
24
|
+
#include <version.hxx>
|
|
25
25
|
|
|
26
26
|
namespace couchbase::operations
|
|
27
27
|
{
|
|
28
28
|
|
|
29
29
|
struct user_drop_response {
|
|
30
|
-
|
|
31
|
-
std::error_code ec;
|
|
30
|
+
error_context::http ctx;
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
struct user_drop_request {
|
|
35
34
|
using response_type = user_drop_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::management;
|
|
40
40
|
|
|
@@ -52,18 +52,18 @@ struct user_drop_request {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
user_drop_response
|
|
55
|
-
make_response(
|
|
55
|
+
make_response(error_context::http&& ctx, user_drop_request&, user_drop_request::encoded_response_type&& encoded)
|
|
56
56
|
{
|
|
57
|
-
user_drop_response response{
|
|
58
|
-
if (!ec) {
|
|
57
|
+
user_drop_response response{ ctx };
|
|
58
|
+
if (!response.ctx.ec) {
|
|
59
59
|
switch (encoded.status_code) {
|
|
60
60
|
case 200:
|
|
61
61
|
break;
|
|
62
62
|
case 404:
|
|
63
|
-
response.ec = std::make_error_code(error::management_errc::user_not_found);
|
|
63
|
+
response.ctx.ec = std::make_error_code(error::management_errc::user_not_found);
|
|
64
64
|
break;
|
|
65
65
|
default:
|
|
66
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
66
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -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.
|
|
@@ -27,8 +27,7 @@ namespace couchbase::operations
|
|
|
27
27
|
{
|
|
28
28
|
|
|
29
29
|
struct user_get_response {
|
|
30
|
-
|
|
31
|
-
std::error_code ec;
|
|
30
|
+
error_context::http ctx;
|
|
32
31
|
rbac::user_and_metadata user{};
|
|
33
32
|
};
|
|
34
33
|
|
|
@@ -36,6 +35,7 @@ struct user_get_request {
|
|
|
36
35
|
using response_type = user_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::management;
|
|
41
41
|
|
|
@@ -54,20 +54,24 @@ struct user_get_request {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
user_get_response
|
|
57
|
-
make_response(
|
|
57
|
+
make_response(error_context::http&& ctx, user_get_request&, user_get_request::encoded_response_type&& encoded)
|
|
58
58
|
{
|
|
59
|
-
user_get_response response{
|
|
60
|
-
if (!ec) {
|
|
59
|
+
user_get_response response{ ctx };
|
|
60
|
+
if (!response.ctx.ec) {
|
|
61
61
|
switch (encoded.status_code) {
|
|
62
62
|
case 200: {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
try {
|
|
64
|
+
response.user = tao::json::from_string(encoded.body).as<rbac::user_and_metadata>();
|
|
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
|
+
}
|
|
65
69
|
} break;
|
|
66
70
|
case 404:
|
|
67
|
-
response.ec = std::make_error_code(error::management_errc::user_not_found);
|
|
71
|
+
response.ctx.ec = std::make_error_code(error::management_errc::user_not_found);
|
|
68
72
|
break;
|
|
69
73
|
default:
|
|
70
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
74
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
71
75
|
break;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -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.
|
|
@@ -27,8 +27,7 @@ namespace couchbase::operations
|
|
|
27
27
|
{
|
|
28
28
|
|
|
29
29
|
struct user_get_all_response {
|
|
30
|
-
|
|
31
|
-
std::error_code ec;
|
|
30
|
+
error_context::http ctx;
|
|
32
31
|
std::vector<rbac::user_and_metadata> users{};
|
|
33
32
|
};
|
|
34
33
|
|
|
@@ -36,6 +35,7 @@ struct user_get_all_request {
|
|
|
36
35
|
using response_type = user_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::management;
|
|
41
41
|
|
|
@@ -53,17 +53,23 @@ struct user_get_all_request {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
user_get_all_response
|
|
56
|
-
make_response(
|
|
56
|
+
make_response(error_context::http&& ctx, user_get_all_request&, user_get_all_request::encoded_response_type&& encoded)
|
|
57
57
|
{
|
|
58
|
-
user_get_all_response response{
|
|
59
|
-
if (!ec) {
|
|
58
|
+
user_get_all_response response{ ctx };
|
|
59
|
+
if (!response.ctx.ec) {
|
|
60
60
|
if (encoded.status_code == 200) {
|
|
61
|
-
tao::json::value payload
|
|
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
|
for (const auto& entry : payload.get_array()) {
|
|
63
69
|
response.users.emplace_back(entry.as<rbac::user_and_metadata>());
|
|
64
70
|
}
|
|
65
71
|
} else {
|
|
66
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
72
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
return response;
|
|
@@ -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.
|
|
@@ -31,8 +31,7 @@ namespace couchbase::operations
|
|
|
31
31
|
{
|
|
32
32
|
|
|
33
33
|
struct user_upsert_response {
|
|
34
|
-
|
|
35
|
-
std::error_code ec;
|
|
34
|
+
error_context::http ctx;
|
|
36
35
|
std::vector<std::string> errors{};
|
|
37
36
|
};
|
|
38
37
|
|
|
@@ -40,6 +39,7 @@ struct user_upsert_request {
|
|
|
40
39
|
using response_type = user_upsert_response;
|
|
41
40
|
using encoded_request_type = io::http_request;
|
|
42
41
|
using encoded_response_type = io::http_response;
|
|
42
|
+
using error_context_type = error_context::http;
|
|
43
43
|
|
|
44
44
|
static const inline service_type type = service_type::management;
|
|
45
45
|
|
|
@@ -98,16 +98,22 @@ struct user_upsert_request {
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
user_upsert_response
|
|
101
|
-
make_response(
|
|
101
|
+
make_response(error_context::http&& ctx, user_upsert_request&, user_upsert_request::encoded_response_type&& encoded)
|
|
102
102
|
{
|
|
103
|
-
user_upsert_response response{
|
|
104
|
-
if (!ec) {
|
|
103
|
+
user_upsert_response response{ ctx };
|
|
104
|
+
if (!response.ctx.ec) {
|
|
105
105
|
switch (encoded.status_code) {
|
|
106
106
|
case 200:
|
|
107
107
|
break;
|
|
108
108
|
case 400: {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
tao::json::value payload{};
|
|
110
|
+
try {
|
|
111
|
+
payload = tao::json::from_string(encoded.body);
|
|
112
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
|
113
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
|
114
|
+
return response;
|
|
115
|
+
}
|
|
116
|
+
response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
|
|
111
117
|
const auto* errors = payload.find("errors");
|
|
112
118
|
if (errors != nullptr && errors->is_object()) {
|
|
113
119
|
for (const auto& entry : errors->get_object()) {
|
|
@@ -116,7 +122,7 @@ make_response(std::error_code ec, user_upsert_request& request, user_upsert_requ
|
|
|
116
122
|
}
|
|
117
123
|
} break;
|
|
118
124
|
default:
|
|
119
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
125
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
120
126
|
break;
|
|
121
127
|
}
|
|
122
128
|
}
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
namespace couchbase::operations
|
|
23
23
|
{
|
|
24
24
|
struct view_index_drop_response {
|
|
25
|
-
|
|
26
|
-
std::error_code ec;
|
|
25
|
+
error_context::http ctx;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
struct view_index_drop_request {
|
|
30
29
|
using response_type = view_index_drop_response;
|
|
31
30
|
using encoded_request_type = io::http_request;
|
|
32
31
|
using encoded_response_type = io::http_response;
|
|
32
|
+
using error_context_type = error_context::http;
|
|
33
33
|
|
|
34
34
|
static const inline service_type type = service_type::views;
|
|
35
35
|
|
|
@@ -50,16 +50,16 @@ struct view_index_drop_request {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
view_index_drop_response
|
|
53
|
-
make_response(
|
|
53
|
+
make_response(error_context::http&& ctx, view_index_drop_request&, view_index_drop_request::encoded_response_type&& encoded)
|
|
54
54
|
{
|
|
55
|
-
view_index_drop_response response{
|
|
56
|
-
if (!ec) {
|
|
55
|
+
view_index_drop_response response{ ctx };
|
|
56
|
+
if (!response.ctx.ec) {
|
|
57
57
|
if (encoded.status_code == 200) {
|
|
58
58
|
|
|
59
59
|
} else if (encoded.status_code == 404) {
|
|
60
|
-
response.ec = std::make_error_code(error::view_errc::design_document_not_found);
|
|
60
|
+
response.ctx.ec = std::make_error_code(error::view_errc::design_document_not_found);
|
|
61
61
|
} else {
|
|
62
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
62
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
return response;
|
|
@@ -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.
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
namespace couchbase::operations
|
|
24
24
|
{
|
|
25
25
|
struct view_index_get_response {
|
|
26
|
-
|
|
27
|
-
std::error_code ec;
|
|
26
|
+
error_context::http ctx;
|
|
28
27
|
design_document document{};
|
|
29
28
|
};
|
|
30
29
|
|
|
@@ -32,6 +31,7 @@ struct view_index_get_request {
|
|
|
32
31
|
using response_type = view_index_get_response;
|
|
33
32
|
using encoded_request_type = io::http_request;
|
|
34
33
|
using encoded_response_type = io::http_response;
|
|
34
|
+
using error_context_type = error_context::http;
|
|
35
35
|
|
|
36
36
|
static const inline service_type type = service_type::views;
|
|
37
37
|
|
|
@@ -52,15 +52,21 @@ struct view_index_get_request {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
view_index_get_response
|
|
55
|
-
make_response(
|
|
55
|
+
make_response(error_context::http&& ctx, view_index_get_request& request, view_index_get_request::encoded_response_type&& encoded)
|
|
56
56
|
{
|
|
57
|
-
view_index_get_response response{
|
|
58
|
-
if (!ec) {
|
|
57
|
+
view_index_get_response response{ ctx };
|
|
58
|
+
if (!response.ctx.ec) {
|
|
59
59
|
if (encoded.status_code == 200) {
|
|
60
60
|
response.document.name = request.document_name;
|
|
61
61
|
response.document.ns = request.name_space;
|
|
62
62
|
|
|
63
|
-
|
|
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
|
+
}
|
|
64
70
|
const auto* views = payload.find("views");
|
|
65
71
|
if (views != nullptr && views->is_object()) {
|
|
66
72
|
for (const auto& view_entry : views->get_object()) {
|
|
@@ -80,9 +86,9 @@ make_response(std::error_code ec, view_index_get_request& request, view_index_ge
|
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
} else if (encoded.status_code == 404) {
|
|
83
|
-
response.ec = std::make_error_code(error::view_errc::design_document_not_found);
|
|
89
|
+
response.ctx.ec = std::make_error_code(error::view_errc::design_document_not_found);
|
|
84
90
|
} else {
|
|
85
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
91
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
return response;
|
|
@@ -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.
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
namespace couchbase::operations
|
|
24
24
|
{
|
|
25
25
|
struct view_index_get_all_response {
|
|
26
|
-
|
|
27
|
-
std::error_code ec;
|
|
26
|
+
error_context::http ctx;
|
|
28
27
|
std::vector<design_document> design_documents{};
|
|
29
28
|
};
|
|
30
29
|
|
|
@@ -32,6 +31,7 @@ struct view_index_get_all_request {
|
|
|
32
31
|
using response_type = view_index_get_all_response;
|
|
33
32
|
using encoded_request_type = io::http_request;
|
|
34
33
|
using encoded_response_type = io::http_response;
|
|
34
|
+
using error_context_type = error_context::http;
|
|
35
35
|
|
|
36
36
|
static const inline service_type type = service_type::management;
|
|
37
37
|
|
|
@@ -50,12 +50,18 @@ struct view_index_get_all_request {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
view_index_get_all_response
|
|
53
|
-
make_response(
|
|
53
|
+
make_response(error_context::http&& ctx, view_index_get_all_request& request, view_index_get_all_request::encoded_response_type&& encoded)
|
|
54
54
|
{
|
|
55
|
-
view_index_get_all_response response{
|
|
56
|
-
if (!ec) {
|
|
55
|
+
view_index_get_all_response response{ ctx };
|
|
56
|
+
if (!response.ctx.ec) {
|
|
57
57
|
if (encoded.status_code == 200) {
|
|
58
|
-
|
|
58
|
+
tao::json::value payload{};
|
|
59
|
+
try {
|
|
60
|
+
payload = tao::json::from_string(encoded.body);
|
|
61
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
|
62
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
59
65
|
auto* rows = payload.find("rows");
|
|
60
66
|
if (rows != nullptr && rows->is_array()) {
|
|
61
67
|
for (const auto& entry : rows->get_array()) {
|
|
@@ -115,9 +121,9 @@ make_response(std::error_code ec, view_index_get_all_request& request, view_inde
|
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
} else if (encoded.status_code == 404) {
|
|
118
|
-
response.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
|
124
|
+
response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
|
119
125
|
} else {
|
|
120
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
126
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
return response;
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
namespace couchbase::operations
|
|
23
23
|
{
|
|
24
24
|
struct view_index_upsert_response {
|
|
25
|
-
|
|
26
|
-
std::error_code ec;
|
|
25
|
+
error_context::http ctx;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
struct view_index_upsert_request {
|
|
30
29
|
using response_type = view_index_upsert_response;
|
|
31
30
|
using encoded_request_type = io::http_request;
|
|
32
31
|
using encoded_response_type = io::http_response;
|
|
32
|
+
using error_context_type = error_context::http;
|
|
33
33
|
|
|
34
34
|
static const inline service_type type = service_type::views;
|
|
35
35
|
|
|
@@ -64,22 +64,22 @@ struct view_index_upsert_request {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
view_index_upsert_response
|
|
67
|
-
make_response(
|
|
67
|
+
make_response(error_context::http&& ctx, view_index_upsert_request&, view_index_upsert_request::encoded_response_type&& encoded)
|
|
68
68
|
{
|
|
69
|
-
view_index_upsert_response response{
|
|
70
|
-
if (!ec) {
|
|
69
|
+
view_index_upsert_response response{ ctx };
|
|
70
|
+
if (!response.ctx.ec) {
|
|
71
71
|
switch (encoded.status_code) {
|
|
72
72
|
case 200:
|
|
73
73
|
case 201:
|
|
74
74
|
break;
|
|
75
75
|
case 400:
|
|
76
|
-
response.ec = std::make_error_code(error::common_errc::invalid_argument);
|
|
76
|
+
response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
|
|
77
77
|
break;
|
|
78
78
|
case 404:
|
|
79
|
-
response.ec = std::make_error_code(error::view_errc::design_document_not_found);
|
|
79
|
+
response.ctx.ec = std::make_error_code(error::view_errc::design_document_not_found);
|
|
80
80
|
break;
|
|
81
81
|
default:
|
|
82
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
82
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
return response;
|
data/ext/couchbase/origin.hxx
CHANGED
|
@@ -63,7 +63,7 @@ log_backtrace()
|
|
|
63
63
|
{
|
|
64
64
|
static const char format_str[] = "Call stack:\n%s";
|
|
65
65
|
|
|
66
|
-
char buffer[
|
|
66
|
+
char buffer[8192];
|
|
67
67
|
if (print_backtrace_to_buffer(" ", buffer, sizeof(buffer))) {
|
|
68
68
|
spdlog::critical("Call stack:\n{}", buffer);
|
|
69
69
|
} else {
|
|
@@ -72,7 +72,7 @@ log_backtrace()
|
|
|
72
72
|
fprintf(stderr, format_str, "");
|
|
73
73
|
print_backtrace_to_file(stderr);
|
|
74
74
|
fflush(stderr);
|
|
75
|
-
spdlog::critical("Call stack exceeds
|
|
75
|
+
spdlog::critical("Call stack exceeds 8k, rendered to STDERR");
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -81,11 +81,15 @@ log_backtrace()
|
|
|
81
81
|
static void
|
|
82
82
|
backtrace_terminate_handler()
|
|
83
83
|
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
static bool meta_reported = false;
|
|
85
|
+
if (!meta_reported) {
|
|
86
|
+
spdlog::critical(R"(*** Fatal error encountered during exception handling (rev="{}", compiler="{}", system="{}", date="{}") ***)",
|
|
87
|
+
BACKEND_GIT_REVISION,
|
|
88
|
+
BACKEND_CXX_COMPILER,
|
|
89
|
+
BACKEND_SYSTEM,
|
|
90
|
+
BACKEND_BUILD_TIMESTAMP);
|
|
91
|
+
meta_reported = true;
|
|
92
|
+
}
|
|
89
93
|
log_handled_exception();
|
|
90
94
|
|
|
91
95
|
if (should_include_backtrace) {
|
|
@@ -94,7 +98,7 @@ backtrace_terminate_handler()
|
|
|
94
98
|
|
|
95
99
|
// Chain to the default handler if available (as it may be able to print
|
|
96
100
|
// other useful information on why we were told to terminate).
|
|
97
|
-
if (default_terminate_handler != nullptr) {
|
|
101
|
+
if (default_terminate_handler != nullptr && default_terminate_handler != backtrace_terminate_handler) {
|
|
98
102
|
default_terminate_handler();
|
|
99
103
|
}
|
|
100
104
|
|