couchbase 4.2.11-rc.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +49 -2
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
- package/deps/couchbase-cxx-client/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +2 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +2 -2
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +51 -5
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +224 -209
- package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +2 -2
- package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +1 -0
- package/deps/couchbase-cxx-client/core/io/dns_client.cxx +4 -0
- package/deps/couchbase-cxx-client/core/io/dns_config.cxx +15 -4
- package/deps/couchbase-cxx-client/core/io/dns_config.hxx +1 -1
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +95 -53
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +1 -0
- package/deps/couchbase-cxx-client/core/mcbp/operation_queue.cxx +1 -0
- package/deps/couchbase-cxx-client/core/meta/features.hxx +5 -0
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +116 -105
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +116 -108
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +97 -81
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +5 -0
- package/deps/couchbase-cxx-client/core/range_scan_load_balancer.cxx +141 -0
- package/deps/couchbase-cxx-client/core/range_scan_load_balancer.hxx +64 -0
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +224 -336
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +5 -6
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +8 -5
- package/deps/couchbase-cxx-client/core/scan_result.hxx +1 -11
- package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +16 -7
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +578 -483
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_testing_hooks.cxx +51 -50
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_testing_hooks.hxx +4 -2
- package/deps/couchbase-cxx-client/core/transactions/cleanup_testing_hooks.cxx +6 -6
- package/deps/couchbase-cxx-client/core/transactions/cleanup_testing_hooks.hxx +3 -2
- package/deps/couchbase-cxx-client/core/transactions/internal/transactions_cleanup.hxx +2 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +5 -1
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +222 -179
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +23 -12
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +61 -24
- package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +36 -16
- package/deps/couchbase-cxx-client/core/transactions/utils.cxx +9 -0
- package/deps/couchbase-cxx-client/core/transactions.hxx +40 -7
- package/deps/couchbase-cxx-client/couchbase/bucket.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +20 -1
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/error_context.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/fork_event.hxx +39 -0
- package/deps/couchbase-cxx-client/couchbase/get_links_analytics_options.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/search_options.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/search_result.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase-sdk-cxx-black-duck-manifest.yaml +1 -0
- package/dist/binding.d.ts +8 -0
- package/dist/bindingutilities.d.ts +6 -1
- package/dist/bindingutilities.js +15 -1
- package/dist/bucketmanager.d.ts +0 -12
- package/dist/cluster.d.ts +0 -2
- package/dist/cluster.js +0 -2
- package/dist/collection.d.ts +3 -3
- package/dist/collection.js +3 -1
- package/dist/querytypes.d.ts +0 -2
- package/dist/rangeScan.d.ts +0 -8
- package/dist/rangeScan.js +0 -8
- package/dist/scope.d.ts +0 -5
- package/dist/scope.js +0 -5
- package/dist/scopesearchindexmanager.d.ts +0 -2
- package/dist/scopesearchindexmanager.js +0 -2
- package/dist/searchexecutor.js +3 -1
- package/dist/searchtypes.d.ts +16 -6
- package/dist/searchtypes.js +2 -6
- package/dist/transactions.d.ts +23 -0
- package/dist/transactions.js +16 -10
- package/dist/vectorsearch.d.ts +8 -8
- package/dist/vectorsearch.js +7 -7
- package/package.json +7 -7
- package/src/instance.cpp +11 -1
- package/src/instance.hpp +1 -0
- package/src/jstocbpp_autogen.hpp +8 -1
- package/src/jstocbpp_transactions.hpp +40 -3
- package/src/transactions.cpp +12 -1
- package/tools/gen-bindings-json.py +0 -1
- package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -44
@@ -26,6 +26,8 @@
|
|
26
26
|
#include "internal/transactions_cleanup.hxx"
|
27
27
|
#include "internal/utils.hxx"
|
28
28
|
|
29
|
+
#include <system_error>
|
30
|
+
|
29
31
|
namespace couchbase::core::transactions
|
30
32
|
{
|
31
33
|
transactions::transactions(core::cluster cluster, const couchbase::transactions::transactions_config& config)
|
@@ -38,35 +40,60 @@ transactions::transactions(core::cluster cluster, const couchbase::transactions:
|
|
38
40
|
, config_(config)
|
39
41
|
, cleanup_(new transactions_cleanup(cluster_, config_))
|
40
42
|
{
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
}
|
44
|
+
|
45
|
+
transactions::~transactions() = default;
|
46
|
+
|
47
|
+
void
|
48
|
+
transactions::create(core::cluster cluster,
|
49
|
+
const couchbase::transactions::transactions_config::built& config,
|
50
|
+
utils::movable_function<void(std::error_code, std::shared_ptr<transactions>)>&& cb)
|
51
|
+
{
|
52
|
+
if (config.metadata_collection) {
|
53
|
+
// if the config specifies custom metadata collection, lets be sure to open that bucket
|
54
|
+
// on the cluster before we start. NOTE: we actually do call get_and_open_buckets which opens all the buckets
|
55
|
+
// on the cluster (that we have permissions to open) in the cleanup. However, that is happening asynchronously
|
56
|
+
// so there's a chance we will fail to have opened the custom metadata collection bucket before trying to make a
|
57
|
+
// transaction. We have to open this one _now_.
|
58
|
+
|
59
|
+
auto bucket_name = config.metadata_collection->bucket;
|
60
|
+
return cluster.open_bucket(bucket_name, [cluster, config, bucket_name, cb = std::move(cb)](std::error_code ec) mutable {
|
61
|
+
if (ec) {
|
62
|
+
CB_TXN_LOG_ERROR("error opening metadata_collection bucket '{}' specified in the config!", bucket_name);
|
63
|
+
return cb(ec, {});
|
55
64
|
}
|
56
|
-
|
57
|
-
|
65
|
+
|
66
|
+
CB_TXN_LOG_DEBUG("couchbase transactions {} ({}) creating new transaction object",
|
67
|
+
couchbase::core::meta::sdk_id(),
|
68
|
+
couchbase::core::meta::os());
|
69
|
+
return cb({}, std::make_shared<transactions>(std::move(cluster), config));
|
58
70
|
});
|
59
|
-
auto err = f.get();
|
60
|
-
if (err) {
|
61
|
-
auto err_msg =
|
62
|
-
fmt::format("error opening metadata_collection bucket '{}' specified in the config!", config_.metadata_collection->bucket);
|
63
|
-
CB_TXN_LOG_DEBUG("{}", err_msg);
|
64
|
-
throw std::runtime_error(err_msg);
|
65
|
-
}
|
66
71
|
}
|
72
|
+
|
73
|
+
return cb({}, std::make_shared<transactions>(std::move(cluster), config));
|
67
74
|
}
|
68
75
|
|
69
|
-
|
76
|
+
void
|
77
|
+
transactions::create(core::cluster cluster,
|
78
|
+
const couchbase::transactions::transactions_config& config,
|
79
|
+
utils::movable_function<void(std::error_code, std::shared_ptr<transactions>)>&& cb)
|
80
|
+
{
|
81
|
+
return create(std::move(cluster), config.build(), std::move(cb));
|
82
|
+
}
|
83
|
+
|
84
|
+
std::future<std::pair<std::error_code, std::shared_ptr<transactions>>>
|
85
|
+
transactions::create(core::cluster cluster, const couchbase::transactions::transactions_config::built& config)
|
86
|
+
{
|
87
|
+
auto barrier = std::make_shared<std::promise<std::pair<std::error_code, std::shared_ptr<transactions>>>>();
|
88
|
+
create(std::move(cluster), config, [barrier](auto ec, auto txns) mutable { barrier->set_value({ ec, txns }); });
|
89
|
+
return barrier->get_future();
|
90
|
+
}
|
91
|
+
|
92
|
+
std::future<std::pair<std::error_code, std::shared_ptr<transactions>>>
|
93
|
+
transactions::create(core::cluster cluster, const couchbase::transactions::transactions_config& config)
|
94
|
+
{
|
95
|
+
return create(std::move(cluster), config.build());
|
96
|
+
}
|
70
97
|
|
71
98
|
template<typename Handler>
|
72
99
|
::couchbase::transactions::transaction_result
|
@@ -175,6 +202,16 @@ transactions::run(async_logic&& code, txn_complete_callback&& cb)
|
|
175
202
|
return run(config, std::move(code), std::move(cb));
|
176
203
|
}
|
177
204
|
|
205
|
+
void
|
206
|
+
transactions::notify_fork(fork_event event)
|
207
|
+
{
|
208
|
+
if (event == fork_event::prepare) {
|
209
|
+
cleanup_->stop();
|
210
|
+
} else {
|
211
|
+
cleanup_->start();
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
178
215
|
void
|
179
216
|
transactions::close()
|
180
217
|
{
|
@@ -45,18 +45,8 @@ transactions_cleanup::transactions_cleanup(core::cluster cluster, const couchbas
|
|
45
45
|
: cluster_(std::move(cluster))
|
46
46
|
, config_(config)
|
47
47
|
, client_uuid_(uid_generator::next())
|
48
|
-
, running_(config.cleanup_config.cleanup_client_attempts || config.cleanup_config.cleanup_lost_attempts)
|
49
48
|
{
|
50
|
-
|
51
|
-
cleanup_thr_ = std::thread(std::bind(&transactions_cleanup::attempts_loop, this));
|
52
|
-
}
|
53
|
-
if (config_.metadata_collection) {
|
54
|
-
add_collection(
|
55
|
-
{ config_.metadata_collection->bucket, config_.metadata_collection->scope, config_.metadata_collection->collection });
|
56
|
-
}
|
57
|
-
for (auto& k : config_.cleanup_config.collections) {
|
58
|
-
add_collection(k);
|
59
|
-
}
|
49
|
+
start();
|
60
50
|
}
|
61
51
|
|
62
52
|
static std::uint64_t
|
@@ -249,7 +239,9 @@ transactions_cleanup::create_client_record(const couchbase::transactions::transa
|
|
249
239
|
wrap_durable_request(req, config_);
|
250
240
|
auto barrier = std::make_shared<std::promise<result>>();
|
251
241
|
auto f = barrier->get_future();
|
252
|
-
auto ec =
|
242
|
+
auto ec = wait_for_hook([this, bucket = keyspace.bucket](auto handler) mutable {
|
243
|
+
return config_.cleanup_hooks->client_record_before_create(bucket, std::move(handler));
|
244
|
+
});
|
253
245
|
if (ec) {
|
254
246
|
throw client_error(*ec, "client_record_before_create hook raised error");
|
255
247
|
}
|
@@ -285,7 +277,9 @@ transactions_cleanup::get_active_clients(const couchbase::transactions::transact
|
|
285
277
|
.specs();
|
286
278
|
auto barrier = std::make_shared<std::promise<result>>();
|
287
279
|
auto f = barrier->get_future();
|
288
|
-
auto ec =
|
280
|
+
auto ec = wait_for_hook([this, bucket = keyspace.bucket](auto handler) mutable {
|
281
|
+
return config_.cleanup_hooks->client_record_before_get(bucket, std::move(handler));
|
282
|
+
});
|
289
283
|
if (ec) {
|
290
284
|
throw client_error(*ec, "client_record_before_get hook raised error");
|
291
285
|
}
|
@@ -363,7 +357,9 @@ transactions_cleanup::get_active_clients(const couchbase::transactions::transact
|
|
363
357
|
mut_specs.push_back(couchbase::mutate_in_specs::remove(FIELD_CLIENTS + "." + details.expired_client_ids[idx]).xattr());
|
364
358
|
}
|
365
359
|
mutate_req.specs = mut_specs.specs();
|
366
|
-
ec =
|
360
|
+
ec = wait_for_hook([this, bucket = keyspace.bucket](auto handler) mutable {
|
361
|
+
return config_.cleanup_hooks->client_record_before_update(bucket, std::move(handler));
|
362
|
+
});
|
367
363
|
if (ec) {
|
368
364
|
throw client_error(*ec, "client_record_before_update hook raised error");
|
369
365
|
}
|
@@ -401,7 +397,9 @@ transactions_cleanup::remove_client_record_from_all_buckets(const std::string& u
|
|
401
397
|
std::chrono::milliseconds(10), std::chrono::milliseconds(250), std::chrono::milliseconds(500), [this, keyspace, uuid]() {
|
402
398
|
try {
|
403
399
|
// proceed to remove the client uuid if it exists
|
404
|
-
auto ec =
|
400
|
+
auto ec = wait_for_hook([this, bucket = keyspace.bucket](auto handler) mutable {
|
401
|
+
return config_.cleanup_hooks->client_record_before_remove_client(bucket, std::move(handler));
|
402
|
+
});
|
405
403
|
if (ec) {
|
406
404
|
throw client_error(*ec, "client_record_before_remove_client hook raised error");
|
407
405
|
}
|
@@ -546,7 +544,23 @@ transactions_cleanup::add_collection(couchbase::transactions::transaction_keyspa
|
|
546
544
|
}
|
547
545
|
|
548
546
|
void
|
549
|
-
transactions_cleanup::
|
547
|
+
transactions_cleanup::start()
|
548
|
+
{
|
549
|
+
running_ = config_.cleanup_config.cleanup_client_attempts || config_.cleanup_config.cleanup_lost_attempts;
|
550
|
+
if (config_.cleanup_config.cleanup_client_attempts) {
|
551
|
+
cleanup_thr_ = std::thread(std::bind(&transactions_cleanup::attempts_loop, this));
|
552
|
+
}
|
553
|
+
if (config_.metadata_collection) {
|
554
|
+
add_collection(
|
555
|
+
{ config_.metadata_collection->bucket, config_.metadata_collection->scope, config_.metadata_collection->collection });
|
556
|
+
}
|
557
|
+
for (const auto& k : config_.cleanup_config.collections) {
|
558
|
+
add_collection(k);
|
559
|
+
}
|
560
|
+
}
|
561
|
+
|
562
|
+
void
|
563
|
+
transactions_cleanup::stop()
|
550
564
|
{
|
551
565
|
{
|
552
566
|
std::unique_lock<std::mutex> lock(mutex_);
|
@@ -563,6 +577,12 @@ transactions_cleanup::close()
|
|
563
577
|
t.join();
|
564
578
|
}
|
565
579
|
}
|
580
|
+
}
|
581
|
+
|
582
|
+
void
|
583
|
+
transactions_cleanup::close()
|
584
|
+
{
|
585
|
+
stop();
|
566
586
|
CB_LOST_ATTEMPT_CLEANUP_LOG_DEBUG("all lost attempt cleanup threads closed");
|
567
587
|
remove_client_record_from_all_buckets(client_uuid_);
|
568
588
|
}
|
@@ -92,6 +92,15 @@ wrap_operation_future(std::future<result>& fut, bool ignore_subdoc_errors)
|
|
92
92
|
return res;
|
93
93
|
}
|
94
94
|
|
95
|
+
std::optional<error_class>
|
96
|
+
wait_for_hook(std::function<void(utils::movable_function<void(std::optional<error_class>)>)> hook)
|
97
|
+
{
|
98
|
+
auto hook_barrier = std::make_shared<std::promise<std::optional<error_class>>>();
|
99
|
+
auto hook_future = hook_barrier->get_future();
|
100
|
+
hook([hook_barrier](std::optional<error_class> ec) mutable { return hook_barrier->set_value(ec); });
|
101
|
+
return hook_future.get();
|
102
|
+
}
|
103
|
+
|
95
104
|
template<>
|
96
105
|
bool
|
97
106
|
is_error(const core::operations::mutate_in_response& resp)
|
@@ -18,20 +18,24 @@
|
|
18
18
|
|
19
19
|
#include <couchbase/transactions.hxx>
|
20
20
|
|
21
|
-
#include
|
22
|
-
#include
|
23
|
-
#include
|
21
|
+
#include <couchbase/fork_event.hxx>
|
22
|
+
#include <couchbase/transactions/transaction_options.hxx>
|
23
|
+
#include <couchbase/transactions/transaction_result.hxx>
|
24
|
+
#include <couchbase/transactions/transactions_config.hxx>
|
25
|
+
|
24
26
|
#include "transactions/async_attempt_context.hxx"
|
25
27
|
#include "transactions/attempt_context.hxx"
|
26
28
|
#include "transactions/exceptions.hxx"
|
27
29
|
|
28
30
|
#include "core/cluster.hxx"
|
29
31
|
#include "core/logger/logger.hxx"
|
32
|
+
#include "core/utils/movable_function.hxx"
|
30
33
|
|
31
34
|
#include <spdlog/common.h>
|
32
35
|
|
33
36
|
#include <cmath>
|
34
37
|
#include <functional>
|
38
|
+
#include <system_error>
|
35
39
|
#include <thread>
|
36
40
|
|
37
41
|
// workaround for MSVC define overlap with log levels
|
@@ -127,6 +131,11 @@ using txn_complete_callback =
|
|
127
131
|
class transactions : public couchbase::transactions::transactions
|
128
132
|
{
|
129
133
|
public:
|
134
|
+
/**
|
135
|
+
* @brief Destructor
|
136
|
+
*/
|
137
|
+
~transactions();
|
138
|
+
|
130
139
|
/**
|
131
140
|
* @brief Create a transactions object.
|
132
141
|
*
|
@@ -134,14 +143,30 @@ class transactions : public couchbase::transactions::transactions
|
|
134
143
|
*
|
135
144
|
* @param cluster The cluster to use for the transactions.
|
136
145
|
* @param config The configuration parameters to use for the transactions.
|
146
|
+
* @param cb Called when the transactions object has been created or an error has occurred during the creation.
|
137
147
|
*/
|
138
|
-
|
139
|
-
|
148
|
+
static void create(core::cluster cluster,
|
149
|
+
const couchbase::transactions::transactions_config::built&,
|
150
|
+
utils::movable_function<void(std::error_code, std::shared_ptr<transactions>)>&& cb);
|
151
|
+
static void create(core::cluster cluster,
|
152
|
+
const couchbase::transactions::transactions_config&,
|
153
|
+
utils::movable_function<void(std::error_code, std::shared_ptr<transactions>)>&& cb);
|
140
154
|
|
141
155
|
/**
|
142
|
-
* @brief
|
156
|
+
* @brief Create a transactions object.
|
157
|
+
*
|
158
|
+
* Creates a transactions object, which can be used to run transactions within the current thread.
|
159
|
+
*
|
160
|
+
* @param cluster The cluster to use for the transactions.
|
161
|
+
* @param config The configuration parameters to use for the transactions.
|
162
|
+
* @return a future containing the error that occurred or the transactions object.
|
143
163
|
*/
|
144
|
-
|
164
|
+
static std::future<std::pair<std::error_code, std::shared_ptr<transactions>>> create(
|
165
|
+
core::cluster cluster,
|
166
|
+
const couchbase::transactions::transactions_config::built& config);
|
167
|
+
static std::future<std::pair<std::error_code, std::shared_ptr<transactions>>> create(
|
168
|
+
core::cluster cluster,
|
169
|
+
const couchbase::transactions::transactions_config& config);
|
145
170
|
|
146
171
|
/**
|
147
172
|
* @brief Run a transaction
|
@@ -199,6 +224,8 @@ class transactions : public couchbase::transactions::transactions
|
|
199
224
|
ctx.rollback();
|
200
225
|
}
|
201
226
|
|
227
|
+
void notify_fork(fork_event event);
|
228
|
+
|
202
229
|
/**
|
203
230
|
* @brief Shut down the transactions object
|
204
231
|
*
|
@@ -245,6 +272,12 @@ class transactions : public couchbase::transactions::transactions
|
|
245
272
|
return cluster_;
|
246
273
|
}
|
247
274
|
|
275
|
+
/**
|
276
|
+
* @internal
|
277
|
+
*/
|
278
|
+
transactions(core::cluster cluster, const couchbase::transactions::transactions_config::built& config);
|
279
|
+
transactions(core::cluster cluster, const couchbase::transactions::transactions_config& config);
|
280
|
+
|
248
281
|
private:
|
249
282
|
core::cluster cluster_;
|
250
283
|
couchbase::transactions::transactions_config::built config_;
|
@@ -79,7 +79,7 @@ class bucket
|
|
79
79
|
* Performs application-level ping requests against services in the Couchbase cluster.
|
80
80
|
*
|
81
81
|
* @note This operation performs active I/O against services and endpoints to assess their health. If you do not
|
82
|
-
* wish to performs I/O, consider using @ref diagnostics() instead.
|
82
|
+
* wish to performs I/O, consider using @ref cluster::diagnostics() instead.
|
83
83
|
*
|
84
84
|
* @param options custom options to change the default behavior.
|
85
85
|
* @param handler the handler that implements @ref ping_handler.
|
@@ -93,7 +93,7 @@ class bucket
|
|
93
93
|
* Performs application-level ping requests against services in the Couchbase cluster.
|
94
94
|
*
|
95
95
|
* @note This operation performs active I/O against services and endpoints to assess their health. If you do not
|
96
|
-
* wish to performs I/O, consider using @ref diagnostics() instead.
|
96
|
+
* wish to performs I/O, consider using @ref cluster::diagnostics() instead.
|
97
97
|
*
|
98
98
|
* @param options custom options to change the default behavior.
|
99
99
|
* @return future object that carries result of the operation.
|
@@ -23,6 +23,7 @@
|
|
23
23
|
#include <couchbase/bucket_manager.hxx>
|
24
24
|
#include <couchbase/cluster_options.hxx>
|
25
25
|
#include <couchbase/diagnostics_options.hxx>
|
26
|
+
#include <couchbase/fork_event.hxx>
|
26
27
|
#include <couchbase/ping_options.hxx>
|
27
28
|
#include <couchbase/query_index_manager.hxx>
|
28
29
|
#include <couchbase/query_options.hxx>
|
@@ -40,6 +41,11 @@ namespace couchbase
|
|
40
41
|
namespace core
|
41
42
|
{
|
42
43
|
class cluster;
|
44
|
+
|
45
|
+
namespace transactions
|
46
|
+
{
|
47
|
+
class transactions;
|
48
|
+
}
|
43
49
|
} // namespace core
|
44
50
|
class cluster_impl;
|
45
51
|
#endif
|
@@ -90,6 +96,8 @@ class cluster
|
|
90
96
|
auto operator=(const cluster& other) -> cluster& = default;
|
91
97
|
auto operator=(cluster&& other) -> cluster& = default;
|
92
98
|
|
99
|
+
void notify_fork(fork_event event);
|
100
|
+
|
93
101
|
void close() const;
|
94
102
|
|
95
103
|
/**
|
@@ -102,6 +110,17 @@ class cluster
|
|
102
110
|
*/
|
103
111
|
explicit cluster(core::cluster core);
|
104
112
|
|
113
|
+
/**
|
114
|
+
* Wraps low-level implementation of the SDK & transactions
|
115
|
+
*
|
116
|
+
* @param core pointer to the low-level SDK handle
|
117
|
+
* @param transactions pointer to the lowe-level transactions handle
|
118
|
+
*
|
119
|
+
* @since 1.0.0
|
120
|
+
* @volatile
|
121
|
+
*/
|
122
|
+
explicit cluster(core::cluster core, std::shared_ptr<core::transactions::transactions> transactions);
|
123
|
+
|
105
124
|
/**
|
106
125
|
* Opens a {@link bucket} with the given name.
|
107
126
|
*
|
@@ -222,7 +241,7 @@ class cluster
|
|
222
241
|
* @since 1.0.0
|
223
242
|
* @volatile
|
224
243
|
*/
|
225
|
-
[[nodiscard]] auto search(std::string index_name, search_request request, const search_options& = {}) const
|
244
|
+
[[nodiscard]] auto search(std::string index_name, search_request request, const search_options& options = {}) const
|
226
245
|
-> std::future<std::pair<search_error_context, search_result>>;
|
227
246
|
|
228
247
|
/**
|
@@ -791,6 +791,7 @@ class collection
|
|
791
791
|
* @param document_id the outer document ID
|
792
792
|
* @param specs an object that specifies the types of lookups to perform
|
793
793
|
* @param options custom options to modify the lookup options
|
794
|
+
* @param handler callable that implements @ref lookup_in_any_replica_handler
|
794
795
|
*
|
795
796
|
* @exception errc::key_value::document_not_found the given document id is not found in the collection.
|
796
797
|
* @exception errc::common::ambiguous_timeout
|
@@ -64,7 +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
|
/**
|
67
|
-
* Get all indexes within the collection
|
67
|
+
* Get all indexes within the collection.
|
68
68
|
*
|
69
69
|
* @param options optional parameters
|
70
70
|
* @return future object that carries result of the operation
|
@@ -0,0 +1,39 @@
|
|
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
|
+
namespace couchbase
|
21
|
+
{
|
22
|
+
enum class fork_event {
|
23
|
+
/**
|
24
|
+
* Notify the cluster that the process is about to fork.
|
25
|
+
*/
|
26
|
+
prepare,
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Notify the context that the process has forked and is the parent.
|
30
|
+
*/
|
31
|
+
parent,
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Notify the context that the process has forked and is the child.
|
35
|
+
*/
|
36
|
+
child,
|
37
|
+
};
|
38
|
+
|
39
|
+
} // namespace couchbase
|
@@ -50,7 +50,7 @@ class get_links_analytics_options : public common_options<get_links_analytics_op
|
|
50
50
|
/**
|
51
51
|
* The name of the link to fetch.
|
52
52
|
*
|
53
|
-
* @param
|
53
|
+
* @param name link name
|
54
54
|
* @return reference to this object, for use in chaining
|
55
55
|
*
|
56
56
|
* @since 1.0.0
|
@@ -65,7 +65,7 @@ class get_links_analytics_options : public common_options<get_links_analytics_op
|
|
65
65
|
/**
|
66
66
|
* The type of links to restrict returned links to.
|
67
67
|
*
|
68
|
-
* @param link_type
|
68
|
+
* @param link_type link type
|
69
69
|
* @return reference to this object, for use in chaining
|
70
70
|
*
|
71
71
|
* @since 1.0.0
|
@@ -151,7 +151,7 @@ class scope
|
|
151
151
|
* @since 1.0.0
|
152
152
|
* @volatile
|
153
153
|
*/
|
154
|
-
[[nodiscard]] auto search(std::string index_name, search_request request, const search_options& = {}) const
|
154
|
+
[[nodiscard]] auto search(std::string index_name, search_request request, const search_options& options = {}) const
|
155
155
|
-> std::future<std::pair<search_error_context, search_result>>;
|
156
156
|
|
157
157
|
/**
|
@@ -35,7 +35,7 @@
|
|
35
35
|
namespace couchbase
|
36
36
|
{
|
37
37
|
/**
|
38
|
-
* Options for cluster#search_query() and scope#
|
38
|
+
* Options for @ref cluster#search_query(), @ref cluster#search() and @ref scope#search().
|
39
39
|
*
|
40
40
|
* @since 1.0.0
|
41
41
|
* @committed
|
@@ -500,7 +500,7 @@ struct search_options : public common_options<search_options> {
|
|
500
500
|
};
|
501
501
|
|
502
502
|
/**
|
503
|
-
* The signature for the handler of the @ref cluster#search_query() and @ref scope#
|
503
|
+
* The signature for the handler of the @ref cluster#search_query(), @ref cluster#search() and @ref scope#search() operations
|
504
504
|
*
|
505
505
|
* @since 1.0.0
|
506
506
|
* @uncommitted
|
@@ -35,7 +35,7 @@ class internal_search_result;
|
|
35
35
|
#endif
|
36
36
|
|
37
37
|
/**
|
38
|
-
* Represents result of @ref cluster#search_query() and @ref scope#
|
38
|
+
* Represents result of @ref cluster#search_query(), @ref cluster#search() and @ref scope#search() calls.
|
39
39
|
*
|
40
40
|
* @since 1.0.0
|
41
41
|
* @committed
|
@@ -78,7 +78,7 @@ class transaction_options
|
|
78
78
|
/**
|
79
79
|
* Set the timeout for this transaction.
|
80
80
|
*
|
81
|
-
* @tparam T timeout type, e.g.
|
81
|
+
* @tparam T timeout type, e.g. std::chrono::milliseconds, or similar
|
82
82
|
* @param timeout Desired timeout
|
83
83
|
* @return reference to this object, convenient for chaining operations.
|
84
84
|
*/
|
package/dist/binding.d.ts
CHANGED
@@ -885,6 +885,8 @@ export interface CppSearchRequest {
|
|
885
885
|
};
|
886
886
|
client_context_id?: string;
|
887
887
|
timeout?: CppMilliseconds;
|
888
|
+
log_request?: boolean;
|
889
|
+
log_response?: boolean;
|
888
890
|
body_str: string;
|
889
891
|
}
|
890
892
|
export interface CppTouchResponse {
|
@@ -2670,6 +2672,11 @@ export interface CppConnection extends CppConnectionAutogen {
|
|
2670
2672
|
result: CppScanIterator;
|
2671
2673
|
};
|
2672
2674
|
}
|
2675
|
+
export interface CppTransactionKeyspace {
|
2676
|
+
bucket_name: string;
|
2677
|
+
scope_name?: string;
|
2678
|
+
collection_name?: string;
|
2679
|
+
}
|
2673
2680
|
export interface CppTransactionsConfig {
|
2674
2681
|
durability_level?: CppDurabilityLevel;
|
2675
2682
|
timeout?: CppMilliseconds;
|
@@ -2677,6 +2684,7 @@ export interface CppTransactionsConfig {
|
|
2677
2684
|
cleanup_window?: CppMilliseconds;
|
2678
2685
|
cleanup_lost_attempts?: boolean;
|
2679
2686
|
cleanup_client_attempts?: boolean;
|
2687
|
+
metadata_collection?: CppTransactionKeyspace;
|
2680
2688
|
}
|
2681
2689
|
export interface CppTransactionOptions {
|
2682
2690
|
durability_level?: CppDurabilityLevel;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AnalyticsScanConsistency, AnalyticsStatus } from './analyticstypes';
|
2
|
-
import { CppAnalyticsResponseAnalyticsStatus, CppAnalyticsScanConsistency, CppDesignDocumentNamespace, CppDiagEndpointState, CppDiagPingState, CppDurabilityLevel, CppError, CppManagementClusterBucketCompression, CppManagementClusterBucketConflictResolution, CppManagementClusterBucketEvictionPolicy, CppManagementClusterBucketStorageBackend, CppManagementClusterBucketType, CppMutationState, CppPersistTo, CppPrefixScan, CppQueryProfile, CppQueryScanConsistency, CppRangeScan, CppReplicateTo, CppSamplingScan, CppSearchHighlightStyle, CppSearchScanConsistency, CppServiceType, CppStoreSemantics, CppTxnExternalException, CppTxnOpException, CppVectorQueryCombination, CppViewScanConsistency, CppViewSortOrder } from './binding';
|
2
|
+
import { CppAnalyticsResponseAnalyticsStatus, CppAnalyticsScanConsistency, CppDesignDocumentNamespace, CppDiagEndpointState, CppDiagPingState, CppDurabilityLevel, CppError, CppManagementClusterBucketCompression, CppManagementClusterBucketConflictResolution, CppManagementClusterBucketEvictionPolicy, CppManagementClusterBucketStorageBackend, CppManagementClusterBucketType, CppMutationState, CppPersistTo, CppPrefixScan, CppQueryProfile, CppQueryScanConsistency, CppRangeScan, CppReplicateTo, CppSamplingScan, CppSearchHighlightStyle, CppSearchScanConsistency, CppServiceType, CppStoreSemantics, CppTransactionKeyspace, CppTxnExternalException, CppTxnOpException, CppVectorQueryCombination, CppViewScanConsistency, CppViewSortOrder } from './binding';
|
3
3
|
import { BucketType, CompressionMode, ConflictResolutionType, EvictionPolicy, StorageBackend } from './bucketmanager';
|
4
4
|
import { EndpointState, PingState } from './diagnosticstypes';
|
5
5
|
import { ErrorContext } from './errorcontexts';
|
@@ -8,6 +8,7 @@ import { MutationState } from './mutationstate';
|
|
8
8
|
import { QueryProfileMode, QueryScanConsistency } from './querytypes';
|
9
9
|
import { PrefixScan, RangeScan, SamplingScan } from './rangeScan';
|
10
10
|
import { HighlightStyle, SearchScanConsistency } from './searchtypes';
|
11
|
+
import { TransactionKeyspace } from './transactions';
|
11
12
|
import { VectorQueryCombination } from './vectorsearch';
|
12
13
|
import { DesignDocumentNamespace, ViewOrdering, ViewScanConsistency } from './viewtypes';
|
13
14
|
/**
|
@@ -154,3 +155,7 @@ export declare function designDocumentNamespaceFromCpp(namespace: CppDesignDocum
|
|
154
155
|
* @internal
|
155
156
|
*/
|
156
157
|
export declare function designDocumentNamespaceToCpp(namespace: DesignDocumentNamespace): CppDesignDocumentNamespace;
|
158
|
+
/**
|
159
|
+
* @internal
|
160
|
+
*/
|
161
|
+
export declare function transactionKeyspaceToCpp(keyspace?: TransactionKeyspace): CppTransactionKeyspace | undefined;
|
package/dist/bindingutilities.js
CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.designDocumentNamespaceToCpp = exports.designDocumentNamespaceFromCpp = exports.vectorQueryCombinationToCpp = exports.bucketConflictResolutionTypeFromCpp = exports.bucketConflictResolutionTypeToCpp = exports.bucketStorageBackendFromCpp = exports.bucketStorageBackendToCpp = exports.bucketEvictionPolicyFromCpp = exports.bucketEvictionPolicyToCpp = exports.bucketCompressionModeFromCpp = exports.bucketCompressionModeToCpp = exports.bucketTypeFromCpp = exports.bucketTypeToCpp = exports.scanTypeToCpp = exports.errorFromCpp = exports.contextFromCpp = exports.pingStateFromCpp = exports.txnOpExeptionFromCpp = exports.txnExternalExceptionStringFromCpp = exports.endpointStateFromCpp = exports.serviceTypeFromCpp = exports.serviceTypeToCpp = exports.mutationStateToCpp = exports.searchHighlightStyleToCpp = exports.searchScanConsistencyToCpp = exports.analyticsStatusFromCpp = exports.analyticsScanConsistencyToCpp = exports.queryProfileToCpp = exports.queryScanConsistencyToCpp = exports.viewOrderingToCpp = exports.viewScanConsistencyToCpp = exports.storeSemanticToCpp = exports.replicateToToCpp = exports.persistToToCpp = exports.durabilityFromCpp = exports.durabilityToCpp = void 0;
|
29
|
+
exports.transactionKeyspaceToCpp = exports.designDocumentNamespaceToCpp = exports.designDocumentNamespaceFromCpp = exports.vectorQueryCombinationToCpp = exports.bucketConflictResolutionTypeFromCpp = exports.bucketConflictResolutionTypeToCpp = exports.bucketStorageBackendFromCpp = exports.bucketStorageBackendToCpp = exports.bucketEvictionPolicyFromCpp = exports.bucketEvictionPolicyToCpp = exports.bucketCompressionModeFromCpp = exports.bucketCompressionModeToCpp = exports.bucketTypeFromCpp = exports.bucketTypeToCpp = exports.scanTypeToCpp = exports.errorFromCpp = exports.contextFromCpp = exports.pingStateFromCpp = exports.txnOpExeptionFromCpp = exports.txnExternalExceptionStringFromCpp = exports.endpointStateFromCpp = exports.serviceTypeFromCpp = exports.serviceTypeToCpp = exports.mutationStateToCpp = exports.searchHighlightStyleToCpp = exports.searchScanConsistencyToCpp = exports.analyticsStatusFromCpp = exports.analyticsScanConsistencyToCpp = exports.queryProfileToCpp = exports.queryScanConsistencyToCpp = exports.viewOrderingToCpp = exports.viewScanConsistencyToCpp = exports.storeSemanticToCpp = exports.replicateToToCpp = exports.persistToToCpp = exports.durabilityFromCpp = exports.durabilityToCpp = void 0;
|
30
30
|
const analyticstypes_1 = require("./analyticstypes");
|
31
31
|
const binding_1 = __importDefault(require("./binding"));
|
32
32
|
const bucketmanager_1 = require("./bucketmanager");
|
@@ -1051,3 +1051,17 @@ function designDocumentNamespaceToCpp(namespace) {
|
|
1051
1051
|
throw new errs.InvalidArgumentError(new Error('Unrecognized DesignDocumentNamespace.'));
|
1052
1052
|
}
|
1053
1053
|
exports.designDocumentNamespaceToCpp = designDocumentNamespaceToCpp;
|
1054
|
+
/**
|
1055
|
+
* @internal
|
1056
|
+
*/
|
1057
|
+
function transactionKeyspaceToCpp(keyspace) {
|
1058
|
+
var _a, _b;
|
1059
|
+
if (!keyspace)
|
1060
|
+
return undefined;
|
1061
|
+
return {
|
1062
|
+
bucket_name: keyspace.bucket,
|
1063
|
+
scope_name: (_a = keyspace.scope) !== null && _a !== void 0 ? _a : '_default',
|
1064
|
+
collection_name: (_b = keyspace.collection) !== null && _b !== void 0 ? _b : '_default',
|
1065
|
+
};
|
1066
|
+
}
|
1067
|
+
exports.transactionKeyspaceToCpp = transactionKeyspaceToCpp;
|