couchbase 3.1.1-universal-darwin-20 → 3.2.0-universal-darwin-20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/CMakeLists.txt +3 -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.hxx +4 -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/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/libcouchbase.bundle +0 -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 +48 -5
@@ -42,7 +42,7 @@ struct get_and_lock_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
43
43
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
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);
|
@@ -53,9 +53,11 @@ struct get_and_lock_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
get_and_lock_response
|
56
|
-
make_response(error_context::key_value&& ctx,
|
56
|
+
make_response(error_context::key_value&& ctx,
|
57
|
+
const get_and_lock_request& /* request */,
|
58
|
+
get_and_lock_request::encoded_response_type&& encoded)
|
57
59
|
{
|
58
|
-
get_and_lock_response response{ ctx };
|
60
|
+
get_and_lock_response response{ std::move(ctx) };
|
59
61
|
if (!response.ctx.ec) {
|
60
62
|
response.value = std::move(encoded.body().value());
|
61
63
|
response.cas = encoded.cas();
|
@@ -42,7 +42,7 @@ struct get_and_touch_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
43
43
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
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);
|
@@ -53,9 +53,11 @@ struct get_and_touch_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
get_and_touch_response
|
56
|
-
make_response(error_context::key_value&& ctx,
|
56
|
+
make_response(error_context::key_value&& ctx,
|
57
|
+
const get_and_touch_request& /* request */,
|
58
|
+
get_and_touch_request::encoded_response_type&& encoded)
|
57
59
|
{
|
58
|
-
get_and_touch_response response{ ctx };
|
60
|
+
get_and_touch_response response{ std::move(ctx) };
|
59
61
|
if (!response.ctx.ec) {
|
60
62
|
response.value = std::move(encoded.body().value());
|
61
63
|
response.cas = encoded.cas();
|
@@ -46,7 +46,7 @@ struct get_projected_request {
|
|
46
46
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
47
47
|
io::retry_context<io::retry_strategy::best_effort> retries{ true };
|
48
48
|
|
49
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
49
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */)
|
50
50
|
{
|
51
51
|
encoded.opaque(opaque);
|
52
52
|
encoded.partition(partition);
|
@@ -111,8 +111,7 @@ subdoc_lookup(tao::json::value& root, const std::string& path)
|
|
111
111
|
break;
|
112
112
|
}
|
113
113
|
std::string key = path.substr(offset, idx - offset);
|
114
|
-
int array_index = std::stoi(key);
|
115
|
-
if (array_index == -1) {
|
114
|
+
if (int array_index = std::stoi(key); array_index == -1) {
|
116
115
|
cur = &cur->get_array().back();
|
117
116
|
} else if (static_cast<std::size_t>(array_index) < cur->get_array().size()) {
|
118
117
|
cur = &cur->get_array().back();
|
@@ -196,9 +195,9 @@ subdoc_apply_projection(tao::json::value& root, const std::string& path, tao::js
|
|
196
195
|
} // namespace priv
|
197
196
|
|
198
197
|
get_projected_response
|
199
|
-
make_response(error_context::key_value&& ctx, get_projected_request& request, get_projected_request::encoded_response_type&& encoded)
|
198
|
+
make_response(error_context::key_value&& ctx, const get_projected_request& request, get_projected_request::encoded_response_type&& encoded)
|
200
199
|
{
|
201
|
-
get_projected_response response{ ctx };
|
200
|
+
get_projected_response response{ std::move(ctx) };
|
202
201
|
if (!response.ctx.ec) {
|
203
202
|
response.cas = encoded.cas();
|
204
203
|
if (request.with_expiry && !encoded.body().fields()[0].value.empty()) {
|
@@ -213,8 +212,8 @@ make_response(error_context::key_value&& ctx, get_projected_request& request, ge
|
|
213
212
|
tao::json::value full_doc{};
|
214
213
|
try {
|
215
214
|
full_doc = tao::json::from_string(encoded.body().fields()[request.with_expiry ? 1 : 0].value);
|
216
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
217
|
-
response.ctx.ec =
|
215
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
216
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
218
217
|
return response;
|
219
218
|
}
|
220
219
|
tao::json::value new_doc;
|
@@ -223,7 +222,7 @@ make_response(error_context::key_value&& ctx, get_projected_request& request, ge
|
|
223
222
|
if (value_to_apply) {
|
224
223
|
priv::subdoc_apply_projection(new_doc, projection, *value_to_apply, request.preserve_array_indexes);
|
225
224
|
} else {
|
226
|
-
response.ctx.ec =
|
225
|
+
response.ctx.ec = error::key_value_errc::path_not_found;
|
227
226
|
return response;
|
228
227
|
}
|
229
228
|
}
|
@@ -238,13 +237,13 @@ make_response(error_context::key_value&& ctx, get_projected_request& request, ge
|
|
238
237
|
tao::json::value value_to_apply{};
|
239
238
|
try {
|
240
239
|
value_to_apply = tao::json::from_string(field.value);
|
241
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
242
|
-
response.ctx.ec =
|
240
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
241
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
243
242
|
return response;
|
244
243
|
}
|
245
244
|
priv::subdoc_apply_projection(new_doc, projection, value_to_apply, request.preserve_array_indexes);
|
246
245
|
} else {
|
247
|
-
response.ctx.ec =
|
246
|
+
response.ctx.ec = error::key_value_errc::path_not_found;
|
248
247
|
return response;
|
249
248
|
}
|
250
249
|
}
|
@@ -49,7 +49,7 @@ struct increment_request {
|
|
49
49
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
50
50
|
bool preserve_expiry{ false };
|
51
51
|
|
52
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
52
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
53
53
|
{
|
54
54
|
encoded.opaque(opaque);
|
55
55
|
encoded.partition(partition);
|
@@ -73,9 +73,9 @@ struct increment_request {
|
|
73
73
|
};
|
74
74
|
|
75
75
|
increment_response
|
76
|
-
make_response(error_context::key_value&& ctx, increment_request& request, increment_request::encoded_response_type&& encoded)
|
76
|
+
make_response(error_context::key_value&& ctx, const increment_request& request, increment_request::encoded_response_type&& encoded)
|
77
77
|
{
|
78
|
-
increment_response response{ ctx };
|
78
|
+
increment_response response{ std::move(ctx) };
|
79
79
|
if (!response.ctx.ec) {
|
80
80
|
response.cas = encoded.cas();
|
81
81
|
response.content = encoded.body().content();
|
@@ -46,7 +46,7 @@ struct insert_request {
|
|
46
46
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
47
47
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
48
48
|
|
49
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
49
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
50
50
|
{
|
51
51
|
encoded.opaque(opaque);
|
52
52
|
encoded.partition(partition);
|
@@ -62,9 +62,9 @@ struct insert_request {
|
|
62
62
|
};
|
63
63
|
|
64
64
|
insert_response
|
65
|
-
make_response(error_context::key_value&& ctx, insert_request& request, insert_request::encoded_response_type&& encoded)
|
65
|
+
make_response(error_context::key_value&& ctx, const insert_request& request, insert_request::encoded_response_type&& encoded)
|
66
66
|
{
|
67
|
-
insert_response response{ ctx };
|
67
|
+
insert_response response{ std::move(ctx) };
|
68
68
|
if (!response.ctx.ec) {
|
69
69
|
response.cas = encoded.cas();
|
70
70
|
response.token = encoded.body().token();
|
@@ -52,19 +52,15 @@ struct lookup_in_request {
|
|
52
52
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
53
53
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
54
54
|
|
55
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
55
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */)
|
56
56
|
{
|
57
57
|
for (std::size_t i = 0; i < specs.entries.size(); ++i) {
|
58
|
-
|
59
|
-
entry.original_index = i;
|
58
|
+
specs.entries[i].original_index = i;
|
60
59
|
}
|
61
|
-
std::stable_sort(specs.entries.begin(),
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
return (lhs.flags & protocol::lookup_in_request_body::lookup_in_specs::path_flag_xattr) >
|
66
|
-
(rhs.flags & protocol::lookup_in_request_body::lookup_in_specs::path_flag_xattr);
|
67
|
-
});
|
60
|
+
std::stable_sort(specs.entries.begin(), specs.entries.end(), [](const auto& lhs, const auto& rhs) {
|
61
|
+
return (lhs.flags & protocol::lookup_in_request_body::lookup_in_specs::path_flag_xattr) >
|
62
|
+
(rhs.flags & protocol::lookup_in_request_body::lookup_in_specs::path_flag_xattr);
|
63
|
+
});
|
68
64
|
|
69
65
|
encoded.opaque(opaque);
|
70
66
|
encoded.partition(partition);
|
@@ -76,9 +72,9 @@ struct lookup_in_request {
|
|
76
72
|
};
|
77
73
|
|
78
74
|
lookup_in_response
|
79
|
-
make_response(error_context::key_value&& ctx, lookup_in_request& request, lookup_in_request::encoded_response_type&& encoded)
|
75
|
+
make_response(error_context::key_value&& ctx, const lookup_in_request& request, lookup_in_request::encoded_response_type&& encoded)
|
80
76
|
{
|
81
|
-
lookup_in_response response{ ctx };
|
77
|
+
lookup_in_response response{ std::move(ctx) };
|
82
78
|
if (encoded.status() == protocol::status::subdoc_success_deleted ||
|
83
79
|
encoded.status() == protocol::status::subdoc_multi_path_failure_deleted) {
|
84
80
|
response.deleted = true;
|
@@ -89,7 +85,7 @@ make_response(error_context::key_value&& ctx, lookup_in_request& request, lookup
|
|
89
85
|
for (size_t i = 0; i < request.specs.entries.size(); ++i) {
|
90
86
|
auto& req_entry = request.specs.entries[i];
|
91
87
|
response.fields[i].original_index = req_entry.original_index;
|
92
|
-
response.fields[i].opcode =
|
88
|
+
response.fields[i].opcode = protocol::subdoc_opcode(req_entry.opcode);
|
93
89
|
response.fields[i].path = req_entry.path;
|
94
90
|
response.fields[i].status = protocol::status::success;
|
95
91
|
}
|
@@ -100,11 +96,9 @@ make_response(error_context::key_value&& ctx, lookup_in_request& request, lookup
|
|
100
96
|
res_entry.status == protocol::status::success || res_entry.status == protocol::status::subdoc_success_deleted;
|
101
97
|
response.fields[i].value = res_entry.value;
|
102
98
|
}
|
103
|
-
std::sort(response.fields.begin(),
|
104
|
-
|
105
|
-
|
106
|
-
return lhs.original_index < rhs.original_index;
|
107
|
-
});
|
99
|
+
std::sort(response.fields.begin(), response.fields.end(), [](const auto& lhs, const auto& rhs) {
|
100
|
+
return lhs.original_index < rhs.original_index;
|
101
|
+
});
|
108
102
|
}
|
109
103
|
return response;
|
110
104
|
}
|
@@ -75,19 +75,16 @@ struct mutate_in_request {
|
|
75
75
|
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& ctx)
|
76
76
|
{
|
77
77
|
if (create_as_deleted && !ctx.supports_feature(protocol::hello_feature::subdoc_create_as_deleted)) {
|
78
|
-
return
|
78
|
+
return error::common_errc::unsupported_operation;
|
79
79
|
}
|
80
80
|
for (std::size_t i = 0; i < specs.entries.size(); ++i) {
|
81
81
|
auto& entry = specs.entries[i];
|
82
82
|
entry.original_index = i;
|
83
83
|
}
|
84
|
-
std::stable_sort(specs.entries.begin(),
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
return (lhs.flags & protocol::mutate_in_request_body::mutate_in_specs::path_flag_xattr) >
|
89
|
-
(rhs.flags & protocol::mutate_in_request_body::mutate_in_specs::path_flag_xattr);
|
90
|
-
});
|
84
|
+
std::stable_sort(specs.entries.begin(), specs.entries.end(), [](const auto& lhs, const auto& rhs) {
|
85
|
+
return (lhs.flags & protocol::mutate_in_request_body::mutate_in_specs::path_flag_xattr) >
|
86
|
+
(rhs.flags & protocol::mutate_in_request_body::mutate_in_specs::path_flag_xattr);
|
87
|
+
});
|
91
88
|
|
92
89
|
encoded.opaque(opaque);
|
93
90
|
encoded.partition(partition);
|
@@ -111,9 +108,9 @@ struct mutate_in_request {
|
|
111
108
|
};
|
112
109
|
|
113
110
|
mutate_in_response
|
114
|
-
make_response(error_context::key_value&& ctx, mutate_in_request& request, mutate_in_request::encoded_response_type&& encoded)
|
111
|
+
make_response(error_context::key_value&& ctx, const mutate_in_request& request, mutate_in_request::encoded_response_type&& encoded)
|
115
112
|
{
|
116
|
-
mutate_in_response response{ ctx };
|
113
|
+
mutate_in_response response{ std::move(ctx) };
|
117
114
|
if (encoded.status() == protocol::status::subdoc_success_deleted ||
|
118
115
|
encoded.status() == protocol::status::subdoc_multi_path_failure_deleted) {
|
119
116
|
response.deleted = true;
|
@@ -127,7 +124,7 @@ make_response(error_context::key_value&& ctx, mutate_in_request& request, mutate
|
|
127
124
|
for (size_t i = 0; i < request.specs.entries.size(); ++i) {
|
128
125
|
auto& req_entry = request.specs.entries[i];
|
129
126
|
response.fields[i].original_index = req_entry.original_index;
|
130
|
-
response.fields[i].opcode =
|
127
|
+
response.fields[i].opcode = protocol::subdoc_opcode(req_entry.opcode);
|
131
128
|
response.fields[i].path = req_entry.path;
|
132
129
|
response.fields[i].status = protocol::status::success;
|
133
130
|
}
|
@@ -140,14 +137,12 @@ make_response(error_context::key_value&& ctx, mutate_in_request& request, mutate
|
|
140
137
|
break;
|
141
138
|
}
|
142
139
|
}
|
143
|
-
std::sort(response.fields.begin(),
|
144
|
-
|
145
|
-
|
146
|
-
return lhs.original_index < rhs.original_index;
|
147
|
-
});
|
140
|
+
std::sort(response.fields.begin(), response.fields.end(), [](const auto& lhs, const auto& rhs) {
|
141
|
+
return lhs.original_index < rhs.original_index;
|
142
|
+
});
|
148
143
|
} else if (request.store_semantics == protocol::mutate_in_request_body::store_semantics_type::insert &&
|
149
|
-
response.ctx.ec ==
|
150
|
-
response.ctx.ec =
|
144
|
+
response.ctx.ec == error::common_errc::cas_mismatch) {
|
145
|
+
response.ctx.ec = error::key_value_errc::document_exists;
|
151
146
|
}
|
152
147
|
return response;
|
153
148
|
}
|
@@ -43,7 +43,7 @@ struct prepend_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 prepend_request {
|
|
57
57
|
};
|
58
58
|
|
59
59
|
prepend_response
|
60
|
-
make_response(error_context::key_value&& ctx, prepend_request& request, prepend_request::encoded_response_type&& encoded)
|
60
|
+
make_response(error_context::key_value&& ctx, const prepend_request& request, prepend_request::encoded_response_type&& encoded)
|
61
61
|
{
|
62
|
-
prepend_response response{ ctx };
|
62
|
+
prepend_response response{ std::move(ctx) };
|
63
63
|
if (!response.ctx.ec) {
|
64
64
|
response.cas = encoded.cas();
|
65
65
|
response.token = encoded.body().token();
|
@@ -79,28 +79,22 @@ struct traits<couchbase::operations::query_response_payload> {
|
|
79
79
|
{
|
80
80
|
couchbase::operations::query_response_payload result;
|
81
81
|
result.meta_data.request_id = v.at("requestID").get_string();
|
82
|
-
|
83
|
-
if (i != nullptr) {
|
82
|
+
|
83
|
+
if (const auto* i = v.find("clientContextID"); i != nullptr) {
|
84
84
|
result.meta_data.client_context_id = i->get_string();
|
85
85
|
}
|
86
86
|
result.meta_data.status = v.at("status").get_string();
|
87
|
-
const auto s = v.find("signature");
|
88
|
-
if (s != nullptr) {
|
87
|
+
if (const auto* s = v.find("signature"); s != nullptr) {
|
89
88
|
result.meta_data.signature = tao::json::to_string(*s);
|
90
89
|
}
|
91
|
-
{
|
92
|
-
|
93
|
-
if (c != nullptr) {
|
94
|
-
result.prepared = c->get_string();
|
95
|
-
}
|
90
|
+
if (const auto* c = v.find("prepared"); c != nullptr) {
|
91
|
+
result.prepared = c->get_string();
|
96
92
|
}
|
97
|
-
const auto p = v.find("profile");
|
98
|
-
if (p != nullptr) {
|
93
|
+
if (const auto* p = v.find("profile"); p != nullptr) {
|
99
94
|
result.meta_data.profile = tao::json::to_string(*p);
|
100
95
|
}
|
101
96
|
|
102
|
-
const auto m = v.find("metrics");
|
103
|
-
if (m != nullptr) {
|
97
|
+
if (const auto* m = v.find("metrics"); m != nullptr) {
|
104
98
|
result.meta_data.metrics.result_count = m->at("resultCount").get_unsigned();
|
105
99
|
result.meta_data.metrics.result_size = m->at("resultSize").get_unsigned();
|
106
100
|
result.meta_data.metrics.elapsed_time = m->at("elapsedTime").get_string();
|
@@ -111,8 +105,7 @@ struct traits<couchbase::operations::query_response_payload> {
|
|
111
105
|
result.meta_data.metrics.warning_count = m->template optional<std::uint64_t>("warningCount");
|
112
106
|
}
|
113
107
|
|
114
|
-
const auto e = v.find("errors");
|
115
|
-
if (e != nullptr) {
|
108
|
+
if (const auto* e = v.find("errors"); e != nullptr) {
|
116
109
|
std::vector<couchbase::operations::query_response_payload::query_problem> problems{};
|
117
110
|
for (auto& err : e->get_array()) {
|
118
111
|
couchbase::operations::query_response_payload::query_problem problem;
|
@@ -123,8 +116,7 @@ struct traits<couchbase::operations::query_response_payload> {
|
|
123
116
|
result.meta_data.errors.emplace(problems);
|
124
117
|
}
|
125
118
|
|
126
|
-
const auto w = v.find("warnings");
|
127
|
-
if (w != nullptr) {
|
119
|
+
if (const auto* w = v.find("warnings"); w != nullptr) {
|
128
120
|
std::vector<couchbase::operations::query_response_payload::query_problem> problems{};
|
129
121
|
for (auto& warn : w->get_array()) {
|
130
122
|
couchbase::operations::query_response_payload::query_problem problem;
|
@@ -134,8 +126,8 @@ struct traits<couchbase::operations::query_response_payload> {
|
|
134
126
|
}
|
135
127
|
result.meta_data.warnings.emplace(problems);
|
136
128
|
}
|
137
|
-
|
138
|
-
if (r != nullptr) {
|
129
|
+
|
130
|
+
if (const auto* r = v.find("results"); r != nullptr) {
|
139
131
|
result.rows.reserve(result.meta_data.metrics.result_count);
|
140
132
|
for (auto& row : r->get_array()) {
|
141
133
|
result.rows.emplace_back(tao::json::to_string(row));
|
@@ -225,13 +217,13 @@ struct query_request {
|
|
225
217
|
body["timeout"] = fmt::format(
|
226
218
|
"{}ms", ((timeout > std::chrono::milliseconds(5'000)) ? (timeout - std::chrono::milliseconds(500)) : timeout).count());
|
227
219
|
if (positional_parameters.empty()) {
|
228
|
-
for (auto&
|
229
|
-
Expects(
|
230
|
-
std::string key =
|
220
|
+
for (const auto& [name, value] : named_parameters) {
|
221
|
+
Expects(name.empty() == false);
|
222
|
+
std::string key = name;
|
231
223
|
if (key[0] != '$') {
|
232
224
|
key.insert(key.begin(), '$');
|
233
225
|
}
|
234
|
-
body[key] =
|
226
|
+
body[key] = value;
|
235
227
|
}
|
236
228
|
} else {
|
237
229
|
body["args"] = positional_parameters;
|
@@ -304,8 +296,8 @@ struct query_request {
|
|
304
296
|
body["query_context"] = fmt::format("default:`{}`.`{}`", *bucket_name, *scope_name);
|
305
297
|
}
|
306
298
|
}
|
307
|
-
for (auto&
|
308
|
-
body[
|
299
|
+
for (const auto& [name, value] : raw) {
|
300
|
+
body[name] = value;
|
309
301
|
}
|
310
302
|
encoded.type = type;
|
311
303
|
encoded.headers["connection"] = "keep-alive";
|
@@ -335,14 +327,14 @@ struct query_request {
|
|
335
327
|
query_response
|
336
328
|
make_response(error_context::query&& ctx, query_request& request, query_request::encoded_response_type&& encoded)
|
337
329
|
{
|
338
|
-
query_response response{ ctx };
|
330
|
+
query_response response{ std::move(ctx) };
|
339
331
|
response.ctx.statement = request.statement;
|
340
332
|
response.ctx.parameters = request.body_str;
|
341
333
|
if (!response.ctx.ec) {
|
342
334
|
try {
|
343
335
|
response.payload = tao::json::from_string(encoded.body).as<query_response_payload>();
|
344
|
-
} catch (tao::json::pegtl::parse_error&
|
345
|
-
response.ctx.ec =
|
336
|
+
} catch (const tao::json::pegtl::parse_error&) {
|
337
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
346
338
|
return response;
|
347
339
|
}
|
348
340
|
Expects(response.payload.meta_data.client_context_id.empty() ||
|
@@ -356,8 +348,8 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
|
|
356
348
|
tao::json::value row{};
|
357
349
|
try {
|
358
350
|
row = tao::json::from_string(response.payload.rows[0]);
|
359
|
-
} catch (tao::json::pegtl::parse_error&
|
360
|
-
response.ctx.ec =
|
351
|
+
} catch (const tao::json::pegtl::parse_error&) {
|
352
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
361
353
|
return response;
|
362
354
|
}
|
363
355
|
auto* plan = row.find("encoded_plan");
|
@@ -366,10 +358,10 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
|
|
366
358
|
request.ctx_->cache.put(request.statement, name->get_string(), plan->get_string());
|
367
359
|
throw couchbase::priv::retry_http_request{};
|
368
360
|
}
|
369
|
-
response.ctx.ec =
|
361
|
+
response.ctx.ec = error::query_errc::prepared_statement_failure;
|
370
362
|
|
371
363
|
} else {
|
372
|
-
response.ctx.ec =
|
364
|
+
response.ctx.ec = error::query_errc::prepared_statement_failure;
|
373
365
|
}
|
374
366
|
}
|
375
367
|
} else {
|
@@ -381,6 +373,7 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
|
|
381
373
|
bool server_timeout = false;
|
382
374
|
bool invalid_argument = false;
|
383
375
|
bool cas_mismatch = false;
|
376
|
+
bool authentication_failure = false;
|
384
377
|
|
385
378
|
if (response.payload.meta_data.errors) {
|
386
379
|
for (const auto& error : *response.payload.meta_data.errors) {
|
@@ -411,6 +404,9 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
|
|
411
404
|
case 12016: /* IKey: "datastore.couchbase.index_not_found" */
|
412
405
|
index_not_found = true;
|
413
406
|
break;
|
407
|
+
case 13014: /* IKey: "datastore.couchbase.insufficient_credentials" */
|
408
|
+
authentication_failure = true;
|
409
|
+
break;
|
414
410
|
default:
|
415
411
|
if ((error.code >= 12000 && error.code < 13000) || (error.code >= 14000 && error.code < 15000)) {
|
416
412
|
index_failure = true;
|
@@ -422,23 +418,25 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
|
|
422
418
|
}
|
423
419
|
}
|
424
420
|
if (syntax_error) {
|
425
|
-
response.ctx.ec =
|
421
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
426
422
|
} else if (invalid_argument) {
|
427
|
-
response.ctx.ec =
|
423
|
+
response.ctx.ec = error::common_errc::invalid_argument;
|
428
424
|
} else if (server_timeout) {
|
429
|
-
response.ctx.ec =
|
425
|
+
response.ctx.ec = error::common_errc::unambiguous_timeout;
|
430
426
|
} else if (prepared_statement_failure) {
|
431
|
-
response.ctx.ec =
|
427
|
+
response.ctx.ec = error::query_errc::prepared_statement_failure;
|
432
428
|
} else if (index_failure) {
|
433
|
-
response.ctx.ec =
|
429
|
+
response.ctx.ec = error::query_errc::index_failure;
|
434
430
|
} else if (planning_failure) {
|
435
|
-
response.ctx.ec =
|
431
|
+
response.ctx.ec = error::query_errc::planning_failure;
|
436
432
|
} else if (index_not_found) {
|
437
|
-
response.ctx.ec =
|
433
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
438
434
|
} else if (cas_mismatch) {
|
439
|
-
response.ctx.ec =
|
435
|
+
response.ctx.ec = error::common_errc::cas_mismatch;
|
436
|
+
} else if (authentication_failure) {
|
437
|
+
response.ctx.ec = error::common_errc::authentication_failure;
|
440
438
|
} else {
|
441
|
-
response.ctx.ec =
|
439
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
442
440
|
}
|
443
441
|
}
|
444
442
|
}
|