couchbase 3.0.0.alpha.5 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -3
- data/README.md +4 -2
- data/Rakefile +1 -1
- data/couchbase.gemspec +17 -12
- data/ext/.idea/misc.xml +12 -0
- data/ext/CMakeLists.txt +10 -1
- data/ext/build_config.hxx.in +20 -0
- data/ext/build_version.hxx.in +1 -1
- data/ext/couchbase/bucket.hxx +90 -24
- data/ext/couchbase/cluster.hxx +125 -84
- data/ext/couchbase/cluster_options.hxx +53 -0
- data/ext/couchbase/configuration.hxx +220 -2
- data/ext/couchbase/couchbase.cxx +134 -127
- data/ext/couchbase/io/dns_client.hxx +3 -1
- data/ext/couchbase/io/http_command.hxx +91 -0
- data/ext/couchbase/io/http_session.hxx +58 -19
- data/ext/couchbase/io/http_session_manager.hxx +26 -31
- data/ext/couchbase/io/mcbp_command.hxx +180 -0
- data/ext/couchbase/io/mcbp_message.hxx +5 -0
- data/ext/couchbase/io/mcbp_session.hxx +213 -98
- data/ext/couchbase/io/streams.hxx +165 -0
- data/ext/couchbase/operations.hxx +1 -1
- data/ext/couchbase/operations/analytics_dataset_create.hxx +1 -1
- data/ext/couchbase/operations/bucket_create.hxx +4 -2
- data/ext/couchbase/operations/bucket_drop.hxx +4 -2
- data/ext/couchbase/operations/bucket_flush.hxx +4 -2
- data/ext/couchbase/operations/bucket_get.hxx +4 -2
- data/ext/couchbase/operations/bucket_get_all.hxx +4 -2
- data/ext/couchbase/operations/bucket_update.hxx +4 -2
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +4 -2
- data/ext/couchbase/operations/collection_create.hxx +4 -2
- data/ext/couchbase/operations/collection_drop.hxx +4 -2
- data/ext/couchbase/operations/document_analytics.hxx +0 -4
- data/ext/couchbase/operations/document_decrement.hxx +6 -3
- data/ext/couchbase/operations/document_get.hxx +3 -0
- data/ext/couchbase/operations/document_get_and_lock.hxx +3 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +5 -2
- data/ext/couchbase/operations/document_get_projected.hxx +12 -9
- data/ext/couchbase/operations/document_increment.hxx +6 -3
- data/ext/couchbase/operations/document_insert.hxx +5 -2
- data/ext/couchbase/operations/document_lookup_in.hxx +3 -0
- data/ext/couchbase/operations/document_mutate_in.hxx +6 -3
- data/ext/couchbase/operations/document_remove.hxx +3 -0
- data/ext/couchbase/operations/document_replace.hxx +5 -2
- data/ext/couchbase/operations/document_search.hxx +6 -7
- data/ext/couchbase/operations/document_touch.hxx +5 -2
- data/ext/couchbase/operations/document_unlock.hxx +3 -0
- data/ext/couchbase/operations/document_upsert.hxx +5 -2
- data/ext/couchbase/operations/query_index_build_deferred.hxx +3 -3
- data/ext/couchbase/operations/query_index_create.hxx +3 -3
- data/ext/couchbase/operations/query_index_drop.hxx +3 -3
- data/ext/couchbase/operations/query_index_get_all.hxx +3 -3
- data/ext/couchbase/operations/scope_create.hxx +4 -2
- data/ext/couchbase/operations/scope_drop.hxx +4 -2
- data/ext/couchbase/operations/scope_get_all.hxx +4 -2
- data/ext/couchbase/operations/search_index_analyze_document.hxx +2 -2
- data/ext/couchbase/operations/search_index_control_ingest.hxx +2 -2
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +2 -2
- data/ext/couchbase/operations/search_index_control_query.hxx +2 -2
- data/ext/couchbase/operations/search_index_drop.hxx +2 -2
- data/ext/couchbase/operations/search_index_get.hxx +2 -2
- data/ext/couchbase/operations/search_index_get_all.hxx +2 -2
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +2 -2
- data/ext/couchbase/operations/search_index_upsert.hxx +2 -2
- data/ext/couchbase/origin.hxx +148 -0
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +1 -6
- data/ext/couchbase/protocol/cmd_decrement.hxx +5 -5
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +5 -5
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +1 -6
- data/ext/couchbase/protocol/cmd_increment.hxx +5 -5
- data/ext/couchbase/protocol/cmd_info.hxx +0 -11
- data/ext/couchbase/protocol/cmd_insert.hxx +5 -5
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +6 -6
- data/ext/couchbase/protocol/cmd_replace.hxx +5 -5
- data/ext/couchbase/protocol/cmd_touch.hxx +1 -1
- data/ext/couchbase/protocol/cmd_upsert.hxx +5 -5
- data/ext/couchbase/timeout_defaults.hxx +7 -0
- data/ext/couchbase/utils/connection_string.hxx +139 -0
- data/ext/extconf.rb +44 -11
- data/ext/test/main.cxx +93 -15
- data/ext/third_party/http_parser/Makefile +160 -0
- data/ext/third_party/json/Makefile +77 -0
- data/lib/couchbase/analytics_options.rb +18 -4
- data/lib/couchbase/binary_collection.rb +2 -2
- data/lib/couchbase/binary_collection_options.rb +2 -2
- data/lib/couchbase/bucket.rb +4 -4
- data/lib/couchbase/cluster.rb +60 -46
- data/lib/couchbase/collection.rb +13 -13
- data/lib/couchbase/collection_options.rb +15 -9
- data/{bin/console → lib/couchbase/datastructures.rb} +4 -7
- data/lib/couchbase/datastructures/couchbase_list.rb +171 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +205 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +145 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +138 -0
- data/lib/couchbase/errors.rb +66 -63
- data/lib/couchbase/management/user_manager.rb +1 -1
- data/lib/couchbase/mutation_state.rb +1 -0
- data/lib/couchbase/query_options.rb +25 -2
- data/lib/couchbase/scope.rb +0 -7
- data/lib/couchbase/search_options.rb +7 -0
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase/view_options.rb +4 -3
- metadata +20 -82
- data/.github/workflows/tests-6.0.3.yml +0 -52
- data/.github/workflows/tests-dev-preview.yml +0 -55
- data/.github/workflows/tests.yml +0 -50
- data/.gitignore +0 -20
- data/.gitmodules +0 -21
- data/.idea/.gitignore +0 -5
- data/.idea/dictionaries/gem_terms.xml +0 -18
- data/.idea/inspectionProfiles/Project_Default.xml +0 -8
- data/.idea/vcs.xml +0 -13
- data/bin/check-cluster +0 -31
- data/bin/fetch-stats +0 -19
- data/bin/init-cluster +0 -82
- data/bin/jenkins/build-extension +0 -35
- data/bin/jenkins/install-dependencies +0 -47
- data/bin/jenkins/test-with-cbdyncluster +0 -58
- data/bin/setup +0 -24
- data/ext/couchbase/configuration_monitor.hxx +0 -93
- data/ext/couchbase/operations/command.hxx +0 -163
- data/rbi/couchbase.rbi +0 -79
@@ -36,7 +36,7 @@ struct query_index_get_all_response {
|
|
36
36
|
std::vector<std::string> index_key{};
|
37
37
|
std::optional<std::string> condition{};
|
38
38
|
};
|
39
|
-
|
39
|
+
std::string client_context_id;
|
40
40
|
std::error_code ec;
|
41
41
|
std::string status{};
|
42
42
|
std::vector<query_index> indexes{};
|
@@ -49,7 +49,7 @@ struct query_index_get_all_request {
|
|
49
49
|
|
50
50
|
static const inline service_type type = service_type::query;
|
51
51
|
|
52
|
-
|
52
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
53
53
|
std::string bucket_name;
|
54
54
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
55
55
|
|
@@ -61,7 +61,7 @@ struct query_index_get_all_request {
|
|
61
61
|
fmt::format(
|
62
62
|
R"(SELECT idx.* FROM system:indexes AS idx WHERE keyspace_id = "{}" AND `using`="gsi" ORDER BY is_primary DESC, name ASC)",
|
63
63
|
bucket_name) },
|
64
|
-
{ "client_context_id",
|
64
|
+
{ "client_context_id", client_context_id }
|
65
65
|
};
|
66
66
|
encoded.method = "POST";
|
67
67
|
encoded.path = "/query/service";
|
@@ -27,6 +27,7 @@ namespace couchbase::operations
|
|
27
27
|
{
|
28
28
|
|
29
29
|
struct scope_create_response {
|
30
|
+
std::string client_context_id;
|
30
31
|
std::error_code ec;
|
31
32
|
std::uint64_t uid{ 0 };
|
32
33
|
};
|
@@ -41,6 +42,7 @@ struct scope_create_request {
|
|
41
42
|
std::string bucket_name;
|
42
43
|
std::string scope_name;
|
43
44
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
45
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
44
46
|
|
45
47
|
void encode_to(encoded_request_type& encoded)
|
46
48
|
{
|
@@ -52,9 +54,9 @@ struct scope_create_request {
|
|
52
54
|
};
|
53
55
|
|
54
56
|
scope_create_response
|
55
|
-
make_response(std::error_code ec, scope_create_request
|
57
|
+
make_response(std::error_code ec, scope_create_request& request, scope_create_request::encoded_response_type encoded)
|
56
58
|
{
|
57
|
-
scope_create_response response{ ec };
|
59
|
+
scope_create_response response{ request.client_context_id, ec };
|
58
60
|
if (!ec) {
|
59
61
|
switch (encoded.status_code) {
|
60
62
|
case 400:
|
@@ -27,6 +27,7 @@ namespace couchbase::operations
|
|
27
27
|
{
|
28
28
|
|
29
29
|
struct scope_drop_response {
|
30
|
+
std::string client_context_id;
|
30
31
|
std::error_code ec;
|
31
32
|
std::uint64_t uid{ 0 };
|
32
33
|
};
|
@@ -41,6 +42,7 @@ struct scope_drop_request {
|
|
41
42
|
std::string bucket_name;
|
42
43
|
std::string scope_name;
|
43
44
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
45
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
44
46
|
|
45
47
|
void encode_to(encoded_request_type& encoded)
|
46
48
|
{
|
@@ -50,9 +52,9 @@ struct scope_drop_request {
|
|
50
52
|
};
|
51
53
|
|
52
54
|
scope_drop_response
|
53
|
-
make_response(std::error_code ec, scope_drop_request
|
55
|
+
make_response(std::error_code ec, scope_drop_request& request, scope_drop_request::encoded_response_type encoded)
|
54
56
|
{
|
55
|
-
scope_drop_response response{ ec };
|
57
|
+
scope_drop_response response{ request.client_context_id, ec };
|
56
58
|
if (!ec) {
|
57
59
|
switch (encoded.status_code) {
|
58
60
|
case 400:
|
@@ -27,6 +27,7 @@ namespace couchbase::operations
|
|
27
27
|
{
|
28
28
|
|
29
29
|
struct scope_get_all_response {
|
30
|
+
std::string client_context_id;
|
30
31
|
std::error_code ec;
|
31
32
|
collections_manifest manifest{};
|
32
33
|
};
|
@@ -40,6 +41,7 @@ struct scope_get_all_request {
|
|
40
41
|
|
41
42
|
std::string bucket_name;
|
42
43
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
43
45
|
|
44
46
|
void encode_to(encoded_request_type& encoded)
|
45
47
|
{
|
@@ -49,9 +51,9 @@ struct scope_get_all_request {
|
|
49
51
|
};
|
50
52
|
|
51
53
|
scope_get_all_response
|
52
|
-
make_response(std::error_code ec, scope_get_all_request
|
54
|
+
make_response(std::error_code ec, scope_get_all_request& request, scope_get_all_request::encoded_response_type encoded)
|
53
55
|
{
|
54
|
-
scope_get_all_response response{ ec };
|
56
|
+
scope_get_all_response response{ request.client_context_id, ec };
|
55
57
|
if (!ec) {
|
56
58
|
switch (encoded.status_code) {
|
57
59
|
case 400:
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_analyze_document_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::string error{};
|
@@ -38,7 +38,7 @@ struct search_index_analyze_document_request {
|
|
38
38
|
|
39
39
|
static const inline service_type type = service_type::search;
|
40
40
|
|
41
|
-
|
41
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
43
43
|
|
44
44
|
std::string index_name;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_control_ingest_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::string error{};
|
@@ -37,7 +37,7 @@ struct search_index_control_ingest_request {
|
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
40
|
-
|
40
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
41
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
42
|
|
43
43
|
std::string index_name;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_control_plan_freeze_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::string error{};
|
@@ -37,7 +37,7 @@ struct search_index_control_plan_freeze_request {
|
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
40
|
-
|
40
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
41
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
42
|
|
43
43
|
std::string index_name;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_control_query_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::string error{};
|
@@ -37,7 +37,7 @@ struct search_index_control_query_request {
|
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
40
|
-
|
40
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
41
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
42
|
|
43
43
|
std::string index_name;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_drop_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::string error{};
|
@@ -37,7 +37,7 @@ struct search_index_drop_request {
|
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
40
|
-
|
40
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
41
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
42
|
|
43
43
|
std::string index_name;
|
@@ -25,7 +25,7 @@
|
|
25
25
|
namespace couchbase::operations
|
26
26
|
{
|
27
27
|
struct search_index_get_response {
|
28
|
-
|
28
|
+
std::string client_context_id;
|
29
29
|
std::error_code ec;
|
30
30
|
std::string status{};
|
31
31
|
search_index index{};
|
@@ -39,7 +39,7 @@ struct search_index_get_request {
|
|
39
39
|
|
40
40
|
static const inline service_type type = service_type::search;
|
41
41
|
|
42
|
-
|
42
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
43
43
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
44
|
|
45
45
|
std::string index_name;
|
@@ -25,7 +25,7 @@
|
|
25
25
|
namespace couchbase::operations
|
26
26
|
{
|
27
27
|
struct search_index_get_all_response {
|
28
|
-
|
28
|
+
std::string client_context_id;
|
29
29
|
std::error_code ec;
|
30
30
|
std::string status{};
|
31
31
|
std::string impl_version{};
|
@@ -39,7 +39,7 @@ struct search_index_get_all_request {
|
|
39
39
|
|
40
40
|
static const inline service_type type = service_type::search;
|
41
41
|
|
42
|
-
|
42
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
43
43
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
44
|
|
45
45
|
std::string index_name;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_get_documents_count_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::uint64_t count{ 0 };
|
@@ -38,7 +38,7 @@ struct search_index_get_documents_count_request {
|
|
38
38
|
|
39
39
|
static const inline service_type type = service_type::search;
|
40
40
|
|
41
|
-
|
41
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
43
43
|
|
44
44
|
std::string index_name;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
namespace couchbase::operations
|
25
25
|
{
|
26
26
|
struct search_index_upsert_response {
|
27
|
-
|
27
|
+
std::string client_context_id;
|
28
28
|
std::error_code ec;
|
29
29
|
std::string status{};
|
30
30
|
std::string error{};
|
@@ -37,7 +37,7 @@ struct search_index_upsert_request {
|
|
37
37
|
|
38
38
|
static const inline service_type type = service_type::search;
|
39
39
|
|
40
|
-
|
40
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
41
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
42
|
|
43
43
|
search_index index;
|
@@ -0,0 +1,148 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#pragma once
|
19
|
+
|
20
|
+
#include <string>
|
21
|
+
|
22
|
+
#include <utils/connection_string.hxx>
|
23
|
+
|
24
|
+
namespace couchbase
|
25
|
+
{
|
26
|
+
struct origin {
|
27
|
+
using node_entry = std::pair<std::string, std::string>;
|
28
|
+
using node_list = std::vector<node_entry>;
|
29
|
+
|
30
|
+
origin() = default;
|
31
|
+
|
32
|
+
origin(origin&& other) = default;
|
33
|
+
|
34
|
+
origin(const origin& other)
|
35
|
+
: options_(other.options_)
|
36
|
+
, username_(other.username_)
|
37
|
+
, password_(other.password_)
|
38
|
+
, nodes_(other.nodes_)
|
39
|
+
, next_node_(nodes_.begin())
|
40
|
+
{
|
41
|
+
}
|
42
|
+
|
43
|
+
origin(std::string username, std::string password, const std::string& hostname, std::uint16_t port, const cluster_options& options)
|
44
|
+
: options_(options)
|
45
|
+
, username_(std::move(username))
|
46
|
+
, password_(std::move(password))
|
47
|
+
, nodes_{ { hostname, std::to_string(port) } }
|
48
|
+
, next_node_(nodes_.begin())
|
49
|
+
{
|
50
|
+
}
|
51
|
+
|
52
|
+
origin(std::string username, std::string password, const utils::connection_string& connstr)
|
53
|
+
: options_(connstr.options)
|
54
|
+
, username_(std::move(username))
|
55
|
+
, password_(std::move(password))
|
56
|
+
{
|
57
|
+
nodes_.reserve(connstr.bootstrap_nodes.size());
|
58
|
+
for (const auto& node : connstr.bootstrap_nodes) {
|
59
|
+
nodes_.emplace_back(
|
60
|
+
std::make_pair(node.address, node.port > 0 ? std::to_string(node.port) : std::to_string(connstr.default_port)));
|
61
|
+
}
|
62
|
+
next_node_ = nodes_.begin();
|
63
|
+
}
|
64
|
+
|
65
|
+
origin& operator=(const origin& other)
|
66
|
+
{
|
67
|
+
if (this != &other) {
|
68
|
+
options_ = other.options_;
|
69
|
+
username_ = other.username_;
|
70
|
+
password_ = other.password_;
|
71
|
+
nodes_ = other.nodes_;
|
72
|
+
next_node_ = nodes_.begin();
|
73
|
+
exhausted_ = false;
|
74
|
+
}
|
75
|
+
return *this;
|
76
|
+
}
|
77
|
+
|
78
|
+
[[nodiscard]] const std::string& get_username() const
|
79
|
+
{
|
80
|
+
return username_;
|
81
|
+
}
|
82
|
+
|
83
|
+
[[nodiscard]] const std::string& get_password() const
|
84
|
+
{
|
85
|
+
return password_;
|
86
|
+
}
|
87
|
+
|
88
|
+
[[nodiscard]] std::vector<std::string> get_nodes() const
|
89
|
+
{
|
90
|
+
std::vector<std::string> res;
|
91
|
+
res.reserve(nodes_.size());
|
92
|
+
for (const auto &node : nodes_) {
|
93
|
+
res.emplace_back(fmt::format("\"{}:{}\"", node.first, node.second));
|
94
|
+
}
|
95
|
+
return res;
|
96
|
+
}
|
97
|
+
|
98
|
+
void set_nodes(node_list nodes)
|
99
|
+
{
|
100
|
+
nodes_ = std::move(nodes);
|
101
|
+
next_node_ = nodes_.begin();
|
102
|
+
exhausted_ = false;
|
103
|
+
}
|
104
|
+
|
105
|
+
[[nodiscard]] std::pair<std::string, std::string> next_address()
|
106
|
+
{
|
107
|
+
if (exhausted_) {
|
108
|
+
restart();
|
109
|
+
}
|
110
|
+
|
111
|
+
auto address = *next_node_;
|
112
|
+
if (++next_node_ == nodes_.end()) {
|
113
|
+
exhausted_ = true;
|
114
|
+
}
|
115
|
+
return address;
|
116
|
+
}
|
117
|
+
|
118
|
+
[[nodiscard]] bool exhausted() const
|
119
|
+
{
|
120
|
+
return exhausted_;
|
121
|
+
}
|
122
|
+
|
123
|
+
void restart()
|
124
|
+
{
|
125
|
+
exhausted_ = false;
|
126
|
+
next_node_ = nodes_.begin();
|
127
|
+
}
|
128
|
+
|
129
|
+
[[nodiscard]] const couchbase::cluster_options& options() const
|
130
|
+
{
|
131
|
+
return options_;
|
132
|
+
}
|
133
|
+
|
134
|
+
[[nodiscard]] couchbase::cluster_options& options()
|
135
|
+
{
|
136
|
+
return options_;
|
137
|
+
}
|
138
|
+
|
139
|
+
private:
|
140
|
+
couchbase::cluster_options options_{};
|
141
|
+
std::string username_{};
|
142
|
+
std::string password_{};
|
143
|
+
node_list nodes_{};
|
144
|
+
node_list::iterator next_node_{};
|
145
|
+
bool exhausted_{ false };
|
146
|
+
};
|
147
|
+
|
148
|
+
} // namespace couchbase
|
@@ -53,7 +53,7 @@ class cluster_map_change_notification_request_body
|
|
53
53
|
return config_;
|
54
54
|
}
|
55
55
|
|
56
|
-
bool parse(const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info&
|
56
|
+
bool parse(const header_buffer& header, const std::vector<uint8_t>& body, const cmd_info&)
|
57
57
|
{
|
58
58
|
Expects(header[1] == static_cast<uint8_t>(opcode));
|
59
59
|
using offset_type = std::vector<uint8_t>::difference_type;
|
@@ -69,11 +69,6 @@ class cluster_map_change_notification_request_body
|
|
69
69
|
bucket_.assign(body.begin() + offset, body.begin() + offset + key_size);
|
70
70
|
offset += key_size;
|
71
71
|
config_ = tao::json::from_string<deduplicate_keys>(std::string(body.begin() + offset, body.end())).as<configuration>();
|
72
|
-
for (auto& node : config_.nodes) {
|
73
|
-
if (node.this_node && node.hostname.empty()) {
|
74
|
-
node.hostname = info.remote_endpoint.address().to_string();
|
75
|
-
}
|
76
|
-
}
|
77
72
|
return true;
|
78
73
|
}
|
79
74
|
};
|
@@ -85,7 +85,7 @@ class decrement_request_body
|
|
85
85
|
std::vector<std::uint8_t> framing_extras_{};
|
86
86
|
std::uint64_t delta_{ 1 };
|
87
87
|
std::uint64_t initial_value_{ 0 };
|
88
|
-
std::uint32_t
|
88
|
+
std::uint32_t expiry_{ 0 };
|
89
89
|
std::vector<std::uint8_t> extras_{};
|
90
90
|
|
91
91
|
public:
|
@@ -108,9 +108,9 @@ class decrement_request_body
|
|
108
108
|
initial_value_ = value;
|
109
109
|
}
|
110
110
|
|
111
|
-
void
|
111
|
+
void expiry(std::uint32_t value)
|
112
112
|
{
|
113
|
-
|
113
|
+
expiry_ = value;
|
114
114
|
}
|
115
115
|
|
116
116
|
void durability(protocol::durability_level level, std::optional<std::uint16_t> timeout)
|
@@ -167,7 +167,7 @@ class decrement_request_body
|
|
167
167
|
private:
|
168
168
|
void fill_extras()
|
169
169
|
{
|
170
|
-
extras_.resize(sizeof(delta_) + sizeof(initial_value_) + sizeof(
|
170
|
+
extras_.resize(sizeof(delta_) + sizeof(initial_value_) + sizeof(expiry_));
|
171
171
|
using offset_type = std::vector<uint8_t>::difference_type;
|
172
172
|
offset_type offset = 0;
|
173
173
|
|
@@ -179,7 +179,7 @@ class decrement_request_body
|
|
179
179
|
memcpy(extras_.data() + offset, &num, sizeof(num));
|
180
180
|
offset += static_cast<offset_type>(sizeof(delta_));
|
181
181
|
|
182
|
-
std::uint32_t ttl = htonl(
|
182
|
+
std::uint32_t ttl = htonl(expiry_);
|
183
183
|
memcpy(extras_.data() + offset, &ttl, sizeof(ttl));
|
184
184
|
}
|
185
185
|
};
|