couchbase 3.1.1 → 3.2.0
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 -1
- data/ext/build_version.hxx.in +1 -1
- data/ext/cmake/Testing.cmake +1 -0
- data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
- data/ext/cmake/VersionInfo.cmake +3 -0
- data/ext/couchbase/bucket.hxx +47 -28
- data/ext/couchbase/cbsasl/client.h +1 -1
- data/ext/couchbase/cbsasl/context.cc +1 -1
- data/ext/couchbase/cbsasl/context.h +3 -3
- data/ext/couchbase/cbsasl/mechanism.cc +5 -8
- data/ext/couchbase/cbsasl/mechanism.h +1 -4
- data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
- data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
- data/ext/couchbase/cluster.hxx +40 -22
- data/ext/couchbase/cluster_options.hxx +7 -1
- data/ext/couchbase/configuration.hxx +37 -16
- data/ext/couchbase/couchbase.cxx +1145 -291
- data/ext/couchbase/error_map.hxx +1 -1
- data/ext/couchbase/errors.hxx +25 -17
- data/ext/couchbase/io/dns_client.hxx +3 -3
- data/ext/couchbase/io/dns_codec.hxx +4 -5
- data/ext/couchbase/io/dns_config.hxx +5 -6
- data/ext/couchbase/io/dns_message.hxx +3 -3
- data/ext/couchbase/io/http_command.hxx +70 -35
- data/ext/couchbase/io/http_session.hxx +4 -3
- data/ext/couchbase/io/http_session_manager.hxx +28 -19
- data/ext/couchbase/io/mcbp_command.hxx +51 -19
- data/ext/couchbase/io/mcbp_context.hxx +1 -1
- data/ext/couchbase/io/mcbp_parser.hxx +4 -4
- data/ext/couchbase/io/mcbp_session.hxx +91 -101
- data/ext/couchbase/io/query_cache.hxx +2 -2
- data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
- data/ext/couchbase/io/retry_reason.hxx +2 -2
- data/ext/couchbase/io/retry_strategy.hxx +1 -6
- data/ext/couchbase/io/streams.hxx +7 -7
- data/ext/couchbase/metrics/logging_meter.hxx +228 -0
- data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
- data/ext/couchbase/metrics/meter.hxx +49 -0
- data/ext/couchbase/metrics/noop_meter.hxx +43 -0
- data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
- data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
- data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
- data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
- data/ext/couchbase/operations/analytics_link.hxx +39 -0
- data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
- data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
- data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
- data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
- data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
- data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
- data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
- data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
- data/ext/couchbase/operations/bucket_create.hxx +8 -8
- data/ext/couchbase/operations/bucket_drop.hxx +5 -5
- data/ext/couchbase/operations/bucket_flush.hxx +5 -5
- data/ext/couchbase/operations/bucket_get.hxx +7 -7
- data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
- data/ext/couchbase/operations/bucket_settings.hxx +40 -49
- data/ext/couchbase/operations/bucket_update.hxx +8 -8
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
- data/ext/couchbase/operations/collection_create.hxx +11 -11
- data/ext/couchbase/operations/collection_drop.hxx +12 -10
- data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
- data/ext/couchbase/operations/design_document.hxx +2 -2
- data/ext/couchbase/operations/document_analytics.hxx +29 -36
- data/ext/couchbase/operations/document_append.hxx +3 -3
- data/ext/couchbase/operations/document_decrement.hxx +3 -3
- data/ext/couchbase/operations/document_exists.hxx +2 -2
- data/ext/couchbase/operations/document_get.hxx +3 -3
- data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
- data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
- data/ext/couchbase/operations/document_get_projected.hxx +10 -11
- data/ext/couchbase/operations/document_increment.hxx +3 -3
- data/ext/couchbase/operations/document_insert.hxx +3 -3
- data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
- data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
- data/ext/couchbase/operations/document_prepend.hxx +3 -3
- data/ext/couchbase/operations/document_query.hxx +39 -41
- data/ext/couchbase/operations/document_remove.hxx +3 -3
- data/ext/couchbase/operations/document_replace.hxx +3 -3
- data/ext/couchbase/operations/document_search.hxx +56 -61
- data/ext/couchbase/operations/document_touch.hxx +3 -3
- data/ext/couchbase/operations/document_unlock.hxx +3 -3
- data/ext/couchbase/operations/document_upsert.hxx +3 -3
- data/ext/couchbase/operations/document_view.hxx +23 -23
- data/ext/couchbase/operations/group_drop.hxx +5 -5
- data/ext/couchbase/operations/group_get.hxx +7 -7
- data/ext/couchbase/operations/group_get_all.hxx +6 -6
- data/ext/couchbase/operations/group_upsert.hxx +11 -11
- data/ext/couchbase/operations/http_noop.hxx +6 -6
- data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
- data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
- data/ext/couchbase/operations/query_index_create.hxx +10 -8
- data/ext/couchbase/operations/query_index_drop.hxx +8 -8
- data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
- data/ext/couchbase/operations/rbac.hxx +40 -63
- data/ext/couchbase/operations/role_get_all.hxx +6 -6
- data/ext/couchbase/operations/scope_create.hxx +10 -10
- data/ext/couchbase/operations/scope_drop.hxx +9 -9
- data/ext/couchbase/operations/scope_get_all.hxx +8 -8
- data/ext/couchbase/operations/search_get_stats.hxx +5 -3
- data/ext/couchbase/operations/search_index.hxx +6 -15
- data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
- data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
- data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
- data/ext/couchbase/operations/search_index_drop.hxx +11 -9
- data/ext/couchbase/operations/search_index_get.hxx +11 -9
- data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
- data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
- data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
- data/ext/couchbase/operations/user_drop.hxx +5 -5
- data/ext/couchbase/operations/user_get.hxx +7 -7
- data/ext/couchbase/operations/user_get_all.hxx +6 -6
- data/ext/couchbase/operations/user_upsert.hxx +9 -9
- data/ext/couchbase/operations/view_index_drop.hxx +10 -10
- data/ext/couchbase/operations/view_index_get.hxx +13 -15
- data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
- data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
- data/ext/couchbase/operations.hxx +4 -0
- data/ext/couchbase/origin.hxx +14 -10
- data/ext/couchbase/platform/backtrace.c +1 -1
- data/ext/couchbase/platform/base64.cc +5 -5
- data/ext/couchbase/platform/base64.h +2 -5
- data/ext/couchbase/protocol/client_opcode.hxx +7 -4
- data/ext/couchbase/protocol/client_request.hxx +2 -2
- data/ext/couchbase/protocol/client_response.hxx +41 -16
- data/ext/couchbase/protocol/cmd_append.hxx +17 -16
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
- data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
- data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
- data/ext/couchbase/protocol/cmd_get.hxx +11 -14
- data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
- data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
- data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
- data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
- data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
- data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
- data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
- data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
- data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
- data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
- data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
- data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
- data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
- data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
- data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
- data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
- data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
- data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
- data/ext/couchbase/protocol/datatype.hxx +3 -3
- data/ext/couchbase/protocol/durability_level.hxx +2 -2
- data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
- data/ext/couchbase/protocol/hello_feature.hxx +2 -2
- data/ext/couchbase/protocol/magic.hxx +2 -2
- data/ext/couchbase/protocol/server_opcode.hxx +2 -2
- data/ext/couchbase/protocol/server_request.hxx +1 -1
- data/ext/couchbase/protocol/status.hxx +4 -7
- data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
- data/ext/couchbase/service_type.hxx +4 -4
- data/ext/couchbase/tracing/constants.hxx +261 -0
- data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
- data/ext/couchbase/tracing/request_tracer.hxx +77 -0
- data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
- data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
- data/ext/couchbase/utils/byteswap.hxx +1 -1
- data/ext/couchbase/utils/connection_string.hxx +21 -1
- data/ext/couchbase/utils/name_codec.hxx +41 -0
- data/ext/couchbase/utils/url_codec.hxx +236 -0
- data/ext/couchbase/version.hxx +1 -1
- data/ext/test/CMakeLists.txt +1 -0
- data/ext/test/test_native_trivial_query.cxx +60 -0
- data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
- data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
- data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
- data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
- data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
- data/lib/couchbase/cluster.rb +1 -0
- data/lib/couchbase/errors.rb +3 -0
- data/lib/couchbase/management/analytics_index_manager.rb +920 -226
- data/lib/couchbase/management/bucket_manager.rb +207 -69
- data/lib/couchbase/management/collection_manager.rb +173 -61
- data/lib/couchbase/management/query_index_manager.rb +357 -169
- data/lib/couchbase/options.rb +75 -3
- data/lib/couchbase/scope.rb +102 -0
- data/lib/couchbase/utils/time.rb +4 -0
- data/lib/couchbase/version.rb +6 -6
- metadata +50 -7
@@ -44,7 +44,7 @@ struct bucket_update_request {
|
|
44
44
|
|
45
45
|
bucket_settings bucket{};
|
46
46
|
|
47
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
47
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
48
48
|
{
|
49
49
|
encoded.method = "POST";
|
50
50
|
encoded.path = fmt::format("/pools/default/buckets/{}", bucket.name);
|
@@ -105,23 +105,23 @@ struct bucket_update_request {
|
|
105
105
|
};
|
106
106
|
|
107
107
|
bucket_update_response
|
108
|
-
make_response(error_context::http&& ctx, bucket_update_request& /* request */, bucket_update_request::encoded_response_type&& encoded)
|
108
|
+
make_response(error_context::http&& ctx, const bucket_update_request& /* request */, bucket_update_request::encoded_response_type&& encoded)
|
109
109
|
{
|
110
|
-
bucket_update_response response{ ctx };
|
110
|
+
bucket_update_response response{ std::move(ctx) };
|
111
111
|
if (!response.ctx.ec) {
|
112
112
|
switch (encoded.status_code) {
|
113
113
|
case 404:
|
114
|
-
response.ctx.ec =
|
114
|
+
response.ctx.ec = error::common_errc::bucket_not_found;
|
115
115
|
break;
|
116
116
|
case 400: {
|
117
117
|
tao::json::value payload{};
|
118
118
|
try {
|
119
119
|
payload = tao::json::from_string(encoded.body);
|
120
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
121
|
-
response.ctx.ec =
|
120
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
121
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
122
122
|
return response;
|
123
123
|
}
|
124
|
-
response.ctx.ec =
|
124
|
+
response.ctx.ec = error::common_errc::invalid_argument;
|
125
125
|
auto* errors = payload.find("errors");
|
126
126
|
if (errors != nullptr) {
|
127
127
|
std::vector<std::string> error_list{};
|
@@ -137,7 +137,7 @@ make_response(error_context::http&& ctx, bucket_update_request& /* request */, b
|
|
137
137
|
case 202:
|
138
138
|
break;
|
139
139
|
default:
|
140
|
-
response.ctx.ec =
|
140
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
141
141
|
break;
|
142
142
|
}
|
143
143
|
}
|
@@ -39,7 +39,7 @@ struct cluster_developer_preview_enable_request {
|
|
39
39
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
40
40
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
41
|
|
42
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
42
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
43
43
|
{
|
44
44
|
encoded.method = "POST";
|
45
45
|
encoded.headers["content-type"] = "application/x-www-form-urlencoded";
|
@@ -50,13 +50,13 @@ struct cluster_developer_preview_enable_request {
|
|
50
50
|
};
|
51
51
|
|
52
52
|
cluster_developer_preview_enable_response
|
53
|
-
make_response(error_context::http&& ctx,
|
53
|
+
make_response(error_context::http&& ctx,
|
54
|
+
const cluster_developer_preview_enable_request& /* request */,
|
55
|
+
scope_get_all_request::encoded_response_type&& encoded)
|
54
56
|
{
|
55
|
-
cluster_developer_preview_enable_response response{ ctx };
|
56
|
-
if (!response.ctx.ec) {
|
57
|
-
|
58
|
-
response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
59
|
-
}
|
57
|
+
cluster_developer_preview_enable_response response{ std::move(ctx) };
|
58
|
+
if (!response.ctx.ec && encoded.status_code != 200) {
|
59
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
60
60
|
}
|
61
61
|
return response;
|
62
62
|
}
|
@@ -46,7 +46,7 @@ struct collection_create_request {
|
|
46
46
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
47
47
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
48
48
|
|
49
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
49
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
50
50
|
{
|
51
51
|
encoded.method = "POST";
|
52
52
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections", bucket_name, scope_name);
|
@@ -61,42 +61,42 @@ struct collection_create_request {
|
|
61
61
|
|
62
62
|
collection_create_response
|
63
63
|
make_response(error_context::http&& ctx,
|
64
|
-
collection_create_request& /* request */,
|
64
|
+
const collection_create_request& /* request */,
|
65
65
|
collection_create_request::encoded_response_type&& encoded)
|
66
66
|
{
|
67
|
-
collection_create_response response{ ctx };
|
67
|
+
collection_create_response response{ std::move(ctx) };
|
68
68
|
if (!response.ctx.ec) {
|
69
69
|
switch (encoded.status_code) {
|
70
70
|
case 400: {
|
71
71
|
std::regex collection_exists("Collection with name .+ already exists");
|
72
72
|
if (std::regex_search(encoded.body, collection_exists)) {
|
73
|
-
response.ctx.ec =
|
73
|
+
response.ctx.ec = error::management_errc::collection_exists;
|
74
74
|
} else if (encoded.body.find("Not allowed on this version of cluster") != std::string::npos) {
|
75
|
-
response.ctx.ec =
|
75
|
+
response.ctx.ec = error::common_errc::feature_not_available;
|
76
76
|
} else {
|
77
|
-
response.ctx.ec =
|
77
|
+
response.ctx.ec = error::common_errc::invalid_argument;
|
78
78
|
}
|
79
79
|
} break;
|
80
80
|
case 404: {
|
81
81
|
std::regex scope_not_found("Scope with name .+ is not found");
|
82
82
|
if (std::regex_search(encoded.body, scope_not_found)) {
|
83
|
-
response.ctx.ec =
|
83
|
+
response.ctx.ec = error::common_errc::scope_not_found;
|
84
84
|
} else {
|
85
|
-
response.ctx.ec =
|
85
|
+
response.ctx.ec = error::common_errc::bucket_not_found;
|
86
86
|
}
|
87
87
|
} break;
|
88
88
|
case 200: {
|
89
89
|
tao::json::value payload{};
|
90
90
|
try {
|
91
91
|
payload = tao::json::from_string(encoded.body);
|
92
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
93
|
-
response.ctx.ec =
|
92
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
93
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
94
94
|
return response;
|
95
95
|
}
|
96
96
|
response.uid = std::stoull(payload.at("uid").get_string(), 0, 16);
|
97
97
|
} break;
|
98
98
|
default:
|
99
|
-
response.ctx.ec =
|
99
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
100
100
|
break;
|
101
101
|
}
|
102
102
|
}
|
@@ -47,7 +47,7 @@ struct collection_drop_request {
|
|
47
47
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
48
48
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
49
49
|
|
50
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
50
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
51
51
|
{
|
52
52
|
encoded.method = "DELETE";
|
53
53
|
encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections/{}", bucket_name, scope_name, collection_name);
|
@@ -56,37 +56,39 @@ struct collection_drop_request {
|
|
56
56
|
};
|
57
57
|
|
58
58
|
collection_drop_response
|
59
|
-
make_response(error_context::http&& ctx,
|
59
|
+
make_response(error_context::http&& ctx,
|
60
|
+
const collection_drop_request& /* request */,
|
61
|
+
collection_drop_request::encoded_response_type&& encoded)
|
60
62
|
{
|
61
|
-
collection_drop_response response{ ctx };
|
63
|
+
collection_drop_response response{ std::move(ctx) };
|
62
64
|
if (!response.ctx.ec) {
|
63
65
|
switch (encoded.status_code) {
|
64
66
|
case 400:
|
65
|
-
response.ctx.ec =
|
67
|
+
response.ctx.ec = error::common_errc::unsupported_operation;
|
66
68
|
break;
|
67
69
|
case 404: {
|
68
70
|
std::regex scope_not_found("Scope with name .+ is not found");
|
69
71
|
std::regex collection_not_found("Collection with name .+ is not found");
|
70
72
|
if (std::regex_search(encoded.body, collection_not_found)) {
|
71
|
-
response.ctx.ec =
|
73
|
+
response.ctx.ec = error::common_errc::collection_not_found;
|
72
74
|
} else if (std::regex_search(encoded.body, scope_not_found)) {
|
73
|
-
response.ctx.ec =
|
75
|
+
response.ctx.ec = error::common_errc::scope_not_found;
|
74
76
|
} else {
|
75
|
-
response.ctx.ec =
|
77
|
+
response.ctx.ec = error::common_errc::bucket_not_found;
|
76
78
|
}
|
77
79
|
} break;
|
78
80
|
case 200: {
|
79
81
|
tao::json::value payload{};
|
80
82
|
try {
|
81
83
|
payload = tao::json::from_string(encoded.body);
|
82
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
83
|
-
response.ctx.ec =
|
84
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
85
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
84
86
|
return response;
|
85
87
|
}
|
86
88
|
response.uid = std::stoull(payload.at("uid").get_string(), 0, 16);
|
87
89
|
} break;
|
88
90
|
default:
|
89
|
-
response.ctx.ec =
|
91
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
90
92
|
break;
|
91
93
|
}
|
92
94
|
}
|
@@ -45,7 +45,7 @@ struct collections_manifest_get_request {
|
|
45
45
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
46
46
|
io::retry_context<io::retry_strategy::best_effort> retries{ true };
|
47
47
|
|
48
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
48
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
49
49
|
{
|
50
50
|
encoded.opaque(opaque);
|
51
51
|
return {};
|
@@ -54,10 +54,10 @@ struct collections_manifest_get_request {
|
|
54
54
|
|
55
55
|
collections_manifest_get_response
|
56
56
|
make_response(error_context::key_value&& ctx,
|
57
|
-
collections_manifest_get_request
|
57
|
+
const collections_manifest_get_request& /* request */,
|
58
58
|
collections_manifest_get_request::encoded_response_type&& encoded)
|
59
59
|
{
|
60
|
-
collections_manifest_get_response response{ ctx };
|
60
|
+
collections_manifest_get_response response{ std::move(ctx) };
|
61
61
|
if (!response.ctx.ec) {
|
62
62
|
response.manifest = encoded.body().manifest();
|
63
63
|
}
|
@@ -79,18 +79,16 @@ struct traits<couchbase::operations::analytics_response_payload> {
|
|
79
79
|
result.meta_data.request_id = v.at("requestID").get_string();
|
80
80
|
result.meta_data.client_context_id = v.at("clientContextID").get_string();
|
81
81
|
result.meta_data.status = v.at("status").get_string();
|
82
|
-
|
83
|
-
if (s != nullptr) {
|
82
|
+
|
83
|
+
if (const auto* s = v.find("signature"); s != nullptr) {
|
84
84
|
result.meta_data.signature = tao::json::to_string(*s);
|
85
85
|
}
|
86
86
|
|
87
|
-
const auto p = v.find("profile");
|
88
|
-
if (p != nullptr) {
|
87
|
+
if (const auto* p = v.find("profile"); p != nullptr) {
|
89
88
|
result.meta_data.profile = tao::json::to_string(*p);
|
90
89
|
}
|
91
90
|
|
92
|
-
const auto m = v.find("metrics");
|
93
|
-
if (m != nullptr) {
|
91
|
+
if (const auto* m = v.find("metrics"); m != nullptr) {
|
94
92
|
result.meta_data.metrics.result_count = m->at("resultCount").get_unsigned();
|
95
93
|
result.meta_data.metrics.result_size = m->at("resultSize").get_unsigned();
|
96
94
|
result.meta_data.metrics.elapsed_time = m->at("elapsedTime").get_string();
|
@@ -101,8 +99,7 @@ struct traits<couchbase::operations::analytics_response_payload> {
|
|
101
99
|
result.meta_data.metrics.warning_count = m->template optional<std::uint64_t>("warningCount");
|
102
100
|
}
|
103
101
|
|
104
|
-
const auto e = v.find("errors");
|
105
|
-
if (e != nullptr) {
|
102
|
+
if (const auto* e = v.find("errors"); e != nullptr) {
|
106
103
|
std::vector<couchbase::operations::analytics_response_payload::analytics_problem> problems{};
|
107
104
|
for (auto& err : e->get_array()) {
|
108
105
|
couchbase::operations::analytics_response_payload::analytics_problem problem;
|
@@ -113,8 +110,7 @@ struct traits<couchbase::operations::analytics_response_payload> {
|
|
113
110
|
result.meta_data.errors.emplace(problems);
|
114
111
|
}
|
115
112
|
|
116
|
-
const auto w = v.find("warnings");
|
117
|
-
if (w != nullptr) {
|
113
|
+
if (const auto* w = v.find("warnings"); w != nullptr) {
|
118
114
|
std::vector<couchbase::operations::analytics_response_payload::analytics_problem> problems{};
|
119
115
|
for (auto& warn : w->get_array()) {
|
120
116
|
couchbase::operations::analytics_response_payload::analytics_problem problem;
|
@@ -124,8 +120,8 @@ struct traits<couchbase::operations::analytics_response_payload> {
|
|
124
120
|
}
|
125
121
|
result.meta_data.warnings.emplace(problems);
|
126
122
|
}
|
127
|
-
|
128
|
-
if (r != nullptr) {
|
123
|
+
|
124
|
+
if (const auto* r = v.find("results"); r != nullptr) {
|
129
125
|
result.rows.reserve(result.meta_data.metrics.result_count);
|
130
126
|
for (auto& row : r->get_array()) {
|
131
127
|
result.rows.emplace_back(tao::json::to_string(row));
|
@@ -178,13 +174,13 @@ struct analytics_request {
|
|
178
174
|
{ "client_context_id", client_context_id },
|
179
175
|
{ "timeout", fmt::format("{}ms", timeout.count()) } };
|
180
176
|
if (positional_parameters.empty()) {
|
181
|
-
for (auto&
|
182
|
-
Expects(
|
183
|
-
std::string key =
|
177
|
+
for (const auto& [name, value] : named_parameters) {
|
178
|
+
Expects(name.empty() == false);
|
179
|
+
std::string key = name;
|
184
180
|
if (key[0] != '$') {
|
185
181
|
key.insert(key.begin(), '$');
|
186
182
|
}
|
187
|
-
body[key] =
|
183
|
+
body[key] = value;
|
188
184
|
}
|
189
185
|
} else {
|
190
186
|
body["args"] = positional_parameters;
|
@@ -204,14 +200,11 @@ struct analytics_request {
|
|
204
200
|
}
|
205
201
|
if (scope_qualifier) {
|
206
202
|
body["query_context"] = scope_qualifier;
|
207
|
-
} else if (scope_name) {
|
208
|
-
|
209
|
-
// for analytics bucket_name.scope_name is quoted as a single unit (unlike n1ql query)
|
210
|
-
body["query_context"] = fmt::format("default:`{}.{}`", *bucket_name, *scope_name);
|
211
|
-
}
|
203
|
+
} else if (scope_name && bucket_name) {
|
204
|
+
body["query_context"] = fmt::format("default:`{}`.`{}`", *bucket_name, *scope_name);
|
212
205
|
}
|
213
|
-
for (auto&
|
214
|
-
body[
|
206
|
+
for (const auto& [name, value] : raw) {
|
207
|
+
body[name] = value;
|
215
208
|
}
|
216
209
|
encoded.type = type;
|
217
210
|
encoded.headers["content-type"] = "application/json";
|
@@ -232,16 +225,16 @@ struct analytics_request {
|
|
232
225
|
};
|
233
226
|
|
234
227
|
analytics_response
|
235
|
-
make_response(error_context::analytics&& ctx, analytics_request& request, analytics_request::encoded_response_type&& encoded)
|
228
|
+
make_response(error_context::analytics&& ctx, const analytics_request& request, analytics_request::encoded_response_type&& encoded)
|
236
229
|
{
|
237
|
-
analytics_response response{ ctx };
|
230
|
+
analytics_response response{ std::move(ctx) };
|
238
231
|
response.ctx.statement = request.statement;
|
239
232
|
response.ctx.parameters = request.body_str;
|
240
233
|
if (!response.ctx.ec) {
|
241
234
|
try {
|
242
235
|
response.payload = tao::json::from_string(encoded.body).as<analytics_response_payload>();
|
243
|
-
} catch (tao::json::pegtl::parse_error&
|
244
|
-
response.ctx.ec =
|
236
|
+
} catch (const tao::json::pegtl::parse_error&) {
|
237
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
245
238
|
return response;
|
246
239
|
}
|
247
240
|
Expects(response.payload.meta_data.client_context_id == request.client_context_id);
|
@@ -290,23 +283,23 @@ make_response(error_context::analytics&& ctx, analytics_request& request, analyt
|
|
290
283
|
}
|
291
284
|
}
|
292
285
|
if (compilation_failure) {
|
293
|
-
response.ctx.ec =
|
286
|
+
response.ctx.ec = error::analytics_errc::compilation_failure;
|
294
287
|
} else if (link_not_found) {
|
295
|
-
response.ctx.ec =
|
288
|
+
response.ctx.ec = error::analytics_errc::link_not_found;
|
296
289
|
} else if (dataset_not_found) {
|
297
|
-
response.ctx.ec =
|
290
|
+
response.ctx.ec = error::analytics_errc::dataset_not_found;
|
298
291
|
} else if (dataverse_not_found) {
|
299
|
-
response.ctx.ec =
|
292
|
+
response.ctx.ec = error::analytics_errc::dataverse_not_found;
|
300
293
|
} else if (server_timeout) {
|
301
|
-
response.ctx.ec =
|
294
|
+
response.ctx.ec = error::common_errc::unambiguous_timeout;
|
302
295
|
} else if (dataset_exists) {
|
303
|
-
response.ctx.ec =
|
296
|
+
response.ctx.ec = error::analytics_errc::dataset_exists;
|
304
297
|
} else if (dataverse_exists) {
|
305
|
-
response.ctx.ec =
|
298
|
+
response.ctx.ec = error::analytics_errc::dataverse_exists;
|
306
299
|
} else if (job_queue_is_full) {
|
307
|
-
response.ctx.ec =
|
300
|
+
response.ctx.ec = error::analytics_errc::job_queue_full;
|
308
301
|
} else {
|
309
|
-
response.ctx.ec =
|
302
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
310
303
|
}
|
311
304
|
}
|
312
305
|
}
|
@@ -43,7 +43,7 @@ struct append_request {
|
|
43
43
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
44
44
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
45
45
|
|
46
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
46
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
47
47
|
{
|
48
48
|
encoded.opaque(opaque);
|
49
49
|
encoded.partition(partition);
|
@@ -57,9 +57,9 @@ struct append_request {
|
|
57
57
|
};
|
58
58
|
|
59
59
|
append_response
|
60
|
-
make_response(error_context::key_value&& ctx, append_request& request, append_request::encoded_response_type&& encoded)
|
60
|
+
make_response(error_context::key_value&& ctx, const append_request& request, append_request::encoded_response_type&& encoded)
|
61
61
|
{
|
62
|
-
append_response response{ ctx };
|
62
|
+
append_response response{ std::move(ctx) };
|
63
63
|
if (!response.ctx.ec) {
|
64
64
|
response.cas = encoded.cas();
|
65
65
|
response.token = encoded.body().token();
|
@@ -47,7 +47,7 @@ struct decrement_request {
|
|
47
47
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
48
48
|
bool preserve_expiry{ false };
|
49
49
|
|
50
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
50
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
51
51
|
{
|
52
52
|
encoded.opaque(opaque);
|
53
53
|
encoded.partition(partition);
|
@@ -71,9 +71,9 @@ struct decrement_request {
|
|
71
71
|
};
|
72
72
|
|
73
73
|
decrement_response
|
74
|
-
make_response(error_context::key_value&& ctx, decrement_request& request, decrement_request::encoded_response_type&& encoded)
|
74
|
+
make_response(error_context::key_value&& ctx, const decrement_request& request, decrement_request::encoded_response_type&& encoded)
|
75
75
|
{
|
76
|
-
decrement_response response{ ctx };
|
76
|
+
decrement_response response{ std::move(ctx) };
|
77
77
|
if (!ctx.ec) {
|
78
78
|
response.cas = encoded.cas();
|
79
79
|
response.content = encoded.body().content();
|
@@ -43,7 +43,7 @@ struct exists_request {
|
|
43
43
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
44
44
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
45
45
|
|
46
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
46
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
47
47
|
{
|
48
48
|
encoded.opaque(opaque);
|
49
49
|
encoded.body().id(partition, id);
|
@@ -52,7 +52,7 @@ struct exists_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
exists_response
|
55
|
-
make_response(error_context::key_value&& ctx, exists_request& request, exists_request::encoded_response_type&& encoded)
|
55
|
+
make_response(error_context::key_value&& ctx, const exists_request& request, exists_request::encoded_response_type&& encoded)
|
56
56
|
{
|
57
57
|
exists_response response{ ctx, request.partition };
|
58
58
|
if (!ctx.ec) {
|
@@ -42,7 +42,7 @@ struct get_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
43
43
|
io::retry_context<io::retry_strategy::best_effort> retries{ true };
|
44
44
|
|
45
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
45
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
46
46
|
{
|
47
47
|
encoded.opaque(opaque);
|
48
48
|
encoded.partition(partition);
|
@@ -52,9 +52,9 @@ struct get_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
get_response
|
55
|
-
make_response(error_context::key_value&& ctx, get_request
|
55
|
+
make_response(error_context::key_value&& ctx, const get_request& /* request */, get_request::encoded_response_type&& encoded)
|
56
56
|
{
|
57
|
-
get_response response{ ctx };
|
57
|
+
get_response response{ std::move(ctx) };
|
58
58
|
if (!response.ctx.ec) {
|
59
59
|
response.value = std::move(encoded.body().value());
|
60
60
|
response.cas = encoded.cas();
|