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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1b175fc0a102a6d3650e4f15366692f47513063860674a1eda13cfbed527937
|
4
|
+
data.tar.gz: 13c49aac0239d2cb11ef5e941dff5046a339a64928ed664d060b7240902bb17a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 866add2355a3d6dad4ea8b08d8ace7ef14ff6dbd594f375d673efa34865c18501b463acedad02372cded31d6e6d326fdc7a672dc5b5b1d4dc391512bbd8b5f83
|
7
|
+
data.tar.gz: 99e702416cbcb5f767d1ef8fdb82887dfbea658cd8679aa73c2d53e92032fcd69ed7d055104e28686be4dc708502ec2bf1603bb98d6582cc7e936970e6d78331
|
data/README.md
CHANGED
@@ -19,12 +19,12 @@ Please attach version information to ticket/post. To obtain this information use
|
|
19
19
|
|
20
20
|
## Installation
|
21
21
|
|
22
|
-
The library tested with the MRI 2.
|
22
|
+
The library tested with the MRI 2.6, 2.7 and 3.0. Supported platforms are Linux and MacOS.
|
23
23
|
|
24
24
|
Add this line to your application's Gemfile:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
gem "couchbase", "3.
|
27
|
+
gem "couchbase", "3.2.0"
|
28
28
|
```
|
29
29
|
|
30
30
|
And then execute:
|
data/ext/CMakeLists.txt
CHANGED
@@ -71,7 +71,7 @@ add_library(
|
|
71
71
|
target_include_directories(platform PRIVATE ${PROJECT_BINARY_DIR}/generated)
|
72
72
|
target_link_libraries(platform PRIVATE ${PLATFORM_LIBRARIES})
|
73
73
|
|
74
|
-
add_library(cbcrypto OBJECT couchbase/cbcrypto/cbcrypto.cc)
|
74
|
+
add_library(cbcrypto OBJECT couchbase/cbcrypto/cbcrypto.cc couchbase/utils/name_codec.hxx)
|
75
75
|
target_link_libraries(
|
76
76
|
cbcrypto
|
77
77
|
PRIVATE project_options
|
@@ -113,6 +113,7 @@ target_link_libraries(
|
|
113
113
|
cbcrypto
|
114
114
|
cbsasl
|
115
115
|
http_parser
|
116
|
+
hdr_histogram_static
|
116
117
|
snappy
|
117
118
|
spdlog::spdlog_header_only)
|
118
119
|
|
@@ -121,6 +122,7 @@ set_target_properties(
|
|
121
122
|
cbsasl
|
122
123
|
platform
|
123
124
|
snappy
|
125
|
+
hdr_histogram_static
|
124
126
|
PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
125
127
|
|
126
128
|
if(APPLE)
|
data/ext/build_version.hxx.in
CHANGED
@@ -26,5 +26,5 @@ constexpr auto BACKEND_CXX_COMPILER = "@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPIL
|
|
26
26
|
constexpr auto BACKEND_C_COMPILER = "@CMAKE_C_COMPILER_ID@ @CMAKE_C_COMPILER_VERSION@";
|
27
27
|
constexpr auto BACKEND_SYSTEM = "@CMAKE_SYSTEM@";
|
28
28
|
constexpr auto BACKEND_SYSTEM_PROCESSOR = "@CMAKE_SYSTEM_PROCESSOR@";
|
29
|
-
constexpr auto BACKEND_GIT_REVISION = "
|
29
|
+
constexpr auto BACKEND_GIT_REVISION = "6c069e4e6965117c7240b331847dc3f62afe0554";
|
30
30
|
} // namespace couchbase
|
data/ext/cmake/Testing.cmake
CHANGED
@@ -10,6 +10,12 @@ option(SNAPPY_BUILD_TESTS OFF)
|
|
10
10
|
option(SNAPPY_INSTALL OFF)
|
11
11
|
add_subdirectory(third_party/snappy)
|
12
12
|
|
13
|
+
option(HDR_LOG_REQUIRED OFF)
|
14
|
+
option(HDR_HISTOGRAM_BUILD_SHARED OFF)
|
15
|
+
option(HDR_HISTOGRAM_BUILD_PROGRAMS OFF)
|
16
|
+
add_subdirectory(third_party/hdr_histogram_c)
|
17
|
+
include_directories(BEFORE SYSTEM third_party/hdr_histogram_c/src)
|
18
|
+
|
13
19
|
include_directories(BEFORE SYSTEM third_party/gsl/include)
|
14
20
|
include_directories(BEFORE SYSTEM third_party/asio/asio/include)
|
15
21
|
include_directories(BEFORE SYSTEM third_party/json/include)
|
data/ext/cmake/VersionInfo.cmake
CHANGED
data/ext/couchbase/bucket.hxx
CHANGED
@@ -22,6 +22,8 @@
|
|
22
22
|
|
23
23
|
#include <operations.hxx>
|
24
24
|
#include <origin.hxx>
|
25
|
+
#include <tracing/request_tracer.hxx>
|
26
|
+
#include <metrics/meter.hxx>
|
25
27
|
|
26
28
|
namespace couchbase
|
27
29
|
{
|
@@ -31,6 +33,8 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
31
33
|
explicit bucket(const std::string& client_id,
|
32
34
|
asio::io_context& ctx,
|
33
35
|
asio::ssl::context& tls,
|
36
|
+
tracing::request_tracer* tracer,
|
37
|
+
metrics::meter* meter,
|
34
38
|
std::string name,
|
35
39
|
couchbase::origin origin,
|
36
40
|
const std::vector<protocol::hello_feature>& known_features)
|
@@ -38,6 +42,8 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
38
42
|
: client_id_(client_id)
|
39
43
|
, ctx_(ctx)
|
40
44
|
, tls_(tls)
|
45
|
+
, tracer_(tracer)
|
46
|
+
, meter_(meter)
|
41
47
|
, name_(std::move(name))
|
42
48
|
, origin_(std::move(origin))
|
43
49
|
, known_features_(known_features)
|
@@ -80,7 +86,7 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
80
86
|
{
|
81
87
|
if (!config_) {
|
82
88
|
spdlog::debug("{} initialize configuration rev={}", log_prefix_, config.rev_str());
|
83
|
-
} else if (
|
89
|
+
} else if (config_ < config) {
|
84
90
|
spdlog::debug("{} will update the configuration old={} -> new={}", log_prefix_, config_->rev_str(), config.rev_str());
|
85
91
|
} else {
|
86
92
|
return;
|
@@ -98,12 +104,13 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
98
104
|
if (!added.empty() || removed.empty()) {
|
99
105
|
std::map<size_t, std::shared_ptr<io::mcbp_session>> new_sessions{};
|
100
106
|
|
101
|
-
for (auto
|
107
|
+
for (auto& [index, session] : sessions_) {
|
102
108
|
std::size_t new_index = config.nodes.size() + 1;
|
103
109
|
for (const auto& node : config.nodes) {
|
104
|
-
if (
|
105
|
-
|
106
|
-
std::to_string(
|
110
|
+
if (session->bootstrap_hostname() == node.hostname_for(origin_.options().network) &&
|
111
|
+
session->bootstrap_port() ==
|
112
|
+
std::to_string(
|
113
|
+
node.port_or(origin_.options().network, service_type::key_value, origin_.options().enable_tls, 0))) {
|
107
114
|
new_index = node.index;
|
108
115
|
break;
|
109
116
|
}
|
@@ -112,18 +119,18 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
112
119
|
spdlog::debug(R"({} rev={}, preserve session="{}", address="{}:{}")",
|
113
120
|
log_prefix_,
|
114
121
|
config.rev_str(),
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
new_sessions.emplace(new_index, std::move(
|
122
|
+
session->id(),
|
123
|
+
session->bootstrap_hostname(),
|
124
|
+
session->bootstrap_port());
|
125
|
+
new_sessions.emplace(new_index, std::move(session));
|
119
126
|
} else {
|
120
127
|
spdlog::debug(R"({} rev={}, drop session="{}", address="{}:{}")",
|
121
128
|
log_prefix_,
|
122
129
|
config.rev_str(),
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
130
|
+
session->id(),
|
131
|
+
session->bootstrap_hostname(),
|
132
|
+
session->bootstrap_port());
|
133
|
+
session.reset();
|
127
134
|
}
|
128
135
|
}
|
129
136
|
|
@@ -132,8 +139,8 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
132
139
|
continue;
|
133
140
|
}
|
134
141
|
|
135
|
-
auto hostname = node.hostname_for(origin_.options().network);
|
136
|
-
auto port = node.port_or(origin_.options().network, service_type::
|
142
|
+
const auto& hostname = node.hostname_for(origin_.options().network);
|
143
|
+
auto port = node.port_or(origin_.options().network, service_type::key_value, origin_.options().enable_tls, 0);
|
137
144
|
if (port == 0) {
|
138
145
|
continue;
|
139
146
|
}
|
@@ -172,7 +179,7 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
172
179
|
spdlog::debug(R"({} requested to restart session idx={}, which does not exist, ignoring)", log_prefix_, index);
|
173
180
|
return;
|
174
181
|
}
|
175
|
-
auto& old_session = ptr->second;
|
182
|
+
const auto& old_session = ptr->second;
|
176
183
|
auto hostname = old_session->bootstrap_hostname();
|
177
184
|
auto port = old_session->bootstrap_port();
|
178
185
|
auto old_id = old_session->id();
|
@@ -242,7 +249,7 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
242
249
|
auto cmd = std::make_shared<operations::mcbp_command<bucket, Request>>(ctx_, shared_from_this(), request);
|
243
250
|
cmd->start([cmd, handler = std::forward<Handler>(handler)](std::error_code ec, std::optional<io::mcbp_message> msg) mutable {
|
244
251
|
using encoded_response_type = typename Request::encoded_response_type;
|
245
|
-
auto resp = msg ? encoded_response_type(*msg) : encoded_response_type{};
|
252
|
+
auto resp = msg ? encoded_response_type(std::move(*msg)) : encoded_response_type{};
|
246
253
|
error_context::key_value ctx{};
|
247
254
|
ctx.id = cmd->request.id;
|
248
255
|
ctx.opaque = resp.opaque();
|
@@ -280,10 +287,10 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
280
287
|
closed_ = true;
|
281
288
|
|
282
289
|
drain_deferred_queue();
|
283
|
-
for (auto& session : sessions_) {
|
284
|
-
if (session
|
285
|
-
spdlog::debug(R"({} shutdown session session="{}", idx={})", log_prefix_, session
|
286
|
-
session
|
290
|
+
for (auto& [index, session] : sessions_) {
|
291
|
+
if (session) {
|
292
|
+
spdlog::debug(R"({} shutdown session session="{}", idx={})", log_prefix_, session->id(), index);
|
293
|
+
session->stop(io::retry_reason::do_not_retry);
|
287
294
|
}
|
288
295
|
}
|
289
296
|
}
|
@@ -305,13 +312,13 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
305
312
|
std::tie(cmd->request.partition, index) = config_->map_key(cmd->request.id.key);
|
306
313
|
if (index < 0) {
|
307
314
|
return io::retry_orchestrator::maybe_retry(
|
308
|
-
cmd->manager_, cmd, io::retry_reason::node_not_available,
|
315
|
+
cmd->manager_, cmd, io::retry_reason::node_not_available, error::common_errc::request_canceled);
|
309
316
|
}
|
310
317
|
}
|
311
318
|
auto session = sessions_.at(static_cast<std::size_t>(index));
|
312
319
|
if (session->is_stopped()) {
|
313
320
|
return io::retry_orchestrator::maybe_retry(
|
314
|
-
cmd->manager_, cmd, io::retry_reason::node_not_available,
|
321
|
+
cmd->manager_, cmd, io::retry_reason::node_not_available, error::common_errc::request_canceled);
|
315
322
|
}
|
316
323
|
cmd->send_to(session);
|
317
324
|
}
|
@@ -331,30 +338,42 @@ class bucket : public std::enable_shared_from_this<bucket>
|
|
331
338
|
});
|
332
339
|
}
|
333
340
|
|
334
|
-
[[nodiscard]] const std::string& log_prefix()
|
341
|
+
[[nodiscard]] const std::string& log_prefix() const
|
335
342
|
{
|
336
343
|
return log_prefix_;
|
337
344
|
}
|
338
345
|
|
339
346
|
void export_diag_info(diag::diagnostics_result& res) const
|
340
347
|
{
|
341
|
-
for (const auto& session : sessions_) {
|
342
|
-
res.services[service_type::
|
348
|
+
for (const auto& [index, session] : sessions_) {
|
349
|
+
res.services[service_type::key_value].emplace_back(session->diag_info());
|
343
350
|
}
|
344
351
|
}
|
345
352
|
|
346
353
|
template<typename Collector>
|
347
354
|
void ping(std::shared_ptr<Collector> collector)
|
348
355
|
{
|
349
|
-
for (const auto& session : sessions_) {
|
350
|
-
session
|
356
|
+
for (const auto& [index, session] : sessions_) {
|
357
|
+
session->ping(collector->build_reporter());
|
351
358
|
}
|
352
359
|
}
|
353
360
|
|
361
|
+
auto tracer() const
|
362
|
+
{
|
363
|
+
return tracer_;
|
364
|
+
}
|
365
|
+
|
366
|
+
auto meter() const
|
367
|
+
{
|
368
|
+
return meter_;
|
369
|
+
}
|
370
|
+
|
354
371
|
private:
|
355
372
|
std::string client_id_;
|
356
373
|
asio::io_context& ctx_;
|
357
374
|
asio::ssl::context& tls_;
|
375
|
+
tracing::request_tracer* tracer_;
|
376
|
+
metrics::meter* meter_;
|
358
377
|
std::string name_;
|
359
378
|
origin origin_;
|
360
379
|
|
@@ -35,7 +35,7 @@ class Context
|
|
35
35
|
* Get the UUID used for errors by this connection. If none
|
36
36
|
* is created a new one is generated.
|
37
37
|
*/
|
38
|
-
std::string get_uuid();
|
38
|
+
[[nodiscard]] const std::string& get_uuid();
|
39
39
|
|
40
40
|
/**
|
41
41
|
* Do this context contain a UUID?
|
@@ -45,8 +45,8 @@ class Context
|
|
45
45
|
return !uuid.empty();
|
46
46
|
}
|
47
47
|
|
48
|
-
|
48
|
+
private:
|
49
49
|
std::string uuid;
|
50
50
|
};
|
51
51
|
|
52
|
-
} // namespace couchbase::sasl
|
52
|
+
} // namespace couchbase::sasl
|
@@ -21,9 +21,7 @@
|
|
21
21
|
#include <iterator>
|
22
22
|
#include <vector>
|
23
23
|
|
24
|
-
namespace couchbase
|
25
|
-
{
|
26
|
-
namespace sasl
|
24
|
+
namespace couchbase::sasl
|
27
25
|
{
|
28
26
|
|
29
27
|
Mechanism
|
@@ -35,14 +33,13 @@ select_mechanism(const std::vector<std::string>& available_mechanisms)
|
|
35
33
|
{ std::string{ "SCRAM-SHA1" }, Mechanism::SCRAM_SHA1 },
|
36
34
|
{ std::string{ "PLAIN" }, Mechanism::PLAIN } };
|
37
35
|
|
38
|
-
for (const auto&
|
39
|
-
if (std::find(available_mechanisms.begin(), available_mechanisms.end(),
|
40
|
-
return
|
36
|
+
for (const auto& [name, code] : mechs) {
|
37
|
+
if (std::find(available_mechanisms.begin(), available_mechanisms.end(), name) != available_mechanisms.end()) {
|
38
|
+
return code;
|
41
39
|
}
|
42
40
|
}
|
43
41
|
|
44
42
|
throw unknown_mechanism("unknown mechanism"); // TODO: avoid this exception
|
45
43
|
}
|
46
44
|
|
47
|
-
} // namespace sasl
|
48
|
-
} // namespace couchbase
|
45
|
+
} // namespace couchbase::sasl
|
@@ -31,10 +31,7 @@ enum class Mechanism { SCRAM_SHA512, SCRAM_SHA256, SCRAM_SHA1, PLAIN };
|
|
31
31
|
class unknown_mechanism : public std::invalid_argument
|
32
32
|
{
|
33
33
|
public:
|
34
|
-
|
35
|
-
: std::invalid_argument(msg)
|
36
|
-
{
|
37
|
-
}
|
34
|
+
using std::invalid_argument::invalid_argument;
|
38
35
|
};
|
39
36
|
|
40
37
|
/**
|
@@ -30,7 +30,7 @@ ClientBackend::start()
|
|
30
30
|
buffer.push_back(0);
|
31
31
|
std::copy(passwd.begin(), passwd.end(), std::back_inserter(buffer));
|
32
32
|
|
33
|
-
return
|
33
|
+
return { error::OK, { buffer.data(), buffer.size() } };
|
34
34
|
}
|
35
35
|
|
36
36
|
} // namespace couchbase::sasl::mechanism::plain
|
@@ -27,11 +27,8 @@
|
|
27
27
|
#include <cbsasl/scram-sha/stringutils.h>
|
28
28
|
|
29
29
|
#include <cstring>
|
30
|
-
#include <gsl/gsl>
|
31
|
-
#include <iomanip>
|
32
30
|
#include <iostream>
|
33
31
|
#include <map>
|
34
|
-
#include <memory>
|
35
32
|
#include <set>
|
36
33
|
#include <sstream>
|
37
34
|
#include <string>
|
@@ -80,10 +77,10 @@ decodeAttributeList(const std::string& list, AttributeMap& attributes)
|
|
80
77
|
|
81
78
|
auto comma = list.find(',', pos);
|
82
79
|
if (comma == std::string::npos) {
|
83
|
-
attributes.
|
80
|
+
attributes.try_emplace(key, list.substr(pos));
|
84
81
|
pos = list.length();
|
85
82
|
} else {
|
86
|
-
attributes.
|
83
|
+
attributes.try_emplace(key, list.substr(pos, comma - pos));
|
87
84
|
pos = comma + 1;
|
88
85
|
}
|
89
86
|
}
|
@@ -188,7 +185,6 @@ ScramShaBackend::addAttribute(std::ostream& out, char key, int value, bool more)
|
|
188
185
|
case 'e': // error message
|
189
186
|
throw std::invalid_argument("ScramShaBackend::addAttribute:"
|
190
187
|
" Invalid value (should not be int)");
|
191
|
-
break;
|
192
188
|
|
193
189
|
case 'i': // iterator count
|
194
190
|
out << value;
|
@@ -284,14 +280,14 @@ ClientBackend::start()
|
|
284
280
|
client_first_message = out.str();
|
285
281
|
client_first_message_bare = client_first_message.substr(3); // skip n,,
|
286
282
|
|
287
|
-
return
|
283
|
+
return { error::OK, client_first_message };
|
288
284
|
}
|
289
285
|
|
290
286
|
std::pair<error, std::string_view>
|
291
287
|
ClientBackend::step(std::string_view input)
|
292
288
|
{
|
293
289
|
if (input.empty()) {
|
294
|
-
return
|
290
|
+
return { error::BAD_PARAM, {} };
|
295
291
|
}
|
296
292
|
|
297
293
|
if (server_first_message.empty()) {
|
@@ -299,7 +295,7 @@ ClientBackend::step(std::string_view input)
|
|
299
295
|
|
300
296
|
AttributeMap attributes;
|
301
297
|
if (!decodeAttributeList(server_first_message, attributes)) {
|
302
|
-
return
|
298
|
+
return { error::BAD_PARAM, {} };
|
303
299
|
}
|
304
300
|
|
305
301
|
for (const auto& attribute : attributes) {
|
@@ -314,24 +310,24 @@ ClientBackend::step(std::string_view input)
|
|
314
310
|
try {
|
315
311
|
iterationCount = static_cast<unsigned int>(std::stoul(attribute.second));
|
316
312
|
} catch (...) {
|
317
|
-
return
|
313
|
+
return { error::BAD_PARAM, {} };
|
318
314
|
}
|
319
315
|
break;
|
320
316
|
default:
|
321
|
-
return
|
317
|
+
return { error::BAD_PARAM, {} };
|
322
318
|
}
|
323
319
|
}
|
324
320
|
|
325
321
|
if (attributes.find('r') == attributes.end() || attributes.find('s') == attributes.end() ||
|
326
322
|
attributes.find('i') == attributes.end()) {
|
327
323
|
spdlog::error("missing r/s/i in server message");
|
328
|
-
return
|
324
|
+
return { error::BAD_PARAM, {} };
|
329
325
|
}
|
330
326
|
|
331
327
|
// I've got the SALT, lets generate the salted password
|
332
328
|
if (!generateSaltedPassword(passwordCallback())) {
|
333
329
|
spdlog::error("failed to generated salted password");
|
334
|
-
return
|
330
|
+
return { error::FAIL, {} };
|
335
331
|
}
|
336
332
|
|
337
333
|
// Ok so we have salted hased password :D
|
@@ -346,34 +342,32 @@ ClientBackend::step(std::string_view input)
|
|
346
342
|
|
347
343
|
client_final_message = out.str();
|
348
344
|
|
349
|
-
return
|
350
|
-
}
|
351
|
-
|
352
|
-
|
353
|
-
AttributeMap attributes;
|
354
|
-
if (!decodeAttributeList(server_final_message, attributes)) {
|
355
|
-
spdlog::error("SCRAM: failed to decode server-final-message");
|
356
|
-
return std::make_pair<error, std::string_view>(error::BAD_PARAM, {});
|
357
|
-
}
|
345
|
+
return { error::CONTINUE, client_final_message };
|
346
|
+
}
|
347
|
+
server_final_message.assign(input.data(), input.size());
|
358
348
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
}
|
349
|
+
AttributeMap attributes;
|
350
|
+
if (!decodeAttributeList(server_final_message, attributes)) {
|
351
|
+
spdlog::error("SCRAM: failed to decode server-final-message");
|
352
|
+
return { error::BAD_PARAM, {} };
|
353
|
+
}
|
363
354
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
355
|
+
if (attributes.find('e') != attributes.end()) {
|
356
|
+
spdlog::error("failed to authenticate: {}", attributes['e']);
|
357
|
+
return { error::FAIL, {} };
|
358
|
+
}
|
368
359
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
}
|
360
|
+
if (attributes.find('v') == attributes.end()) {
|
361
|
+
spdlog::error("syntax error server final message is missing 'v'");
|
362
|
+
return { error::BAD_PARAM, {} };
|
363
|
+
}
|
374
364
|
|
375
|
-
|
365
|
+
if (auto encoded = couchbase::base64::encode(getServerSignature()); encoded != attributes['v']) {
|
366
|
+
spdlog::error("incorrect ServerKey received");
|
367
|
+
return { error::FAIL, {} };
|
376
368
|
}
|
369
|
+
|
370
|
+
return { error::OK, {} };
|
377
371
|
}
|
378
372
|
|
379
373
|
bool
|