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
@@ -20,6 +20,7 @@
|
|
20
20
|
#include <tao/json.hpp>
|
21
21
|
|
22
22
|
#include <error_context/http.hxx>
|
23
|
+
#include <utils/name_codec.hxx>
|
23
24
|
#include <version.hxx>
|
24
25
|
|
25
26
|
namespace couchbase::operations
|
@@ -54,15 +55,19 @@ struct analytics_dataset_create_request {
|
|
54
55
|
|
55
56
|
bool ignore_if_exists{ false };
|
56
57
|
|
57
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
|
58
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
58
59
|
{
|
59
60
|
std::string where_clause = condition ? fmt::format("WHERE {}", *condition) : "";
|
60
61
|
std::string if_not_exists_clause = ignore_if_exists ? "IF NOT EXISTS" : "";
|
61
62
|
|
62
63
|
tao::json::value body{
|
63
64
|
{ "statement",
|
64
|
-
fmt::format(
|
65
|
-
|
65
|
+
fmt::format("CREATE DATASET {} {}.`{}` ON `{}` {}",
|
66
|
+
if_not_exists_clause,
|
67
|
+
utils::analytics::uncompound_name(dataverse_name),
|
68
|
+
dataset_name,
|
69
|
+
bucket_name,
|
70
|
+
where_clause) },
|
66
71
|
};
|
67
72
|
encoded.headers["content-type"] = "application/json";
|
68
73
|
encoded.method = "POST";
|
@@ -74,16 +79,16 @@ struct analytics_dataset_create_request {
|
|
74
79
|
|
75
80
|
analytics_dataset_create_response
|
76
81
|
make_response(error_context::http&& ctx,
|
77
|
-
analytics_dataset_create_request& /* request */,
|
82
|
+
const analytics_dataset_create_request& /* request */,
|
78
83
|
analytics_dataset_create_request::encoded_response_type&& encoded)
|
79
84
|
{
|
80
|
-
analytics_dataset_create_response response{ ctx };
|
85
|
+
analytics_dataset_create_response response{ std::move(ctx) };
|
81
86
|
if (!response.ctx.ec) {
|
82
87
|
tao::json::value payload{};
|
83
88
|
try {
|
84
89
|
payload = tao::json::from_string(encoded.body);
|
85
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
86
|
-
response.ctx.ec =
|
90
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
91
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
87
92
|
return response;
|
88
93
|
}
|
89
94
|
response.status = payload.at("status").get_string();
|
@@ -92,8 +97,7 @@ make_response(error_context::http&& ctx,
|
|
92
97
|
bool dataset_exists = false;
|
93
98
|
bool link_not_found = false;
|
94
99
|
|
95
|
-
auto* errors = payload.find("errors");
|
96
|
-
if (errors != nullptr && errors->is_array()) {
|
100
|
+
if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
|
97
101
|
for (const auto& error : errors->get_array()) {
|
98
102
|
analytics_dataset_create_response::problem err{
|
99
103
|
error.at("code").as<std::uint32_t>(),
|
@@ -111,11 +115,11 @@ make_response(error_context::http&& ctx,
|
|
111
115
|
}
|
112
116
|
}
|
113
117
|
if (dataset_exists) {
|
114
|
-
response.ctx.ec =
|
118
|
+
response.ctx.ec = error::analytics_errc::dataset_exists;
|
115
119
|
} else if (link_not_found) {
|
116
|
-
response.ctx.ec =
|
120
|
+
response.ctx.ec = error::analytics_errc::link_not_found;
|
117
121
|
} else {
|
118
|
-
response.ctx.ec =
|
122
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
119
123
|
}
|
120
124
|
}
|
121
125
|
}
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include <tao/json.hpp>
|
21
21
|
|
22
|
-
#include <
|
22
|
+
#include <utils/name_codec.hxx>
|
23
23
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
@@ -50,12 +50,13 @@ struct analytics_dataset_drop_request {
|
|
50
50
|
|
51
51
|
bool ignore_if_does_not_exist{ false };
|
52
52
|
|
53
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
|
53
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
54
54
|
{
|
55
55
|
std::string if_exists_clause = ignore_if_does_not_exist ? "IF EXISTS" : "";
|
56
56
|
|
57
57
|
tao::json::value body{
|
58
|
-
{ "statement",
|
58
|
+
{ "statement",
|
59
|
+
fmt::format("DROP DATASET {}.`{}` {}", utils::analytics::uncompound_name(dataverse_name), dataset_name, if_exists_clause) },
|
59
60
|
};
|
60
61
|
encoded.headers["content-type"] = "application/json";
|
61
62
|
encoded.method = "POST";
|
@@ -67,16 +68,16 @@ struct analytics_dataset_drop_request {
|
|
67
68
|
|
68
69
|
analytics_dataset_drop_response
|
69
70
|
make_response(error_context::http&& ctx,
|
70
|
-
analytics_dataset_drop_request& /* request */,
|
71
|
+
const analytics_dataset_drop_request& /* request */,
|
71
72
|
analytics_dataset_drop_request::encoded_response_type&& encoded)
|
72
73
|
{
|
73
|
-
analytics_dataset_drop_response response{ ctx };
|
74
|
+
analytics_dataset_drop_response response{ std::move(ctx) };
|
74
75
|
if (!response.ctx.ec) {
|
75
76
|
tao::json::value payload{};
|
76
77
|
try {
|
77
78
|
payload = tao::json::from_string(encoded.body);
|
78
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
79
|
-
response.ctx.ec =
|
79
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
80
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
80
81
|
return response;
|
81
82
|
}
|
82
83
|
response.status = payload.at("status").get_string();
|
@@ -84,8 +85,7 @@ make_response(error_context::http&& ctx,
|
|
84
85
|
if (response.status != "success") {
|
85
86
|
bool dataset_does_not_exist = false;
|
86
87
|
|
87
|
-
auto* errors = payload.find("errors");
|
88
|
-
if (errors != nullptr && errors->is_array()) {
|
88
|
+
if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
|
89
89
|
for (const auto& error : errors->get_array()) {
|
90
90
|
analytics_dataset_drop_response::problem err{
|
91
91
|
error.at("code").as<std::uint32_t>(),
|
@@ -100,9 +100,9 @@ make_response(error_context::http&& ctx,
|
|
100
100
|
}
|
101
101
|
}
|
102
102
|
if (dataset_does_not_exist) {
|
103
|
-
response.ctx.ec =
|
103
|
+
response.ctx.ec = error::analytics_errc::dataset_not_found;
|
104
104
|
} else {
|
105
|
-
response.ctx.ec =
|
105
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
106
106
|
}
|
107
107
|
}
|
108
108
|
}
|
@@ -53,7 +53,7 @@ struct analytics_dataset_get_all_request {
|
|
53
53
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
54
54
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
55
55
|
|
56
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
|
56
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
57
57
|
{
|
58
58
|
tao::json::value body{
|
59
59
|
{ "statement", "SELECT d.* FROM Metadata.`Dataset` d WHERE d.DataverseName <> \"Metadata\"" },
|
@@ -68,17 +68,17 @@ struct analytics_dataset_get_all_request {
|
|
68
68
|
|
69
69
|
analytics_dataset_get_all_response
|
70
70
|
make_response(error_context::http&& ctx,
|
71
|
-
analytics_dataset_get_all_request& /* request */,
|
71
|
+
const analytics_dataset_get_all_request& /* request */,
|
72
72
|
analytics_dataset_get_all_request::encoded_response_type&& encoded)
|
73
73
|
{
|
74
|
-
analytics_dataset_get_all_response response{ ctx };
|
74
|
+
analytics_dataset_get_all_response response{ std::move(ctx) };
|
75
75
|
|
76
76
|
if (!response.ctx.ec) {
|
77
77
|
tao::json::value payload{};
|
78
78
|
try {
|
79
79
|
payload = tao::json::from_string(encoded.body);
|
80
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
81
|
-
response.ctx.ec =
|
80
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
81
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
82
82
|
return response;
|
83
83
|
}
|
84
84
|
response.status = payload.at("status").get_string();
|
@@ -105,7 +105,7 @@ make_response(error_context::http&& ctx,
|
|
105
105
|
response.errors.emplace_back(err);
|
106
106
|
}
|
107
107
|
}
|
108
|
-
response.ctx.ec =
|
108
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
109
109
|
}
|
110
110
|
}
|
111
111
|
return response;
|
@@ -20,7 +20,7 @@
|
|
20
20
|
#include <tao/json.hpp>
|
21
21
|
|
22
22
|
#include <error_context/http.hxx>
|
23
|
-
#include <
|
23
|
+
#include <utils/name_codec.hxx>
|
24
24
|
|
25
25
|
namespace couchbase::operations
|
26
26
|
{
|
@@ -50,12 +50,12 @@ struct analytics_dataverse_create_request {
|
|
50
50
|
|
51
51
|
bool ignore_if_exists{ false };
|
52
52
|
|
53
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
|
53
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
54
54
|
{
|
55
55
|
std::string if_not_exists_clause = ignore_if_exists ? "IF NOT EXISTS" : "";
|
56
56
|
|
57
57
|
tao::json::value body{
|
58
|
-
{ "statement", fmt::format("CREATE DATAVERSE
|
58
|
+
{ "statement", fmt::format("CREATE DATAVERSE {} {}", utils::analytics::uncompound_name(dataverse_name), if_not_exists_clause) },
|
59
59
|
};
|
60
60
|
encoded.headers["content-type"] = "application/json";
|
61
61
|
encoded.method = "POST";
|
@@ -67,16 +67,16 @@ struct analytics_dataverse_create_request {
|
|
67
67
|
|
68
68
|
analytics_dataverse_create_response
|
69
69
|
make_response(error_context::http&& ctx,
|
70
|
-
analytics_dataverse_create_request& /* request */,
|
70
|
+
const analytics_dataverse_create_request& /* request */,
|
71
71
|
analytics_dataverse_create_request::encoded_response_type&& encoded)
|
72
72
|
{
|
73
|
-
analytics_dataverse_create_response response{ ctx };
|
73
|
+
analytics_dataverse_create_response response{ std::move(ctx) };
|
74
74
|
if (!response.ctx.ec) {
|
75
75
|
tao::json::value payload{};
|
76
76
|
try {
|
77
77
|
payload = tao::json::from_string(encoded.body);
|
78
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
79
|
-
response.ctx.ec =
|
78
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
79
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
80
80
|
return response;
|
81
81
|
}
|
82
82
|
response.status = payload.at("status").get_string();
|
@@ -84,8 +84,7 @@ make_response(error_context::http&& ctx,
|
|
84
84
|
if (response.status != "success") {
|
85
85
|
bool dataverse_exists = false;
|
86
86
|
|
87
|
-
auto* errors = payload.find("errors");
|
88
|
-
if (errors != nullptr && errors->is_array()) {
|
87
|
+
if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
|
89
88
|
for (const auto& error : errors->get_array()) {
|
90
89
|
analytics_dataverse_create_response::problem err{
|
91
90
|
error.at("code").as<std::uint32_t>(),
|
@@ -100,9 +99,9 @@ make_response(error_context::http&& ctx,
|
|
100
99
|
}
|
101
100
|
}
|
102
101
|
if (dataverse_exists) {
|
103
|
-
response.ctx.ec =
|
102
|
+
response.ctx.ec = error::analytics_errc::dataverse_exists;
|
104
103
|
} else {
|
105
|
-
response.ctx.ec =
|
104
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
106
105
|
}
|
107
106
|
}
|
108
107
|
}
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include <tao/json.hpp>
|
21
21
|
|
22
|
-
#include <
|
22
|
+
#include <utils/name_codec.hxx>
|
23
23
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
@@ -49,12 +49,12 @@ struct analytics_dataverse_drop_request {
|
|
49
49
|
|
50
50
|
bool ignore_if_does_not_exist{ false };
|
51
51
|
|
52
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
|
52
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
53
53
|
{
|
54
54
|
std::string if_exists_clause = ignore_if_does_not_exist ? "IF EXISTS" : "";
|
55
55
|
|
56
56
|
tao::json::value body{
|
57
|
-
{ "statement", fmt::format("DROP DATAVERSE
|
57
|
+
{ "statement", fmt::format("DROP DATAVERSE {} {}", utils::analytics::uncompound_name(dataverse_name), if_exists_clause) },
|
58
58
|
};
|
59
59
|
encoded.headers["content-type"] = "application/json";
|
60
60
|
encoded.method = "POST";
|
@@ -66,16 +66,16 @@ struct analytics_dataverse_drop_request {
|
|
66
66
|
|
67
67
|
analytics_dataverse_drop_response
|
68
68
|
make_response(error_context::http&& ctx,
|
69
|
-
analytics_dataverse_drop_request& /* request */,
|
69
|
+
const analytics_dataverse_drop_request& /* request */,
|
70
70
|
analytics_dataverse_drop_request::encoded_response_type&& encoded)
|
71
71
|
{
|
72
|
-
analytics_dataverse_drop_response response{ ctx };
|
72
|
+
analytics_dataverse_drop_response response{ std::move(ctx) };
|
73
73
|
if (!response.ctx.ec) {
|
74
74
|
tao::json::value payload{};
|
75
75
|
try {
|
76
76
|
payload = tao::json::from_string(encoded.body);
|
77
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
78
|
-
response.ctx.ec =
|
77
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
78
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
79
79
|
return response;
|
80
80
|
}
|
81
81
|
response.status = payload.at("status").get_string();
|
@@ -83,8 +83,7 @@ make_response(error_context::http&& ctx,
|
|
83
83
|
if (response.status != "success") {
|
84
84
|
bool dataverse_does_not_exist = false;
|
85
85
|
|
86
|
-
auto* errors = payload.find("errors");
|
87
|
-
if (errors != nullptr && errors->is_array()) {
|
86
|
+
if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
|
88
87
|
for (const auto& error : errors->get_array()) {
|
89
88
|
analytics_dataverse_drop_response::problem err{
|
90
89
|
error.at("code").as<std::uint32_t>(),
|
@@ -99,9 +98,9 @@ make_response(error_context::http&& ctx,
|
|
99
98
|
}
|
100
99
|
}
|
101
100
|
if (dataverse_does_not_exist) {
|
102
|
-
response.ctx.ec =
|
101
|
+
response.ctx.ec = error::analytics_errc::dataverse_not_found;
|
103
102
|
} else {
|
104
|
-
response.ctx.ec =
|
103
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
105
104
|
}
|
106
105
|
}
|
107
106
|
}
|
@@ -47,7 +47,7 @@ struct analytics_get_pending_mutations_request {
|
|
47
47
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
48
48
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
49
49
|
|
50
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */)
|
50
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
51
51
|
{
|
52
52
|
encoded.method = "GET";
|
53
53
|
encoded.path = "/analytics/node/agg/stats/remaining";
|
@@ -57,25 +57,23 @@ struct analytics_get_pending_mutations_request {
|
|
57
57
|
|
58
58
|
analytics_get_pending_mutations_response
|
59
59
|
make_response(error_context::http&& ctx,
|
60
|
-
analytics_get_pending_mutations_request& /* request */,
|
60
|
+
const analytics_get_pending_mutations_request& /* request */,
|
61
61
|
analytics_get_pending_mutations_request::encoded_response_type&& encoded)
|
62
62
|
{
|
63
|
-
analytics_get_pending_mutations_response response{ ctx };
|
63
|
+
analytics_get_pending_mutations_response response{ std::move(ctx) };
|
64
64
|
if (!response.ctx.ec) {
|
65
65
|
tao::json::value payload{};
|
66
66
|
try {
|
67
67
|
payload = tao::json::from_string(encoded.body);
|
68
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
69
|
-
response.ctx.ec =
|
68
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
69
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
70
70
|
return response;
|
71
71
|
}
|
72
72
|
if (encoded.status_code == 200) {
|
73
73
|
if (payload.is_object()) {
|
74
|
-
for (const auto& entry : payload.get_object()) {
|
75
|
-
|
76
|
-
|
77
|
-
std::string dataset = dataverse + stats.first;
|
78
|
-
response.stats.emplace(dataset, stats.second.get_unsigned());
|
74
|
+
for (const auto& [dataverse, entry] : payload.get_object()) {
|
75
|
+
for (const auto& [dataset, counter] : entry.get_object()) {
|
76
|
+
response.stats.try_emplace(fmt::format("{}.{}", dataverse, dataset), counter.get_unsigned());
|
79
77
|
}
|
80
78
|
}
|
81
79
|
}
|
@@ -91,7 +89,7 @@ make_response(error_context::http&& ctx,
|
|
91
89
|
response.errors.emplace_back(err);
|
92
90
|
}
|
93
91
|
}
|
94
|
-
response.ctx.ec =
|
92
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
95
93
|
}
|
96
94
|
return response;
|
97
95
|
}
|
@@ -52,13 +52,13 @@ struct analytics_index_create_request {
|
|
52
52
|
|
53
53
|
bool ignore_if_exists{ false };
|
54
54
|
|
55
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
55
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
56
56
|
{
|
57
57
|
std::string if_not_exists_clause = ignore_if_exists ? "IF NOT EXISTS" : "";
|
58
58
|
std::vector<std::string> field_specs;
|
59
59
|
field_specs.reserve(fields.size());
|
60
|
-
for (const auto&
|
61
|
-
field_specs.emplace_back(
|
60
|
+
for (const auto& [field_name, field_type] : fields) {
|
61
|
+
field_specs.emplace_back(fmt::format("{}:{}", field_name, field_type));
|
62
62
|
}
|
63
63
|
|
64
64
|
tao::json::value body{
|
@@ -79,15 +79,17 @@ struct analytics_index_create_request {
|
|
79
79
|
};
|
80
80
|
|
81
81
|
analytics_index_create_response
|
82
|
-
make_response(error_context::http&& ctx,
|
82
|
+
make_response(error_context::http&& ctx,
|
83
|
+
const analytics_index_create_request& /* request */,
|
84
|
+
analytics_index_create_request::encoded_response_type&& encoded)
|
83
85
|
{
|
84
|
-
analytics_index_create_response response{ ctx };
|
86
|
+
analytics_index_create_response response{ std::move(ctx) };
|
85
87
|
if (!response.ctx.ec) {
|
86
88
|
tao::json::value payload{};
|
87
89
|
try {
|
88
90
|
payload = tao::json::from_string(encoded.body);
|
89
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
90
|
-
response.ctx.ec =
|
91
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
92
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
91
93
|
return response;
|
92
94
|
}
|
93
95
|
response.status = payload.at("status").get_string();
|
@@ -97,8 +99,7 @@ make_response(error_context::http&& ctx, analytics_index_create_request&, analyt
|
|
97
99
|
bool dataset_not_found = false;
|
98
100
|
bool link_not_found = false;
|
99
101
|
|
100
|
-
auto* errors = payload.find("errors");
|
101
|
-
if (errors != nullptr && errors->is_array()) {
|
102
|
+
if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
|
102
103
|
for (const auto& error : errors->get_array()) {
|
103
104
|
analytics_index_create_response::problem err{
|
104
105
|
error.at("code").as<std::uint32_t>(),
|
@@ -119,13 +120,13 @@ make_response(error_context::http&& ctx, analytics_index_create_request&, analyt
|
|
119
120
|
}
|
120
121
|
}
|
121
122
|
if (index_exists) {
|
122
|
-
response.ctx.ec =
|
123
|
+
response.ctx.ec = error::common_errc::index_exists;
|
123
124
|
} else if (dataset_not_found) {
|
124
|
-
response.ctx.ec =
|
125
|
+
response.ctx.ec = error::analytics_errc::dataset_not_found;
|
125
126
|
} else if (link_not_found) {
|
126
|
-
response.ctx.ec =
|
127
|
+
response.ctx.ec = error::analytics_errc::link_not_found;
|
127
128
|
} else {
|
128
|
-
response.ctx.ec =
|
129
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
129
130
|
}
|
130
131
|
}
|
131
132
|
}
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include <tao/json.hpp>
|
21
21
|
|
22
|
-
#include <
|
22
|
+
#include <utils/name_codec.hxx>
|
23
23
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
@@ -51,12 +51,17 @@ struct analytics_index_drop_request {
|
|
51
51
|
|
52
52
|
bool ignore_if_does_not_exist{ false };
|
53
53
|
|
54
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
54
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
55
55
|
{
|
56
56
|
std::string if_exists_clause = ignore_if_does_not_exist ? "IF EXISTS" : "";
|
57
57
|
|
58
58
|
tao::json::value body{
|
59
|
-
{ "statement",
|
59
|
+
{ "statement",
|
60
|
+
fmt::format("DROP INDEX {}.`{}`.`{}` {}",
|
61
|
+
utils::analytics::uncompound_name(dataverse_name),
|
62
|
+
dataset_name,
|
63
|
+
index_name,
|
64
|
+
if_exists_clause) },
|
60
65
|
};
|
61
66
|
encoded.headers["content-type"] = "application/json";
|
62
67
|
encoded.method = "POST";
|
@@ -67,15 +72,17 @@ struct analytics_index_drop_request {
|
|
67
72
|
};
|
68
73
|
|
69
74
|
analytics_index_drop_response
|
70
|
-
make_response(error_context::http&& ctx,
|
75
|
+
make_response(error_context::http&& ctx,
|
76
|
+
const analytics_index_drop_request& /* request */,
|
77
|
+
analytics_index_drop_request::encoded_response_type&& encoded)
|
71
78
|
{
|
72
|
-
analytics_index_drop_response response{ ctx };
|
79
|
+
analytics_index_drop_response response{ std::move(ctx) };
|
73
80
|
if (!response.ctx.ec) {
|
74
81
|
tao::json::value payload{};
|
75
82
|
try {
|
76
83
|
payload = tao::json::from_string(encoded.body);
|
77
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
78
|
-
response.ctx.ec =
|
84
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
85
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
79
86
|
return response;
|
80
87
|
}
|
81
88
|
response.status = payload.at("status").get_string();
|
@@ -84,8 +91,7 @@ make_response(error_context::http&& ctx, analytics_index_drop_request&, analytic
|
|
84
91
|
bool index_does_not_exist = false;
|
85
92
|
bool dataset_not_found = false;
|
86
93
|
|
87
|
-
auto* errors = payload.find("errors");
|
88
|
-
if (errors != nullptr && errors->is_array()) {
|
94
|
+
if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
|
89
95
|
for (const auto& error : errors->get_array()) {
|
90
96
|
analytics_index_drop_response::problem err{
|
91
97
|
error.at("code").as<std::uint32_t>(),
|
@@ -103,11 +109,11 @@ make_response(error_context::http&& ctx, analytics_index_drop_request&, analytic
|
|
103
109
|
}
|
104
110
|
}
|
105
111
|
if (index_does_not_exist) {
|
106
|
-
response.ctx.ec =
|
112
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
107
113
|
} else if (dataset_not_found) {
|
108
|
-
response.ctx.ec =
|
114
|
+
response.ctx.ec = error::analytics_errc::dataset_not_found;
|
109
115
|
} else {
|
110
|
-
response.ctx.ec =
|
116
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
111
117
|
}
|
112
118
|
}
|
113
119
|
}
|