couchbase 4.2.5-dev.3 → 4.2.6-dev
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.
- package/README.md +81 -9
- package/deps/couchbase-cxx-client/CMakeLists.txt +9 -1
- package/deps/couchbase-cxx-client/bin/api.rb +234 -0
- package/deps/couchbase-cxx-client/bin/create-search-index +18 -135
- package/deps/couchbase-cxx-client/bin/init-cluster +17 -139
- package/deps/couchbase-cxx-client/bin/load-sample-buckets +54 -0
- package/deps/couchbase-cxx-client/core/cluster.hxx +33 -12
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +3 -0
- package/deps/couchbase-cxx-client/core/crud_component.cxx +51 -22
- package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +115 -50
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +6 -0
- package/deps/couchbase-cxx-client/core/impl/create_bucket.cxx +155 -0
- package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +172 -59
- package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/drop_bucket.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +138 -59
- package/deps/couchbase-cxx-client/core/impl/flush_bucket.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/get_all_buckets.cxx +163 -0
- package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +67 -37
- package/deps/couchbase-cxx-client/core/impl/get_bucket.cxx +153 -0
- package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.cxx +113 -0
- package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.hxx +60 -0
- package/deps/couchbase-cxx-client/core/impl/key_value_error_category.cxx +2 -4
- package/deps/couchbase-cxx-client/core/impl/manager_error_context.cxx +100 -0
- package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/update_bucket.cxx +130 -0
- package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +53 -29
- package/deps/couchbase-cxx-client/core/io/dns_client.cxx +71 -38
- package/deps/couchbase-cxx-client/core/io/dns_config.cxx +5 -4
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +5 -6
- package/deps/couchbase-cxx-client/core/meta/features.hxx +6 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +11 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
- package/deps/couchbase-cxx-client/core/origin.cxx +270 -0
- package/deps/couchbase-cxx-client/core/origin.hxx +2 -0
- package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -2
- package/deps/couchbase-cxx-client/core/range_scan_options.cxx +3 -27
- package/deps/couchbase-cxx-client/core/range_scan_options.hxx +13 -17
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +367 -170
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +13 -2
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +5 -3
- package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -19
- package/deps/couchbase-cxx-client/core/scan_result.cxx +19 -5
- package/deps/couchbase-cxx-client/core/scan_result.hxx +5 -2
- package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +2 -3
- package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +1 -0
- package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +2 -0
- package/deps/couchbase-cxx-client/core/topology/collections_manifest_fmt.hxx +1 -1
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +5 -0
- package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +2 -0
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +4 -0
- package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +19 -2
- package/deps/couchbase-cxx-client/couchbase/bucket_manager.hxx +135 -0
- package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +0 -30
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +14 -0
- package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +7 -48
- package/deps/couchbase-cxx-client/couchbase/create_bucket_options.hxx +41 -0
- package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +0 -29
- package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +0 -33
- package/deps/couchbase-cxx-client/couchbase/drop_bucket_options.hxx +41 -0
- package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +0 -30
- package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +0 -31
- package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -2
- package/deps/couchbase-cxx-client/couchbase/flush_bucket_options.hxx +41 -0
- package/deps/couchbase-cxx-client/couchbase/get_all_buckets_options.hxx +44 -0
- package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +0 -30
- package/deps/couchbase-cxx-client/couchbase/get_bucket_options.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +116 -0
- package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +29 -53
- package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +16 -83
- package/deps/couchbase-cxx-client/couchbase/query_options.hxx +18 -0
- package/deps/couchbase-cxx-client/couchbase/security_options.hxx +15 -0
- package/deps/couchbase-cxx-client/couchbase/update_bucket_options.hxx +41 -0
- package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +0 -31
- package/deps/couchbase-cxx-client/docs/cbc-analytics.md +1 -0
- package/deps/couchbase-cxx-client/docs/cbc-get.md +1 -0
- package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +1 -0
- package/deps/couchbase-cxx-client/docs/cbc-query.md +1 -0
- package/deps/couchbase-cxx-client/docs/cbc.md +10 -0
- package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +6 -0
- package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +5 -0
- package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +137 -1
- package/deps/couchbase-cxx-client/test/test_integration_management.cxx +709 -266
- package/deps/couchbase-cxx-client/test/test_integration_query.cxx +19 -7
- package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +351 -112
- package/deps/couchbase-cxx-client/test/test_integration_search.cxx +10 -1
- package/deps/couchbase-cxx-client/test/test_transaction_public_async_api.cxx +13 -12
- package/deps/couchbase-cxx-client/test/test_transaction_public_blocking_api.cxx +27 -21
- package/deps/couchbase-cxx-client/test/test_unit_query.cxx +75 -0
- package/deps/couchbase-cxx-client/test/utils/server_version.hxx +5 -0
- package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +29 -10
- package/deps/couchbase-cxx-client/test/utils/wait_until.hxx +3 -1
- package/deps/couchbase-cxx-client/tools/utils.cxx +4 -1
- package/dist/binding.d.ts +21 -16
- package/dist/binding.js +1 -4
- package/dist/bindingutilities.d.ts +6 -1
- package/dist/bindingutilities.js +36 -1
- package/dist/collection.d.ts +65 -3
- package/dist/collection.js +107 -0
- package/dist/crudoptypes.d.ts +34 -0
- package/dist/crudoptypes.js +18 -1
- package/dist/queryexecutor.js +1 -0
- package/dist/querytypes.d.ts +7 -0
- package/dist/rangeScan.d.ts +107 -0
- package/dist/rangeScan.js +91 -0
- package/dist/streamablepromises.d.ts +6 -0
- package/dist/streamablepromises.js +25 -1
- package/package.json +13 -14
- package/scripts/createPlatformPackages.js +1 -4
- package/src/addondata.hpp +1 -0
- package/src/binding.cpp +5 -2
- package/src/connection.cpp +108 -2
- package/src/connection.hpp +1 -0
- package/src/constants.cpp +2 -12
- package/src/jstocbpp_autogen.hpp +49 -22
- package/src/jstocbpp_basic.hpp +2 -8
- package/src/mutationtoken.cpp +13 -0
- package/src/scan_iterator.cpp +90 -0
- package/src/scan_iterator.hpp +30 -0
- package/tools/gen-bindings-json.py +9 -8
- package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +0 -93
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
#include "range_scan_options.hxx"
|
|
19
19
|
#include "range_scan_orchestrator_options.hxx"
|
|
20
20
|
#include "scan_result.hxx"
|
|
21
|
+
#include "topology/configuration.hxx"
|
|
21
22
|
|
|
22
23
|
#include <tl/expected.hpp>
|
|
23
24
|
|
|
@@ -34,15 +35,25 @@ namespace couchbase::core
|
|
|
34
35
|
class agent;
|
|
35
36
|
class range_scan_orchestrator_impl;
|
|
36
37
|
|
|
38
|
+
class scan_stream_manager
|
|
39
|
+
{
|
|
40
|
+
public:
|
|
41
|
+
virtual ~scan_stream_manager() = default;
|
|
42
|
+
virtual void stream_start_failed(std::int16_t node_id, bool fatal) = 0;
|
|
43
|
+
virtual void stream_start_failed_awaiting_retry(std::int16_t node_id, std::uint16_t vbucket_id) = 0;
|
|
44
|
+
virtual void stream_continue_failed(std::int16_t node_id, bool fatal) = 0;
|
|
45
|
+
virtual void stream_completed(std::int16_t node_id) = 0;
|
|
46
|
+
};
|
|
47
|
+
|
|
37
48
|
class range_scan_orchestrator
|
|
38
49
|
{
|
|
39
50
|
public:
|
|
40
51
|
range_scan_orchestrator(asio::io_context& io,
|
|
41
52
|
agent kv_provider,
|
|
42
|
-
|
|
53
|
+
topology::configuration::vbucket_map vbucket_map,
|
|
43
54
|
std::string scope_name,
|
|
44
55
|
std::string collection_name,
|
|
45
|
-
std::variant<std::monostate, range_scan, sampling_scan> scan_type,
|
|
56
|
+
std::variant<std::monostate, range_scan, prefix_scan, sampling_scan> scan_type,
|
|
46
57
|
range_scan_orchestrator_options options);
|
|
47
58
|
|
|
48
59
|
auto scan() -> tl::expected<scan_result, std::error_code>;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#pragma once
|
|
17
17
|
|
|
18
18
|
#include "scan_options.hxx"
|
|
19
|
+
#include "timeout_defaults.hxx"
|
|
19
20
|
|
|
20
21
|
#include <couchbase/mutation_token.hxx>
|
|
21
22
|
#include <couchbase/retry_strategy.hxx>
|
|
@@ -40,15 +41,16 @@ namespace couchbase::core
|
|
|
40
41
|
{
|
|
41
42
|
|
|
42
43
|
struct range_scan_orchestrator_options {
|
|
44
|
+
static constexpr std::uint16_t default_concurrency{ 1 };
|
|
45
|
+
|
|
43
46
|
bool ids_only{ false };
|
|
44
47
|
std::optional<mutation_state> consistent_with{};
|
|
45
|
-
scan_sort sort{ scan_sort::none };
|
|
46
48
|
std::uint32_t batch_item_limit{ range_scan_continue_options::default_batch_item_limit };
|
|
47
49
|
std::uint32_t batch_byte_limit{ range_scan_continue_options::default_batch_byte_limit };
|
|
48
|
-
std::
|
|
50
|
+
std::uint16_t concurrency{ default_concurrency };
|
|
49
51
|
|
|
50
52
|
std::shared_ptr<couchbase::retry_strategy> retry_strategy{ nullptr };
|
|
51
|
-
std::chrono::milliseconds timeout{};
|
|
53
|
+
std::chrono::milliseconds timeout{ timeout_defaults::key_value_scan_timeout };
|
|
52
54
|
std::shared_ptr<couchbase::tracing::request_span> parent_span{};
|
|
53
55
|
};
|
|
54
56
|
} // namespace couchbase::core
|
|
@@ -38,26 +38,7 @@ class request_span;
|
|
|
38
38
|
|
|
39
39
|
namespace couchbase::core
|
|
40
40
|
{
|
|
41
|
-
|
|
42
|
-
enum class scan_sort {
|
|
43
|
-
none,
|
|
44
|
-
ascending,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
41
|
struct mutation_state {
|
|
48
42
|
std::vector<couchbase::mutation_token> tokens;
|
|
49
43
|
};
|
|
50
|
-
|
|
51
|
-
struct scan_options {
|
|
52
|
-
bool ids_only{ false };
|
|
53
|
-
std::optional<mutation_state> consistent_with{};
|
|
54
|
-
scan_sort sort{ scan_sort::none };
|
|
55
|
-
std::uint32_t batch_item_limit{ range_scan_continue_options::default_batch_item_limit };
|
|
56
|
-
std::uint32_t batch_byte_limit{ range_scan_continue_options::default_batch_byte_limit };
|
|
57
|
-
std::chrono::milliseconds batch_time_limit{ range_scan_continue_options::default_batch_time_limit };
|
|
58
|
-
|
|
59
|
-
std::shared_ptr<couchbase::retry_strategy> retry_strategy{ nullptr };
|
|
60
|
-
std::chrono::milliseconds timeout{};
|
|
61
|
-
std::shared_ptr<couchbase::tracing::request_span> parent_span{};
|
|
62
|
-
};
|
|
63
44
|
} // namespace couchbase::core
|
|
@@ -32,10 +32,7 @@ class scan_result_impl
|
|
|
32
32
|
|
|
33
33
|
[[nodiscard]] auto next() const -> tl::expected<range_scan_item, std::error_code>
|
|
34
34
|
{
|
|
35
|
-
|
|
36
|
-
return item.value();
|
|
37
|
-
}
|
|
38
|
-
return tl::unexpected{ errc::key_value::range_scan_completed };
|
|
35
|
+
return iterator_->next().get();
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
void next(utils::movable_function<void(range_scan_item, std::error_code)> callback) const
|
|
@@ -43,6 +40,16 @@ class scan_result_impl
|
|
|
43
40
|
return iterator_->next(std::move(callback));
|
|
44
41
|
}
|
|
45
42
|
|
|
43
|
+
void cancel()
|
|
44
|
+
{
|
|
45
|
+
return iterator_->cancel();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[[nodiscard]] auto is_cancelled() -> bool
|
|
49
|
+
{
|
|
50
|
+
return iterator_->is_cancelled();
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
private:
|
|
47
54
|
std::shared_ptr<range_scan_item_iterator> iterator_;
|
|
48
55
|
};
|
|
@@ -65,7 +72,14 @@ scan_result::next(utils::movable_function<void(range_scan_item, std::error_code)
|
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
void
|
|
68
|
-
scan_result::cancel()
|
|
75
|
+
scan_result::cancel()
|
|
76
|
+
{
|
|
77
|
+
return impl_->cancel();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
auto
|
|
81
|
+
scan_result::is_cancelled() -> bool
|
|
69
82
|
{
|
|
83
|
+
return impl_->is_cancelled();
|
|
70
84
|
}
|
|
71
85
|
} // namespace couchbase::core
|
|
@@ -41,8 +41,10 @@ class range_scan_item_iterator
|
|
|
41
41
|
{
|
|
42
42
|
public:
|
|
43
43
|
virtual ~range_scan_item_iterator() = default;
|
|
44
|
-
virtual auto next() -> std::future<
|
|
44
|
+
virtual auto next() -> std::future<tl::expected<range_scan_item, std::error_code>> = 0;
|
|
45
45
|
virtual void next(utils::movable_function<void(range_scan_item, std::error_code)> callback) = 0;
|
|
46
|
+
virtual void cancel() = 0;
|
|
47
|
+
virtual bool is_cancelled() = 0;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
class scan_result
|
|
@@ -51,7 +53,8 @@ class scan_result
|
|
|
51
53
|
explicit scan_result(std::shared_ptr<range_scan_item_iterator> iterator);
|
|
52
54
|
[[nodiscard]] auto next() const -> tl::expected<range_scan_item, std::error_code>;
|
|
53
55
|
void next(utils::movable_function<void(range_scan_item, std::error_code)> callback) const;
|
|
54
|
-
void cancel()
|
|
56
|
+
void cancel();
|
|
57
|
+
[[nodiscard]] auto is_cancelled() -> bool;
|
|
55
58
|
|
|
56
59
|
private:
|
|
57
60
|
std::shared_ptr<scan_result_impl> impl_{};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2020-
|
|
3
|
+
* Copyright 2020-2023 Couchbase, Inc.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -27,6 +27,7 @@ constexpr std::chrono::milliseconds resolve_timeout{ 2'000 };
|
|
|
27
27
|
constexpr std::chrono::milliseconds connect_timeout{ 2'000 };
|
|
28
28
|
constexpr std::chrono::milliseconds key_value_timeout{ 2'500 };
|
|
29
29
|
constexpr std::chrono::milliseconds key_value_durable_timeout{ 10'000 };
|
|
30
|
+
constexpr std::chrono::milliseconds key_value_scan_timeout{ 75'000 };
|
|
30
31
|
constexpr std::chrono::milliseconds view_timeout{ 75'000 };
|
|
31
32
|
constexpr std::chrono::milliseconds query_timeout{ 75'000 };
|
|
32
33
|
constexpr std::chrono::milliseconds analytics_timeout{ 75'000 };
|
|
@@ -34,8 +35,6 @@ constexpr std::chrono::milliseconds search_timeout{ 75'000 };
|
|
|
34
35
|
constexpr std::chrono::milliseconds management_timeout{ 75'000 };
|
|
35
36
|
constexpr std::chrono::milliseconds eventing_timeout{ 75'000 };
|
|
36
37
|
|
|
37
|
-
constexpr std::chrono::milliseconds range_scan_timeout{ 75'000 };
|
|
38
|
-
|
|
39
38
|
constexpr std::chrono::milliseconds dns_srv_timeout{ 500 };
|
|
40
39
|
constexpr std::chrono::milliseconds tcp_keep_alive_interval{ 60'000 };
|
|
41
40
|
constexpr std::chrono::milliseconds config_poll_interval{ 2'500 };
|
|
@@ -100,6 +100,8 @@ struct fmt::formatter<couchbase::core::cluster_capability> {
|
|
|
100
100
|
case couchbase::core::cluster_capability::n1ql_enhanced_prepared_statements:
|
|
101
101
|
name = "n1ql_enhanced_prepared_statements";
|
|
102
102
|
break;
|
|
103
|
+
case couchbase::core::cluster_capability::n1ql_read_from_replica:
|
|
104
|
+
name = "n1ql_read_from_replica";
|
|
103
105
|
}
|
|
104
106
|
return format_to(ctx.out(), "{}", name);
|
|
105
107
|
}
|
|
@@ -47,6 +47,6 @@ struct fmt::formatter<couchbase::core::topology::collections_manifest> {
|
|
|
47
47
|
couchbase::core::uuid::to_string(manifest.id),
|
|
48
48
|
manifest.uid,
|
|
49
49
|
collections.size(),
|
|
50
|
-
utils::join_strings(collections, ", "));
|
|
50
|
+
couchbase::core::utils::join_strings(collections, ", "));
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -112,6 +112,11 @@ struct configuration {
|
|
|
112
112
|
return cluster_capabilities.find(cluster_capability::n1ql_enhanced_prepared_statements) != cluster_capabilities.end();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
[[nodiscard]] bool supports_read_from_replica() const
|
|
116
|
+
{
|
|
117
|
+
return cluster_capabilities.find(cluster_capability::n1ql_read_from_replica) != cluster_capabilities.end();
|
|
118
|
+
}
|
|
119
|
+
|
|
115
120
|
[[nodiscard]] bool ephemeral() const
|
|
116
121
|
{
|
|
117
122
|
// Use bucket capabilities to identify if couchapi is missing (then its ephemeral). If its null then
|
|
@@ -249,6 +249,8 @@ struct traits<couchbase::core::topology::configuration> {
|
|
|
249
249
|
result.cluster_capabilities.insert(couchbase::core::cluster_capability::n1ql_inline_functions);
|
|
250
250
|
} else if (name == "enhancedPreparedStatements") {
|
|
251
251
|
result.cluster_capabilities.insert(couchbase::core::cluster_capability::n1ql_enhanced_prepared_statements);
|
|
252
|
+
} else if (name == "readFromReplica") {
|
|
253
|
+
result.cluster_capabilities.insert(couchbase::core::cluster_capability::n1ql_read_from_replica);
|
|
252
254
|
}
|
|
253
255
|
}
|
|
254
256
|
}
|
|
@@ -415,6 +415,10 @@ extract_options(connection_string& connstr)
|
|
|
415
415
|
parse_option(connstr.options.tls_verify, name, value, connstr.warnings);
|
|
416
416
|
} else if (name == "disable_mozilla_ca_certificates") {
|
|
417
417
|
parse_option(connstr.options.disable_mozilla_ca_certificates, name, value, connstr.warnings);
|
|
418
|
+
} else if (name == "tls_disable_deprecated_protocols") {
|
|
419
|
+
parse_option(connstr.options.tls_disable_deprecated_protocols, name, value, connstr.warnings);
|
|
420
|
+
} else if (name == "tls_disable_v1_2") {
|
|
421
|
+
parse_option(connstr.options.tls_disable_v1_2, name, value, connstr.warnings);
|
|
418
422
|
} else if (name == "user_agent_extra") {
|
|
419
423
|
/**
|
|
420
424
|
* string, that will be appended to identification fields of the server protocols (key in HELO packet for MCBP, "user-agent"
|
|
@@ -60,6 +60,21 @@ class behavior_options
|
|
|
60
60
|
return *this;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Selects network to use.
|
|
65
|
+
*
|
|
66
|
+
* @param name network name as it is exposed in the configuration.
|
|
67
|
+
* @return this object for chaining purposes.
|
|
68
|
+
*
|
|
69
|
+
* @see https://docs.couchbase.com/server/current/learn/clusters-and-availability/connectivity.html#alternate-addresses
|
|
70
|
+
* @see https://docs.couchbase.com/server/current/rest-api/rest-set-up-alternate-address.html
|
|
71
|
+
*/
|
|
72
|
+
auto network(std::string name) -> behavior_options&
|
|
73
|
+
{
|
|
74
|
+
network_ = std::move(name);
|
|
75
|
+
return *this;
|
|
76
|
+
}
|
|
77
|
+
|
|
63
78
|
struct built {
|
|
64
79
|
std::string user_agent_extra;
|
|
65
80
|
bool show_queries;
|
|
@@ -67,13 +82,14 @@ class behavior_options
|
|
|
67
82
|
bool enable_mutation_tokens;
|
|
68
83
|
bool enable_unordered_execution;
|
|
69
84
|
bool dump_configuration;
|
|
85
|
+
std::string network;
|
|
70
86
|
};
|
|
71
87
|
|
|
72
88
|
[[nodiscard]] auto build() const -> built
|
|
73
89
|
{
|
|
74
90
|
return {
|
|
75
|
-
user_agent_extra_,
|
|
76
|
-
|
|
91
|
+
user_agent_extra_, show_queries_, enable_clustermap_notification_, enable_mutation_tokens_, enable_unordered_execution_,
|
|
92
|
+
dump_configuration_, network_,
|
|
77
93
|
};
|
|
78
94
|
}
|
|
79
95
|
|
|
@@ -84,5 +100,6 @@ class behavior_options
|
|
|
84
100
|
bool enable_mutation_tokens_{ true };
|
|
85
101
|
bool enable_unordered_execution_{ true };
|
|
86
102
|
bool dump_configuration_{ false };
|
|
103
|
+
std::string network_{ "auto" };
|
|
87
104
|
};
|
|
88
105
|
} // namespace couchbase
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020-Present 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 <couchbase/create_bucket_options.hxx>
|
|
21
|
+
#include <couchbase/drop_bucket_options.hxx>
|
|
22
|
+
#include <couchbase/flush_bucket_options.hxx>
|
|
23
|
+
#include <couchbase/get_all_buckets_options.hxx>
|
|
24
|
+
#include <couchbase/get_bucket_options.hxx>
|
|
25
|
+
#include <couchbase/update_bucket_options.hxx>
|
|
26
|
+
|
|
27
|
+
#include <future>
|
|
28
|
+
#include <memory>
|
|
29
|
+
|
|
30
|
+
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
|
31
|
+
namespace couchbase::core
|
|
32
|
+
{
|
|
33
|
+
class cluster;
|
|
34
|
+
} // namespace couchbase::core
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
namespace couchbase
|
|
38
|
+
{
|
|
39
|
+
class cluster;
|
|
40
|
+
|
|
41
|
+
class bucket_manager
|
|
42
|
+
{
|
|
43
|
+
public:
|
|
44
|
+
/**
|
|
45
|
+
* Get specific bucket within the cluster
|
|
46
|
+
*
|
|
47
|
+
* @param bucket_name the name of the bucket to get
|
|
48
|
+
* @param options optional parameters
|
|
49
|
+
* @param handler handler that implements @ref get_bucket_handler
|
|
50
|
+
*
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
* @committed
|
|
53
|
+
*/
|
|
54
|
+
void get_bucket(std::string bucket_name, const get_bucket_options& options, get_bucket_handler&& handler) const;
|
|
55
|
+
|
|
56
|
+
[[nodiscard]] auto get_bucket(std::string bucket_name, const get_bucket_options& options = {}) const
|
|
57
|
+
-> std::future<std::pair<manager_error_context, management::cluster::bucket_settings>>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get all buckets on the cluster
|
|
61
|
+
*
|
|
62
|
+
* @param options optional parameters
|
|
63
|
+
* @param handler handler that implements @ref get_all_buckets_handler
|
|
64
|
+
*
|
|
65
|
+
* @since 1.0.0
|
|
66
|
+
* @committed
|
|
67
|
+
*/
|
|
68
|
+
void get_all_buckets(const get_all_buckets_options& options, get_all_buckets_handler&& handler) const;
|
|
69
|
+
|
|
70
|
+
[[nodiscard]] auto get_all_buckets(const get_all_buckets_options& options = {}) const
|
|
71
|
+
-> std::future<std::pair<manager_error_context, std::vector<management::cluster::bucket_settings>>>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create a bucket on the cluster
|
|
75
|
+
*
|
|
76
|
+
* @param bucket_settings the settings for the bucket
|
|
77
|
+
* @param options optional parameters
|
|
78
|
+
* @param handler handler that implements @ref create_bucket_handler
|
|
79
|
+
*/
|
|
80
|
+
void create_bucket(const management::cluster::bucket_settings& bucket_settings,
|
|
81
|
+
const create_bucket_options& options,
|
|
82
|
+
create_bucket_handler&& handler) const;
|
|
83
|
+
|
|
84
|
+
[[nodiscard]] auto create_bucket(const management::cluster::bucket_settings& bucket_settings,
|
|
85
|
+
const create_bucket_options& options = {}) const -> std::future<manager_error_context>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Update an existing bucket
|
|
89
|
+
*
|
|
90
|
+
* @param bucket_settings the settings for the bucket
|
|
91
|
+
* @param options optional parameters
|
|
92
|
+
* @param handler handler that implements @ref update_bucket_handler
|
|
93
|
+
*/
|
|
94
|
+
void update_bucket(const management::cluster::bucket_settings& bucket_settings,
|
|
95
|
+
const update_bucket_options& options,
|
|
96
|
+
update_bucket_handler&& handler) const;
|
|
97
|
+
|
|
98
|
+
[[nodiscard]] auto update_bucket(const management::cluster::bucket_settings& bucket_settings,
|
|
99
|
+
const update_bucket_options& options = {}) const -> std::future<manager_error_context>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Drop an existing bucket
|
|
103
|
+
*
|
|
104
|
+
* @param bucket_name the name of the bucket to drop
|
|
105
|
+
* @param options optional parameters
|
|
106
|
+
* @param handler handler that implements @ref drop_bucket_handler
|
|
107
|
+
*/
|
|
108
|
+
void drop_bucket(std::string bucket_name, const drop_bucket_options& options, drop_bucket_handler&& handler) const;
|
|
109
|
+
|
|
110
|
+
[[nodiscard]] auto drop_bucket(std::string bucket_name, const drop_bucket_options& options = {}) const
|
|
111
|
+
-> std::future<manager_error_context>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Flush an existing bucket
|
|
115
|
+
*
|
|
116
|
+
* @param bucket_name the name of the bucket to flush
|
|
117
|
+
* @param options optional parameters
|
|
118
|
+
* @param handler handler that implements @ref flush_bucket_handler
|
|
119
|
+
*/
|
|
120
|
+
void flush_bucket(std::string bucket_name, const flush_bucket_options& options, flush_bucket_handler&& handler) const;
|
|
121
|
+
|
|
122
|
+
[[nodiscard]] auto flush_bucket(std::string bucket_name, const flush_bucket_options& options = {}) const
|
|
123
|
+
-> std::future<manager_error_context>;
|
|
124
|
+
|
|
125
|
+
private:
|
|
126
|
+
friend class cluster;
|
|
127
|
+
|
|
128
|
+
explicit bucket_manager(std::shared_ptr<couchbase::core::cluster> core)
|
|
129
|
+
: core_(std::move(core))
|
|
130
|
+
{
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
std::shared_ptr<couchbase::core::cluster> core_;
|
|
134
|
+
};
|
|
135
|
+
} // namespace couchbase
|
|
@@ -66,34 +66,4 @@ class build_query_index_options : public common_options<build_query_index_option
|
|
|
66
66
|
* @uncommitted
|
|
67
67
|
*/
|
|
68
68
|
using build_deferred_query_indexes_handler = std::function<void(couchbase::manager_error_context)>;
|
|
69
|
-
|
|
70
|
-
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
|
71
|
-
namespace core
|
|
72
|
-
{
|
|
73
|
-
class cluster;
|
|
74
|
-
class query_context;
|
|
75
|
-
namespace impl
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @since 1.0.0
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
void
|
|
83
|
-
initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> resp1,
|
|
84
|
-
std::string bucket_name,
|
|
85
|
-
build_query_index_options::built options,
|
|
86
|
-
query_context query_ctx,
|
|
87
|
-
std::string collection_name,
|
|
88
|
-
build_deferred_query_indexes_handler&& handler);
|
|
89
|
-
|
|
90
|
-
void
|
|
91
|
-
initiate_build_deferred_indexes(std::shared_ptr<couchbase::core::cluster> resp1,
|
|
92
|
-
std::string bucket_name,
|
|
93
|
-
build_query_index_options::built options,
|
|
94
|
-
build_deferred_query_indexes_handler&& handler);
|
|
95
|
-
|
|
96
|
-
#endif
|
|
97
|
-
} // namespace impl
|
|
98
|
-
} // namespace core
|
|
99
69
|
} // namespace couchbase
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
#include <couchbase/analytics_options.hxx>
|
|
21
21
|
#include <couchbase/bucket.hxx>
|
|
22
|
+
#include <couchbase/bucket_manager.hxx>
|
|
22
23
|
#include <couchbase/cluster_options.hxx>
|
|
23
24
|
#include <couchbase/query_index_manager.hxx>
|
|
24
25
|
#include <couchbase/query_options.hxx>
|
|
@@ -250,6 +251,19 @@ class cluster
|
|
|
250
251
|
return query_index_manager{ core_ };
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Provides access to the bucket management services.
|
|
256
|
+
*
|
|
257
|
+
* @return a manager instance
|
|
258
|
+
*
|
|
259
|
+
* @since 1.0.0
|
|
260
|
+
* @committed
|
|
261
|
+
*/
|
|
262
|
+
[[nodiscard]] auto buckets() const -> bucket_manager
|
|
263
|
+
{
|
|
264
|
+
return bucket_manager{ core_ };
|
|
265
|
+
}
|
|
266
|
+
|
|
253
267
|
/**
|
|
254
268
|
* Provides access to transaction services.
|
|
255
269
|
*
|
|
@@ -64,13 +64,7 @@ class collection_query_index_manager
|
|
|
64
64
|
void get_all_indexes(const get_all_query_indexes_options& options, get_all_query_indexes_handler&& handler) const;
|
|
65
65
|
|
|
66
66
|
[[nodiscard]] auto get_all_indexes(const get_all_query_indexes_options& options) const
|
|
67
|
-
-> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index
|
|
68
|
-
{
|
|
69
|
-
auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>>();
|
|
70
|
-
auto future = barrier->get_future();
|
|
71
|
-
get_all_indexes(options, [barrier](auto ctx, auto resp) { barrier->set_value({ ctx, resp }); });
|
|
72
|
-
return future;
|
|
73
|
-
}
|
|
67
|
+
-> std::future<std::pair<manager_error_context, std::vector<couchbase::management::query::index>>>;
|
|
74
68
|
/**
|
|
75
69
|
* Create an index on the collection.
|
|
76
70
|
*
|
|
@@ -89,13 +83,7 @@ class collection_query_index_manager
|
|
|
89
83
|
|
|
90
84
|
[[nodiscard]] auto create_index(std::string index_name,
|
|
91
85
|
std::vector<std::string> fields,
|
|
92
|
-
const create_query_index_options& options) const -> std::future<manager_error_context
|
|
93
|
-
{
|
|
94
|
-
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
|
95
|
-
auto future = barrier->get_future();
|
|
96
|
-
create_index(std::move(index_name), std::move(fields), options, [barrier](auto ctx) { barrier->set_value(ctx); });
|
|
97
|
-
return future;
|
|
98
|
-
}
|
|
86
|
+
const create_query_index_options& options) const -> std::future<manager_error_context>;
|
|
99
87
|
|
|
100
88
|
/**
|
|
101
89
|
* Create a primary index on a collection.
|
|
@@ -108,13 +96,7 @@ class collection_query_index_manager
|
|
|
108
96
|
*/
|
|
109
97
|
void create_primary_index(const create_primary_query_index_options& options, create_query_index_handler&& handler) const;
|
|
110
98
|
|
|
111
|
-
[[nodiscard]] auto create_primary_index(const create_primary_query_index_options& options) -> std::future<manager_error_context
|
|
112
|
-
{
|
|
113
|
-
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
|
114
|
-
auto future = barrier->get_future();
|
|
115
|
-
create_primary_index(options, [barrier](auto ctx) { barrier->set_value(ctx); });
|
|
116
|
-
return future;
|
|
117
|
-
}
|
|
99
|
+
[[nodiscard]] auto create_primary_index(const create_primary_query_index_options& options) -> std::future<manager_error_context>;
|
|
118
100
|
/**
|
|
119
101
|
* Drop primary index on a collection.
|
|
120
102
|
*
|
|
@@ -126,13 +108,7 @@ class collection_query_index_manager
|
|
|
126
108
|
*/
|
|
127
109
|
void drop_primary_index(const drop_primary_query_index_options& options, drop_query_index_handler&& handler) const;
|
|
128
110
|
|
|
129
|
-
[[nodiscard]] auto drop_primary_index(const drop_primary_query_index_options& options) const -> std::future<manager_error_context
|
|
130
|
-
{
|
|
131
|
-
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
|
132
|
-
auto future = barrier->get_future();
|
|
133
|
-
drop_primary_index(options, [barrier](auto ctx) { barrier->set_value(ctx); });
|
|
134
|
-
return future;
|
|
135
|
-
}
|
|
111
|
+
[[nodiscard]] auto drop_primary_index(const drop_primary_query_index_options& options) const -> std::future<manager_error_context>;
|
|
136
112
|
|
|
137
113
|
/**
|
|
138
114
|
* Drop index in collection.
|
|
@@ -146,13 +122,7 @@ class collection_query_index_manager
|
|
|
146
122
|
*/
|
|
147
123
|
void drop_index(std::string index_name, const drop_query_index_options& options, drop_query_index_handler&& handler) const;
|
|
148
124
|
|
|
149
|
-
[[nodiscard]] auto drop_index(std::string index_name, const drop_query_index_options& options) -> std::future<manager_error_context
|
|
150
|
-
{
|
|
151
|
-
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
|
152
|
-
auto future = barrier->get_future();
|
|
153
|
-
drop_index(std::move(index_name), options, [barrier](auto ctx) { barrier->set_value(ctx); });
|
|
154
|
-
return future;
|
|
155
|
-
}
|
|
125
|
+
[[nodiscard]] auto drop_index(std::string index_name, const drop_query_index_options& options) -> std::future<manager_error_context>;
|
|
156
126
|
/**
|
|
157
127
|
* Builds all currently deferred indexes in this collection.
|
|
158
128
|
*
|
|
@@ -166,13 +136,7 @@ class collection_query_index_manager
|
|
|
166
136
|
*/
|
|
167
137
|
void build_deferred_indexes(const build_query_index_options& options, build_deferred_query_indexes_handler&& handler) const;
|
|
168
138
|
|
|
169
|
-
[[nodiscard]] auto build_deferred_indexes(const build_query_index_options& options) const -> std::future<manager_error_context
|
|
170
|
-
{
|
|
171
|
-
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
|
172
|
-
auto future = barrier->get_future();
|
|
173
|
-
build_deferred_indexes(options, [barrier](auto ctx) { barrier->set_value(std::move(ctx)); });
|
|
174
|
-
return future;
|
|
175
|
-
}
|
|
139
|
+
[[nodiscard]] auto build_deferred_indexes(const build_query_index_options& options) const -> std::future<manager_error_context>;
|
|
176
140
|
|
|
177
141
|
/**
|
|
178
142
|
* Polls the state of a set of indexes, until they all are online.
|
|
@@ -189,12 +153,7 @@ class collection_query_index_manager
|
|
|
189
153
|
watch_query_indexes_handler&& handler) const;
|
|
190
154
|
|
|
191
155
|
[[nodiscard]] auto watch_indexes(std::vector<std::string> index_names, const watch_query_indexes_options& options)
|
|
192
|
-
|
|
193
|
-
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
|
194
|
-
auto future = barrier->get_future();
|
|
195
|
-
watch_indexes(std::move(index_names), options, [barrier](auto ctx) { barrier->set_value(ctx); });
|
|
196
|
-
return future;
|
|
197
|
-
}
|
|
156
|
+
-> std::future<manager_error_context>;
|
|
198
157
|
|
|
199
158
|
private:
|
|
200
159
|
friend class collection;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020-Present 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 <functional>
|
|
21
|
+
#include <memory>
|
|
22
|
+
#include <optional>
|
|
23
|
+
#include <string>
|
|
24
|
+
|
|
25
|
+
namespace couchbase
|
|
26
|
+
{
|
|
27
|
+
struct create_bucket_options : public common_options<create_bucket_options> {
|
|
28
|
+
public:
|
|
29
|
+
struct built : public common_options<create_bucket_options>::built {
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
[[nodiscard]] auto build() const -> built
|
|
33
|
+
{
|
|
34
|
+
return { build_common_options() };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
using create_bucket_handler = std::function<void(couchbase::manager_error_context)>;
|
|
41
|
+
} // namespace couchbase
|
|
@@ -134,33 +134,4 @@ class create_primary_query_index_options : public common_options<create_primary_
|
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
136
|
using create_primary_query_index_handler = std::function<void(couchbase::manager_error_context)>;
|
|
137
|
-
|
|
138
|
-
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
|
139
|
-
namespace core
|
|
140
|
-
{
|
|
141
|
-
class cluster;
|
|
142
|
-
class query_context;
|
|
143
|
-
namespace impl
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @since 1.0.0
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
void
|
|
151
|
-
initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
|
|
152
|
-
std::string bucket_name,
|
|
153
|
-
couchbase::create_primary_query_index_options::built options,
|
|
154
|
-
query_context query_ctx,
|
|
155
|
-
std::string collection_name,
|
|
156
|
-
create_primary_query_index_handler&& handler);
|
|
157
|
-
void
|
|
158
|
-
initiate_create_primary_query_index(std::shared_ptr<couchbase::core::cluster> core,
|
|
159
|
-
std::string bucket_name,
|
|
160
|
-
couchbase::create_primary_query_index_options::built options,
|
|
161
|
-
create_primary_query_index_handler&& handler);
|
|
162
|
-
|
|
163
|
-
#endif
|
|
164
|
-
} // namespace impl
|
|
165
|
-
} // namespace core
|
|
166
137
|
} // namespace couchbase
|