couchbase 3.4.3 → 3.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/couchbase/CMakeLists.txt +22 -1
- data/ext/couchbase/core/bucket.cxx +183 -152
- data/ext/couchbase/core/bucket.hxx +17 -4
- data/ext/couchbase/core/cluster.hxx +41 -13
- data/ext/couchbase/core/cluster_options.hxx +3 -0
- data/ext/couchbase/core/crud_component.cxx +51 -22
- data/ext/couchbase/core/error_context/key_value.cxx +2 -1
- data/ext/couchbase/core/error_context/key_value.hxx +10 -12
- data/ext/couchbase/core/impl/build_deferred_query_indexes.cxx +115 -50
- data/ext/couchbase/core/impl/cluster.cxx +6 -0
- data/ext/couchbase/core/impl/create_bucket.cxx +158 -0
- data/ext/couchbase/core/impl/create_collection.cxx +83 -0
- data/ext/couchbase/core/impl/create_query_index.cxx +172 -59
- data/ext/couchbase/core/impl/create_scope.cxx +69 -0
- data/ext/couchbase/core/impl/dns_srv_tracker.cxx +2 -1
- data/ext/couchbase/core/impl/drop_bucket.cxx +66 -0
- data/ext/couchbase/core/impl/drop_collection.cxx +76 -0
- data/ext/couchbase/core/impl/drop_query_index.cxx +138 -59
- data/ext/couchbase/core/impl/drop_scope.cxx +68 -0
- data/ext/couchbase/core/impl/flush_bucket.cxx +66 -0
- data/ext/couchbase/core/impl/get_all_buckets.cxx +178 -0
- data/ext/couchbase/core/impl/get_all_query_indexes.cxx +67 -37
- data/ext/couchbase/core/impl/get_all_scopes.cxx +94 -0
- data/ext/couchbase/core/impl/get_bucket.cxx +168 -0
- data/ext/couchbase/core/impl/internal_manager_error_context.cxx +113 -0
- data/ext/couchbase/core/impl/internal_manager_error_context.hxx +60 -0
- data/ext/couchbase/core/impl/key_value_error_category.cxx +2 -4
- data/ext/couchbase/core/impl/key_value_error_context.cxx +98 -0
- data/ext/couchbase/core/impl/lookup_in.cxx +1 -0
- data/ext/couchbase/core/impl/lookup_in_all_replicas.cxx +178 -0
- data/ext/couchbase/core/impl/lookup_in_all_replicas.hxx +80 -0
- data/ext/couchbase/core/impl/lookup_in_any_replica.cxx +169 -0
- data/ext/couchbase/core/impl/lookup_in_any_replica.hxx +75 -0
- data/ext/couchbase/core/impl/lookup_in_replica.cxx +104 -0
- data/ext/couchbase/core/impl/lookup_in_replica.hxx +67 -0
- data/ext/couchbase/core/impl/manager_error_context.cxx +100 -0
- data/ext/couchbase/core/impl/query.cxx +1 -0
- data/ext/couchbase/core/impl/query_error_context.cxx +75 -0
- data/ext/couchbase/core/impl/update_bucket.cxx +133 -0
- data/ext/couchbase/core/impl/update_collection.cxx +83 -0
- data/ext/couchbase/core/impl/watch_query_indexes.cxx +53 -29
- data/ext/couchbase/core/io/dns_client.cxx +111 -40
- data/ext/couchbase/core/io/dns_config.cxx +5 -4
- data/ext/couchbase/core/io/http_session.hxx +24 -1
- data/ext/couchbase/core/io/mcbp_command.hxx +9 -2
- data/ext/couchbase/core/io/mcbp_session.cxx +80 -43
- data/ext/couchbase/core/io/mcbp_session.hxx +4 -3
- data/ext/couchbase/core/logger/custom_rotating_file_sink.cxx +1 -1
- data/ext/couchbase/core/logger/logger.cxx +80 -20
- data/ext/couchbase/core/logger/logger.hxx +31 -0
- data/ext/couchbase/core/management/bucket_settings.hxx +8 -5
- data/ext/couchbase/core/management/bucket_settings_json.hxx +12 -2
- data/ext/couchbase/core/meta/features.hxx +42 -0
- data/ext/couchbase/core/operations/document_lookup_in.cxx +8 -1
- data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +192 -0
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +188 -0
- data/ext/couchbase/core/operations/document_query.cxx +11 -0
- data/ext/couchbase/core/operations/document_query.hxx +1 -0
- data/ext/couchbase/core/operations/management/CMakeLists.txt +1 -0
- data/ext/couchbase/core/operations/management/bucket_create.cxx +30 -9
- data/ext/couchbase/core/operations/management/bucket_update.cxx +27 -6
- data/ext/couchbase/core/operations/management/collection_create.cxx +5 -1
- data/ext/couchbase/core/operations/management/collection_create.hxx +1 -0
- data/ext/couchbase/core/operations/management/collection_update.cxx +87 -0
- data/ext/couchbase/core/operations/management/collection_update.hxx +54 -0
- data/ext/couchbase/core/operations/management/collections.hxx +1 -0
- data/ext/couchbase/core/operations.hxx +2 -0
- data/ext/couchbase/core/origin.cxx +270 -0
- data/ext/couchbase/core/origin.hxx +2 -0
- data/ext/couchbase/core/protocol/client_response.hxx +1 -0
- data/ext/couchbase/core/protocol/cmd_hello.hxx +1 -0
- data/ext/couchbase/core/protocol/cmd_lookup_in_replica.cxx +107 -0
- data/ext/couchbase/core/protocol/cmd_lookup_in_replica.hxx +137 -0
- data/ext/couchbase/core/protocol/hello_feature.hxx +6 -0
- data/ext/couchbase/core/protocol/hello_feature_fmt.hxx +3 -0
- data/ext/couchbase/core/protocol/status.cxx +2 -2
- data/ext/couchbase/core/range_scan_options.cxx +3 -27
- data/ext/couchbase/core/range_scan_options.hxx +13 -17
- data/ext/couchbase/core/range_scan_orchestrator.cxx +388 -170
- data/ext/couchbase/core/range_scan_orchestrator.hxx +13 -2
- data/ext/couchbase/core/range_scan_orchestrator_options.hxx +5 -3
- data/ext/couchbase/core/scan_options.hxx +0 -19
- data/ext/couchbase/core/scan_result.cxx +19 -5
- data/ext/couchbase/core/scan_result.hxx +5 -2
- data/ext/couchbase/core/timeout_defaults.hxx +3 -4
- data/ext/couchbase/core/topology/capabilities.hxx +4 -0
- data/ext/couchbase/core/topology/capabilities_fmt.hxx +11 -0
- data/ext/couchbase/core/topology/collections_manifest.hxx +2 -0
- data/ext/couchbase/core/topology/collections_manifest_fmt.hxx +1 -1
- data/ext/couchbase/core/topology/collections_manifest_json.hxx +3 -0
- data/ext/couchbase/core/topology/configuration.hxx +20 -0
- data/ext/couchbase/core/topology/configuration_json.hxx +8 -1
- data/ext/couchbase/core/utils/connection_string.cxx +62 -47
- data/ext/couchbase/core/utils/connection_string.hxx +1 -0
- data/ext/couchbase/couchbase/analytics_error_context.hxx +1 -1
- data/ext/couchbase/couchbase/behavior_options.hxx +19 -2
- data/ext/couchbase/couchbase/bucket.hxx +14 -0
- data/ext/couchbase/couchbase/bucket_manager.hxx +135 -0
- data/ext/couchbase/couchbase/build_query_index_options.hxx +0 -30
- data/ext/couchbase/couchbase/cluster.hxx +14 -0
- data/ext/couchbase/couchbase/collection.hxx +111 -0
- data/ext/couchbase/couchbase/collection_manager.hxx +160 -0
- data/ext/couchbase/couchbase/collection_query_index_manager.hxx +7 -48
- data/ext/couchbase/couchbase/create_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/create_collection_options.hxx +44 -0
- data/ext/couchbase/couchbase/create_primary_query_index_options.hxx +0 -29
- data/ext/couchbase/couchbase/create_query_index_options.hxx +0 -33
- data/ext/couchbase/couchbase/create_scope_options.hxx +41 -0
- data/ext/couchbase/couchbase/drop_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/drop_collection_options.hxx +41 -0
- data/ext/couchbase/couchbase/drop_primary_query_index_options.hxx +0 -30
- data/ext/couchbase/couchbase/drop_query_index_options.hxx +0 -31
- data/ext/couchbase/couchbase/drop_scope_options.hxx +41 -0
- data/ext/couchbase/couchbase/error_codes.hxx +1 -2
- data/ext/couchbase/couchbase/error_context.hxx +10 -2
- data/ext/couchbase/couchbase/flush_bucket_options.hxx +41 -0
- data/ext/couchbase/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
- data/ext/couchbase/couchbase/get_all_buckets_options.hxx +44 -0
- data/ext/couchbase/couchbase/get_all_query_indexes_options.hxx +0 -30
- data/ext/couchbase/couchbase/get_all_scopes_options.hxx +44 -0
- data/ext/couchbase/couchbase/get_and_lock_options.hxx +2 -2
- data/ext/couchbase/couchbase/get_and_touch_options.hxx +2 -2
- data/ext/couchbase/couchbase/get_bucket_options.hxx +43 -0
- data/ext/couchbase/couchbase/get_options.hxx +2 -2
- data/ext/couchbase/couchbase/insert_options.hxx +3 -3
- data/ext/couchbase/couchbase/key_value_error_context.hxx +7 -2
- data/ext/couchbase/couchbase/lookup_in_all_replicas_options.hxx +109 -0
- data/ext/couchbase/couchbase/lookup_in_any_replica_options.hxx +101 -0
- data/ext/couchbase/couchbase/lookup_in_options.hxx +2 -2
- data/ext/couchbase/couchbase/lookup_in_replica_result.hxx +74 -0
- data/ext/couchbase/couchbase/lookup_in_result.hxx +26 -0
- data/ext/couchbase/couchbase/management/bucket_settings.hxx +119 -0
- data/ext/couchbase/couchbase/management/collection_spec.hxx +29 -0
- data/ext/couchbase/couchbase/management/scope_spec.hxx +29 -0
- data/ext/couchbase/couchbase/manager_error_context.hxx +29 -53
- data/ext/couchbase/couchbase/mutate_in_options.hxx +2 -2
- data/ext/couchbase/couchbase/query_error_context.hxx +3 -1
- data/ext/couchbase/couchbase/query_index_manager.hxx +16 -83
- data/ext/couchbase/couchbase/query_options.hxx +18 -0
- data/ext/couchbase/couchbase/remove_options.hxx +2 -2
- data/ext/couchbase/couchbase/replace_options.hxx +3 -3
- data/ext/couchbase/couchbase/security_options.hxx +15 -0
- data/ext/couchbase/couchbase/subdocument_error_context.hxx +4 -2
- data/ext/couchbase/couchbase/touch_options.hxx +2 -2
- data/ext/couchbase/couchbase/unlock_options.hxx +2 -2
- data/ext/couchbase/couchbase/update_bucket_options.hxx +41 -0
- data/ext/couchbase/couchbase/update_collection_options.hxx +44 -0
- data/ext/couchbase/couchbase/upsert_options.hxx +3 -3
- data/ext/couchbase/couchbase/watch_query_indexes_options.hxx +0 -31
- data/ext/couchbase/test/CMakeLists.txt +1 -0
- data/ext/couchbase/test/test_integration_collections.cxx +6 -0
- data/ext/couchbase/test/test_integration_crud.cxx +5 -0
- data/ext/couchbase/test/test_integration_examples.cxx +137 -1
- data/ext/couchbase/test/test_integration_management.cxx +1009 -309
- data/ext/couchbase/test/test_integration_query.cxx +19 -7
- data/ext/couchbase/test/test_integration_range_scan.cxx +351 -112
- data/ext/couchbase/test/test_integration_search.cxx +10 -1
- data/ext/couchbase/test/test_integration_subdoc.cxx +721 -7
- data/ext/couchbase/test/test_transaction_public_async_api.cxx +13 -12
- data/ext/couchbase/test/test_transaction_public_blocking_api.cxx +27 -21
- data/ext/couchbase/test/test_unit_connection_string.cxx +29 -0
- data/ext/couchbase/test/test_unit_query.cxx +75 -0
- data/ext/couchbase.cxx +735 -60
- data/ext/revisions.rb +3 -3
- data/lib/couchbase/cluster.rb +1 -1
- data/lib/couchbase/collection.rb +108 -0
- data/lib/couchbase/collection_options.rb +100 -1
- data/lib/couchbase/errors.rb +5 -0
- data/lib/couchbase/key_value_scan.rb +125 -0
- data/lib/couchbase/management/bucket_manager.rb +22 -15
- data/lib/couchbase/management/collection_manager.rb +158 -9
- data/lib/couchbase/options.rb +151 -0
- data/lib/couchbase/scope.rb +1 -1
- data/lib/couchbase/utils/time.rb +14 -1
- data/lib/couchbase/version.rb +1 -1
- metadata +59 -8
- data/ext/couchbase/core/impl/collection_query_index_manager.cxx +0 -93
@@ -81,35 +81,4 @@ class watch_query_indexes_options : public common_options<watch_query_indexes_op
|
|
81
81
|
*/
|
82
82
|
|
83
83
|
using watch_query_indexes_handler = std::function<void(couchbase::manager_error_context)>;
|
84
|
-
|
85
|
-
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
86
|
-
namespace core
|
87
|
-
{
|
88
|
-
class cluster;
|
89
|
-
class query_context;
|
90
|
-
namespace impl
|
91
|
-
{
|
92
|
-
|
93
|
-
/**
|
94
|
-
* @since 1.0.0
|
95
|
-
* @internal
|
96
|
-
*/
|
97
|
-
void
|
98
|
-
initiate_watch_query_indexes(std::shared_ptr<couchbase::core::cluster> core,
|
99
|
-
std::string bucket_name,
|
100
|
-
std::vector<std::string> index_names,
|
101
|
-
couchbase::watch_query_indexes_options::built options,
|
102
|
-
query_context query_ctx,
|
103
|
-
std::string collection_name,
|
104
|
-
watch_query_indexes_handler&& handler);
|
105
|
-
void
|
106
|
-
initiate_watch_query_indexes(std::shared_ptr<couchbase::core::cluster> core,
|
107
|
-
std::string bucket_name,
|
108
|
-
std::vector<std::string> index_names,
|
109
|
-
couchbase::watch_query_indexes_options::built options,
|
110
|
-
watch_query_indexes_handler&& handler);
|
111
|
-
|
112
|
-
#endif
|
113
|
-
} // namespace impl
|
114
|
-
} // namespace core
|
115
84
|
} // namespace couchbase
|
@@ -113,6 +113,12 @@ TEST_CASE("integration: get and insert non default scope and collection", "[inte
|
|
113
113
|
REQUIRE_SUCCESS(resp.ctx.ec());
|
114
114
|
REQUIRE(resp.value == couchbase::core::utils::to_binary(key));
|
115
115
|
}
|
116
|
+
|
117
|
+
{
|
118
|
+
couchbase::core::operations::management::scope_drop_request req{ integration.ctx.bucket, scope_name };
|
119
|
+
auto resp = test::utils::execute(integration.cluster, req);
|
120
|
+
REQUIRE_SUCCESS(resp.ctx.ec);
|
121
|
+
}
|
116
122
|
}
|
117
123
|
|
118
124
|
TEST_CASE("integration: insert into dropped scope", "[integration]")
|
@@ -315,6 +315,11 @@ TEST_CASE("integration: lock/unlock without lock time", "[integration]")
|
|
315
315
|
TEST_CASE("integration: touch with zero expiry resets expiry", "[integration]")
|
316
316
|
{
|
317
317
|
test::utils::integration_test_guard integration;
|
318
|
+
|
319
|
+
if (integration.ctx.deployment == test::utils::deployment_type::elixir) {
|
320
|
+
SKIP("Timeout is too strict for sanity test env");
|
321
|
+
}
|
322
|
+
|
318
323
|
test::utils::open_bucket(integration.cluster, integration.ctx.bucket);
|
319
324
|
|
320
325
|
couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("get_reset_expiry_key") };
|
@@ -132,6 +132,9 @@ row: {"airline":{"callsign":"MILE-AIR","country":"United States","iata":"Q5","ic
|
|
132
132
|
TEST_CASE("example: start using", "[integration]")
|
133
133
|
{
|
134
134
|
test::utils::integration_test_guard integration;
|
135
|
+
if (integration.cluster_version().is_capella()) {
|
136
|
+
SKIP("Capella does not allow to use REST API to load sample buckets");
|
137
|
+
}
|
135
138
|
if (!integration.cluster_version().supports_collections()) {
|
136
139
|
SKIP("cluster does not support collections");
|
137
140
|
}
|
@@ -438,8 +441,12 @@ row: {"airline":{"callsign":"MILE-AIR","country":"United States","iata":"Q5","ic
|
|
438
441
|
TEST_CASE("example: search", "[integration]")
|
439
442
|
{
|
440
443
|
test::utils::integration_test_guard integration;
|
444
|
+
|
445
|
+
if (integration.cluster_version().is_capella()) {
|
446
|
+
SKIP("Capella does not allow to use REST API to load sample buckets");
|
447
|
+
}
|
441
448
|
if (!integration.cluster_version().supports_collections()) {
|
442
|
-
|
449
|
+
SKIP("cluster does not support collections");
|
443
450
|
}
|
444
451
|
|
445
452
|
const auto env = test::utils::test_context::load_from_environment();
|
@@ -452,3 +459,132 @@ TEST_CASE("example: search", "[integration]")
|
|
452
459
|
|
453
460
|
REQUIRE(example_search::main(4, argv) == 0);
|
454
461
|
}
|
462
|
+
|
463
|
+
namespace example_buckets
|
464
|
+
{
|
465
|
+
//! [example-buckets]
|
466
|
+
#include <couchbase/cluster.hxx>
|
467
|
+
|
468
|
+
int
|
469
|
+
main(int argc, const char* argv[])
|
470
|
+
{
|
471
|
+
if (argc != 4) {
|
472
|
+
fmt::print("USAGE: ./example_buckets couchbase://127.0.0.1 Administrator password\n");
|
473
|
+
return 1;
|
474
|
+
}
|
475
|
+
|
476
|
+
std::string connection_string{ argv[1] }; // "couchbase://127.0.0.1"
|
477
|
+
std::string username{ argv[2] }; // "Administrator"
|
478
|
+
std::string password{ argv[3] }; // "password"
|
479
|
+
std::string bucket_name{ "travel-sample" };
|
480
|
+
|
481
|
+
// run IO context on separate thread
|
482
|
+
asio::io_context io;
|
483
|
+
auto guard = asio::make_work_guard(io);
|
484
|
+
std::thread io_thread([&io]() { io.run(); });
|
485
|
+
|
486
|
+
auto options = couchbase::cluster_options(username, password);
|
487
|
+
// customize through the 'options'.
|
488
|
+
// For example, optimize timeouts for WAN
|
489
|
+
options.apply_profile("wan_development");
|
490
|
+
|
491
|
+
auto [cluster, ec] = couchbase::cluster::connect(io, connection_string, options).get();
|
492
|
+
if (ec) {
|
493
|
+
fmt::print("unable to connect to the cluster: {}\n", ec.message());
|
494
|
+
return 1;
|
495
|
+
}
|
496
|
+
auto manager = cluster.buckets();
|
497
|
+
|
498
|
+
couchbase::management::cluster::bucket_settings bucket_settings{};
|
499
|
+
std::string test_bucket_name = "cxx_test_integration_examples_bucket";
|
500
|
+
bucket_settings.name = test_bucket_name;
|
501
|
+
bucket_settings.ram_quota_mb = 150;
|
502
|
+
bucket_settings.bucket_type = couchbase::management::cluster::bucket_type::couchbase;
|
503
|
+
bucket_settings.eviction_policy = couchbase::management::cluster::bucket_eviction_policy::value_only;
|
504
|
+
bucket_settings.flush_enabled = true;
|
505
|
+
bucket_settings.replica_indexes = true;
|
506
|
+
bucket_settings.conflict_resolution_type = couchbase::management::cluster::bucket_conflict_resolution::sequence_number;
|
507
|
+
{
|
508
|
+
fmt::print("--- create bucket\n");
|
509
|
+
auto ctx = manager.create_bucket(bucket_settings).get();
|
510
|
+
if (ctx.ec()) {
|
511
|
+
if (ctx.ec() == couchbase::errc::common::invalid_argument) {
|
512
|
+
fmt::print("bucket already exists\n");
|
513
|
+
} else {
|
514
|
+
fmt::print("unable to create the bucket: {}\n", ctx.ec().message());
|
515
|
+
return 1;
|
516
|
+
}
|
517
|
+
} else {
|
518
|
+
fmt::print("--- bucket has been successfully created\n");
|
519
|
+
}
|
520
|
+
}
|
521
|
+
{
|
522
|
+
fmt::print("--- get bucket\n");
|
523
|
+
auto [ctx, bucket] = manager.get_bucket(bucket_name).get();
|
524
|
+
if (ctx.ec()) {
|
525
|
+
fmt::print("unable to get the bucket: {}\n", ctx.ec().message());
|
526
|
+
return 1;
|
527
|
+
}
|
528
|
+
fmt::print("name of fetched bucket: {}\n", bucket.name);
|
529
|
+
}
|
530
|
+
{
|
531
|
+
fmt::print("--- get all buckets\n");
|
532
|
+
auto [ctx, buckets] = manager.get_all_buckets().get();
|
533
|
+
if (ctx.ec()) {
|
534
|
+
fmt::print("unable to get all buckets: {}\n", ctx.ec().message());
|
535
|
+
return 1;
|
536
|
+
}
|
537
|
+
for (const auto& fetched_bucket : buckets) {
|
538
|
+
fmt::print("Bucket name: {}\n", fetched_bucket.name);
|
539
|
+
}
|
540
|
+
}
|
541
|
+
{
|
542
|
+
fmt::print("--- update bucket\n");
|
543
|
+
bucket_settings.ram_quota_mb = 150;
|
544
|
+
auto ctx = manager.update_bucket(bucket_settings).get();
|
545
|
+
if (ctx.ec()) {
|
546
|
+
fmt::print("unable to update the bucket: {}\n", ctx.ec().message());
|
547
|
+
return 1;
|
548
|
+
}
|
549
|
+
fmt::print("bucket has been updated\n");
|
550
|
+
}
|
551
|
+
{
|
552
|
+
fmt::print("--- drop bucket\n");
|
553
|
+
auto ctx = manager.drop_bucket(test_bucket_name).get();
|
554
|
+
if (ctx.ec()) {
|
555
|
+
fmt::print("unable to drop the bucket: {}\n", ctx.ec().message());
|
556
|
+
return 1;
|
557
|
+
}
|
558
|
+
fmt::print("bucket has been dropped\n");
|
559
|
+
}
|
560
|
+
|
561
|
+
// close cluster connection
|
562
|
+
cluster.close();
|
563
|
+
guard.reset();
|
564
|
+
|
565
|
+
io_thread.join();
|
566
|
+
return 0;
|
567
|
+
}
|
568
|
+
|
569
|
+
//! [example-buckets]
|
570
|
+
} // namespace example_buckets
|
571
|
+
|
572
|
+
TEST_CASE("example: bucket management", "[integration]")
|
573
|
+
{
|
574
|
+
test::utils::integration_test_guard integration;
|
575
|
+
|
576
|
+
if (integration.cluster_version().is_capella()) {
|
577
|
+
SKIP("Capella does not allow to use REST API to load sample buckets");
|
578
|
+
}
|
579
|
+
|
580
|
+
const auto env = test::utils::test_context::load_from_environment();
|
581
|
+
|
582
|
+
const char* argv[] = {
|
583
|
+
"example_buckets", // name of the "executable"
|
584
|
+
env.connection_string.c_str(),
|
585
|
+
env.username.c_str(),
|
586
|
+
env.password.c_str(),
|
587
|
+
};
|
588
|
+
|
589
|
+
REQUIRE(example_buckets::main(4, argv) == 0);
|
590
|
+
}
|