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.
|
@@ -27,8 +27,7 @@ namespace couchbase::operations
|
|
27
27
|
{
|
28
28
|
|
29
29
|
struct scope_create_response {
|
30
|
-
|
31
|
-
std::error_code ec;
|
30
|
+
error_context::http ctx;
|
32
31
|
std::uint64_t uid{ 0 };
|
33
32
|
};
|
34
33
|
|
@@ -36,6 +35,7 @@ struct scope_create_request {
|
|
36
35
|
using response_type = scope_create_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
|
|
@@ -55,31 +55,37 @@ struct scope_create_request {
|
|
55
55
|
};
|
56
56
|
|
57
57
|
scope_create_response
|
58
|
-
make_response(
|
58
|
+
make_response(error_context::http&& ctx, scope_create_request&, scope_create_request::encoded_response_type&& encoded)
|
59
59
|
{
|
60
|
-
scope_create_response response{
|
61
|
-
if (!ec) {
|
60
|
+
scope_create_response response{ ctx };
|
61
|
+
if (!response.ctx.ec) {
|
62
62
|
switch (encoded.status_code) {
|
63
63
|
case 400:
|
64
64
|
if (encoded.body.find("Not allowed on this version") != std::string::npos) {
|
65
|
-
response.ec = std::make_error_code(error::common_errc::unsupported_operation);
|
65
|
+
response.ctx.ec = std::make_error_code(error::common_errc::unsupported_operation);
|
66
66
|
} else if (encoded.body.find("Scope with this name already exists") != std::string::npos) {
|
67
|
-
response.ec = std::make_error_code(error::management_errc::scope_exists);
|
67
|
+
response.ctx.ec = std::make_error_code(error::management_errc::scope_exists);
|
68
68
|
} else if (encoded.body.find("Not allowed on this version of cluster") != std::string::npos) {
|
69
|
-
response.ec = std::make_error_code(error::common_errc::feature_not_available);
|
69
|
+
response.ctx.ec = std::make_error_code(error::common_errc::feature_not_available);
|
70
70
|
} else {
|
71
|
-
response.ec = std::make_error_code(error::common_errc::invalid_argument);
|
71
|
+
response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
|
72
72
|
}
|
73
73
|
break;
|
74
74
|
case 404:
|
75
|
-
response.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
75
|
+
response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
76
76
|
break;
|
77
77
|
case 200: {
|
78
|
-
tao::json::value payload
|
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
|
+
}
|
79
85
|
response.uid = std::stoull(payload.at("uid").get_string(), 0, 16);
|
80
86
|
} break;
|
81
87
|
default:
|
82
|
-
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);
|
83
89
|
break;
|
84
90
|
}
|
85
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.
|
@@ -27,8 +27,7 @@ namespace couchbase::operations
|
|
27
27
|
{
|
28
28
|
|
29
29
|
struct scope_drop_response {
|
30
|
-
|
31
|
-
std::error_code ec;
|
30
|
+
error_context::http ctx;
|
32
31
|
std::uint64_t uid{ 0 };
|
33
32
|
};
|
34
33
|
|
@@ -36,6 +35,7 @@ struct scope_drop_request {
|
|
36
35
|
using response_type = scope_drop_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,27 +53,33 @@ struct scope_drop_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
scope_drop_response
|
56
|
-
make_response(
|
56
|
+
make_response(error_context::http&& ctx, scope_drop_request&, scope_drop_request::encoded_response_type&& encoded)
|
57
57
|
{
|
58
|
-
scope_drop_response response{
|
59
|
-
if (!ec) {
|
58
|
+
scope_drop_response response{ ctx };
|
59
|
+
if (!response.ctx.ec) {
|
60
60
|
switch (encoded.status_code) {
|
61
61
|
case 400:
|
62
|
-
response.ec = std::make_error_code(error::common_errc::unsupported_operation);
|
62
|
+
response.ctx.ec = std::make_error_code(error::common_errc::unsupported_operation);
|
63
63
|
break;
|
64
64
|
case 404:
|
65
65
|
if (encoded.body.find("Scope with this name is not found") != std::string::npos) {
|
66
|
-
response.ec = std::make_error_code(error::common_errc::scope_not_found);
|
66
|
+
response.ctx.ec = std::make_error_code(error::common_errc::scope_not_found);
|
67
67
|
} else {
|
68
|
-
response.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
68
|
+
response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
69
69
|
}
|
70
70
|
break;
|
71
71
|
case 200: {
|
72
|
-
tao::json::value payload
|
72
|
+
tao::json::value payload{};
|
73
|
+
try {
|
74
|
+
payload = tao::json::from_string(encoded.body);
|
75
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
76
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
77
|
+
return response;
|
78
|
+
}
|
73
79
|
response.uid = std::stoull(payload.at("uid").get_string(), 0, 16);
|
74
80
|
} break;
|
75
81
|
default:
|
76
|
-
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);
|
77
83
|
break;
|
78
84
|
}
|
79
85
|
}
|
@@ -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 scope_get_all_response {
|
30
|
-
|
31
|
-
std::error_code ec;
|
30
|
+
error_context::http ctx;
|
32
31
|
collections_manifest manifest{};
|
33
32
|
};
|
34
33
|
|
@@ -36,6 +35,7 @@ struct scope_get_all_request {
|
|
36
35
|
using response_type = scope_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
|
|
@@ -52,22 +52,27 @@ struct scope_get_all_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
scope_get_all_response
|
55
|
-
make_response(
|
55
|
+
make_response(error_context::http&& ctx, scope_get_all_request&, scope_get_all_request::encoded_response_type&& encoded)
|
56
56
|
{
|
57
|
-
scope_get_all_response response{
|
58
|
-
if (!ec) {
|
57
|
+
scope_get_all_response response{ ctx };
|
58
|
+
if (!response.ctx.ec) {
|
59
59
|
switch (encoded.status_code) {
|
60
60
|
case 400:
|
61
|
-
response.ec = std::make_error_code(error::common_errc::unsupported_operation);
|
61
|
+
response.ctx.ec = std::make_error_code(error::common_errc::unsupported_operation);
|
62
62
|
break;
|
63
63
|
case 404:
|
64
|
-
response.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
64
|
+
response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
|
65
65
|
break;
|
66
66
|
case 200:
|
67
|
-
|
67
|
+
try {
|
68
|
+
response.manifest = tao::json::from_string(encoded.body).as<collections_manifest>();
|
69
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
70
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
71
|
+
return response;
|
72
|
+
}
|
68
73
|
break;
|
69
74
|
default:
|
70
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
75
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
71
76
|
break;
|
72
77
|
}
|
73
78
|
}
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_stats_response {
|
27
|
-
|
28
|
-
std::error_code ec;
|
27
|
+
error_context::http ctx;
|
29
28
|
std::string stats{};
|
30
29
|
};
|
31
30
|
|
@@ -33,6 +32,7 @@ struct search_index_stats_request {
|
|
33
32
|
using response_type = search_index_stats_response;
|
34
33
|
using encoded_request_type = io::http_request;
|
35
34
|
using encoded_response_type = io::http_response;
|
35
|
+
using error_context_type = error_context::http;
|
36
36
|
|
37
37
|
static const inline service_type type = service_type::search;
|
38
38
|
|
@@ -48,10 +48,10 @@ struct search_index_stats_request {
|
|
48
48
|
};
|
49
49
|
|
50
50
|
search_index_stats_response
|
51
|
-
make_response(
|
51
|
+
make_response(error_context::http&& ctx, search_index_stats_request&, search_index_stats_request::encoded_response_type&& encoded)
|
52
52
|
{
|
53
|
-
search_index_stats_response response{
|
54
|
-
if (!ec) {
|
53
|
+
search_index_stats_response response{ ctx };
|
54
|
+
if (!response.ctx.ec) {
|
55
55
|
response.stats = encoded.body;
|
56
56
|
}
|
57
57
|
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.
|
@@ -24,8 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_analyze_document_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 analysis{};
|
@@ -35,6 +34,7 @@ struct search_index_analyze_document_request {
|
|
35
34
|
using response_type = search_index_analyze_document_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
|
|
@@ -56,14 +56,20 @@ struct search_index_analyze_document_request {
|
|
56
56
|
};
|
57
57
|
|
58
58
|
search_index_analyze_document_response
|
59
|
-
make_response(
|
60
|
-
search_index_analyze_document_request
|
59
|
+
make_response(error_context::http&& ctx,
|
60
|
+
search_index_analyze_document_request&,
|
61
61
|
search_index_analyze_document_request::encoded_response_type&& encoded)
|
62
62
|
{
|
63
|
-
search_index_analyze_document_response response{
|
64
|
-
if (!ec) {
|
63
|
+
search_index_analyze_document_response response{ ctx };
|
64
|
+
if (!response.ctx.ec) {
|
65
65
|
if (encoded.status_code == 200) {
|
66
|
-
|
66
|
+
tao::json::value payload{};
|
67
|
+
try {
|
68
|
+
payload = tao::json::from_string(encoded.body);
|
69
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
70
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
71
|
+
return response;
|
72
|
+
}
|
67
73
|
response.status = payload.at("status").get_string();
|
68
74
|
if (response.status == "ok") {
|
69
75
|
response.analysis = tao::json::to_string(payload.at("analyzed"));
|
@@ -71,21 +77,27 @@ make_response(std::error_code ec,
|
|
71
77
|
}
|
72
78
|
} else if (encoded.status_code == 400) {
|
73
79
|
if (encoded.body.find("no indexName:") != std::string::npos) {
|
74
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
80
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
81
|
+
return response;
|
82
|
+
}
|
83
|
+
tao::json::value payload{};
|
84
|
+
try {
|
85
|
+
payload = tao::json::from_string(encoded.body);
|
86
|
+
} catch (tao::json::pegtl::parse_error& e) {
|
87
|
+
response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
|
75
88
|
return response;
|
76
89
|
}
|
77
|
-
auto payload = tao::json::from_string(encoded.body);
|
78
90
|
response.status = payload.at("status").get_string();
|
79
91
|
response.error = payload.at("error").get_string();
|
80
92
|
if (response.error.find("index not found") != std::string::npos) {
|
81
|
-
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
93
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
|
82
94
|
return response;
|
83
95
|
} else if (response.error.find("index with the same name already exists") != std::string::npos) {
|
84
|
-
response.ec = std::make_error_code(error::common_errc::index_exists);
|
96
|
+
response.ctx.ec = std::make_error_code(error::common_errc::index_exists);
|
85
97
|
return response;
|
86
98
|
}
|
87
99
|
}
|
88
|
-
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
100
|
+
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
89
101
|
}
|
90
102
|
return response;
|
91
103
|
}
|
@@ -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_ingest_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_ingest_request {
|
|
34
33
|
using response_type = search_index_control_ingest_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_ingest_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
search_index_control_ingest_response
|
55
|
-
make_response(
|
56
|
-
search_index_control_ingest_request
|
55
|
+
make_response(error_context::http&& ctx,
|
56
|
+
search_index_control_ingest_request&,
|
57
57
|
search_index_control_ingest_request::encoded_response_type&& encoded)
|
58
58
|
{
|
59
|
-
search_index_control_ingest_response response{
|
60
|
-
if (!ec) {
|
59
|
+
search_index_control_ingest_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_control_plan_freeze_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_plan_freeze_request {
|
|
34
33
|
using response_type = search_index_control_plan_freeze_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_plan_freeze_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
search_index_control_plan_freeze_response
|
55
|
-
make_response(
|
56
|
-
search_index_control_plan_freeze_request
|
55
|
+
make_response(error_context::http&& ctx,
|
56
|
+
search_index_control_plan_freeze_request&,
|
57
57
|
search_index_control_plan_freeze_request::encoded_response_type&& encoded)
|
58
58
|
{
|
59
|
-
search_index_control_plan_freeze_response response{
|
60
|
-
if (!ec) {
|
59
|
+
search_index_control_plan_freeze_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
|
}
|