21
21
#include < core/meta/version.hxx>
22
22
23
23
#include < asio.hpp>
24
+ #include < openssl/crypto.h>
24
25
#include < spdlog/cfg/env.h>
25
26
#include < spdlog/sinks/base_sink.h>
26
27
#include < spdlog/spdlog.h>
37
38
#include < core/agent_group.hxx>
38
39
#include < core/design_document_namespace_fmt.hxx>
39
40
#include < core/logger/configuration.hxx>
41
+ #include < core/logger/logger.hxx>
40
42
#include < core/operations.hxx>
41
43
42
44
#include < core/operations/management/analytics.hxx>
@@ -485,7 +487,7 @@ cb_Backend_allocate(VALUE klass)
485
487
cb_backend_data* backend = nullptr ;
486
488
VALUE obj = TypedData_Make_Struct (klass, cb_backend_data, &cb_backend_type, backend);
487
489
backend->ctx = std::make_unique<asio::io_context>();
488
- backend->cluster = couchbase::core::cluster::create (*backend->ctx );
490
+ backend->cluster = std::make_shared< couchbase::core::cluster> (*backend->ctx );
489
491
backend->worker = std::thread ([backend]() { backend->ctx ->run (); });
490
492
return obj;
491
493
}
@@ -527,6 +529,7 @@ static VALUE eDocumentExists;
527
529
static VALUE eDocumentIrretrievable;
528
530
static VALUE eDocumentLocked;
529
531
static VALUE eDocumentNotFound;
532
+ static VALUE eDocumentNotLocked;
530
533
static VALUE eDocumentNotJson;
531
534
static VALUE eDurabilityAmbiguous;
532
535
static VALUE eDurabilityImpossible;
@@ -623,6 +626,7 @@ init_exceptions(VALUE mCouchbase)
623
626
eDocumentIrretrievable = rb_define_class_under (mError , " DocumentIrretrievable" , eCouchbaseError);
624
627
eDocumentLocked = rb_define_class_under (mError , " DocumentLocked" , eCouchbaseError);
625
628
eDocumentNotFound = rb_define_class_under (mError , " DocumentNotFound" , eCouchbaseError);
629
+ eDocumentNotLocked = rb_define_class_under (mError , " DocumentNotLocked" , eCouchbaseError);
626
630
eDocumentNotJson = rb_define_class_under (mError , " DocumentNotJson" , eCouchbaseError);
627
631
eDurabilityAmbiguous = rb_define_class_under (mError , " DurabilityAmbiguous" , eCouchbaseError);
628
632
eDurabilityImpossible = rb_define_class_under (mError , " DurabilityImpossible" , eCouchbaseError);
@@ -776,6 +780,9 @@ cb_map_error_code(std::error_code ec, const std::string& message, bool include_e
776
780
case couchbase::errc::key_value::document_locked:
777
781
return rb_exc_new_cstr (eDocumentLocked, what.c_str ());
778
782
783
+ case couchbase::errc::key_value::document_not_locked:
784
+ return rb_exc_new_cstr (eDocumentNotLocked, what.c_str ());
785
+
779
786
case couchbase::errc::key_value::value_too_large:
780
787
return rb_exc_new_cstr (eValueTooLarge, what.c_str ());
781
788
@@ -1802,6 +1809,12 @@ cb_extract_timeout(std::chrono::milliseconds& field, VALUE options)
1802
1809
cb_extract_duration (field, options, " timeout" );
1803
1810
}
1804
1811
1812
+ static void
1813
+ cb_extract_timeout (std::optional<std::chrono::milliseconds>& field, VALUE options)
1814
+ {
1815
+ cb_extract_duration (field, options, " timeout" );
1816
+ }
1817
+
1805
1818
static void
1806
1819
cb_extract_cas (couchbase::cas& field, VALUE cas)
1807
1820
{
@@ -2454,9 +2467,12 @@ cb_Backend_ping(VALUE self, VALUE bucket, VALUE options)
2454
2467
}
2455
2468
}
2456
2469
}
2470
+ std::optional<std::chrono::milliseconds> timeout{};
2471
+ cb_extract_timeout (timeout, options);
2472
+
2457
2473
auto barrier = std::make_shared<std::promise<couchbase::core::diag::ping_result>>();
2458
2474
auto f = barrier->get_future ();
2459
- cluster->ping (report_id, bucket_name, selected_services, [barrier](couchbase::core::diag::ping_result&& resp) {
2475
+ cluster->ping (report_id, bucket_name, selected_services, timeout, [barrier](couchbase::core::diag::ping_result&& resp) {
2460
2476
barrier->set_value (std::move (resp));
2461
2477
});
2462
2478
auto resp = cb_wait_for_future (f);
@@ -2583,7 +2599,7 @@ cb_Backend_document_get_any_replica(VALUE self, VALUE bucket, VALUE scope, VALUE
2583
2599
couchbase::get_any_replica_options opts;
2584
2600
couchbase::ruby::set_timeout (opts, options);
2585
2601
2586
- auto f = couchbase::cluster (core)
2602
+ auto f = couchbase::cluster (* core)
2587
2603
.bucket (cb_string_new (bucket))
2588
2604
.scope (cb_string_new (scope))
2589
2605
.collection (cb_string_new (collection))
@@ -2621,7 +2637,7 @@ cb_Backend_document_get_all_replicas(VALUE self, VALUE bucket, VALUE scope, VALU
2621
2637
couchbase::get_all_replicas_options opts;
2622
2638
couchbase::ruby::set_timeout (opts, options);
2623
2639
2624
- auto f = couchbase::cluster (core)
2640
+ auto f = couchbase::cluster (* core)
2625
2641
.bucket (cb_string_new (bucket))
2626
2642
.scope (cb_string_new (scope))
2627
2643
.collection (cb_string_new (collection))
@@ -3018,12 +3034,11 @@ cb_Backend_document_upsert(VALUE self, VALUE bucket, VALUE scope, VALUE collecti
3018
3034
couchbase::ruby::set_durability (opts, options);
3019
3035
couchbase::ruby::set_preserve_expiry (opts, options);
3020
3036
3021
- auto f = couchbase::cluster (core)
3037
+ auto f = couchbase::cluster (* core)
3022
3038
.bucket (cb_string_new (bucket))
3023
3039
.scope (cb_string_new (scope))
3024
3040
.collection (cb_string_new (collection))
3025
- .upsert <couchbase::ruby::passthrough_transcoder>(
3026
- cb_string_new (id), couchbase::codec::encoded_value{ cb_binary_new (content), FIX2UINT (flags) }, opts);
3041
+ .upsert (cb_string_new (id), couchbase::codec::encoded_value{ cb_binary_new (content), FIX2UINT (flags) }, opts);
3027
3042
3028
3043
auto [ctx, resp] = cb_wait_for_future (f);
3029
3044
if (ctx.ec ()) {
@@ -3051,7 +3066,7 @@ cb_Backend_document_upsert_multi(VALUE self, VALUE bucket, VALUE scope, VALUE co
3051
3066
couchbase::ruby::set_durability (opts, options);
3052
3067
couchbase::ruby::set_preserve_expiry (opts, options);
3053
3068
3054
- auto c = couchbase::cluster (core).bucket (cb_string_new (bucket)).scope (cb_string_new (scope)).collection (cb_string_new (collection));
3069
+ auto c = couchbase::cluster (* core).bucket (cb_string_new (bucket)).scope (cb_string_new (scope)).collection (cb_string_new (collection));
3055
3070
3056
3071
std::vector<std::pair<std::string, couchbase::codec::encoded_value>> tuples{};
3057
3072
cb_extract_array_of_id_content (tuples, id_content);
@@ -3061,7 +3076,7 @@ cb_Backend_document_upsert_multi(VALUE self, VALUE bucket, VALUE scope, VALUE co
3061
3076
futures.reserve (num_of_tuples);
3062
3077
3063
3078
for (auto & [id, content] : tuples) {
3064
- futures.emplace_back (c.upsert <couchbase::ruby::passthrough_transcoder> (std::move (id), content, opts));
3079
+ futures.emplace_back (c.upsert (std::move (id), content, opts));
3065
3080
}
3066
3081
3067
3082
VALUE res = rb_ary_new_capa (static_cast <long >(num_of_tuples));
@@ -3102,7 +3117,7 @@ cb_Backend_document_append(VALUE self, VALUE bucket, VALUE scope, VALUE collecti
3102
3117
couchbase::ruby::set_timeout (opts, options);
3103
3118
couchbase::ruby::set_durability (opts, options);
3104
3119
3105
- auto f = couchbase::cluster (core)
3120
+ auto f = couchbase::cluster (* core)
3106
3121
.bucket (cb_string_new (bucket))
3107
3122
.scope (cb_string_new (scope))
3108
3123
.collection (cb_string_new (collection))
@@ -3142,7 +3157,7 @@ cb_Backend_document_prepend(VALUE self, VALUE bucket, VALUE scope, VALUE collect
3142
3157
couchbase::ruby::set_timeout (opts, options);
3143
3158
couchbase::ruby::set_durability (opts, options);
3144
3159
3145
- auto f = couchbase::cluster (core)
3160
+ auto f = couchbase::cluster (* core)
3146
3161
.bucket (cb_string_new (bucket))
3147
3162
.scope (cb_string_new (scope))
3148
3163
.collection (cb_string_new (collection))
@@ -3186,12 +3201,11 @@ cb_Backend_document_replace(VALUE self, VALUE bucket, VALUE scope, VALUE collect
3186
3201
couchbase::ruby::set_preserve_expiry (opts, options);
3187
3202
couchbase::ruby::set_cas (opts, options);
3188
3203
3189
- auto f = couchbase::cluster (core)
3204
+ auto f = couchbase::cluster (* core)
3190
3205
.bucket (cb_string_new (bucket))
3191
3206
.scope (cb_string_new (scope))
3192
3207
.collection (cb_string_new (collection))
3193
- .replace <couchbase::ruby::passthrough_transcoder>(
3194
- cb_string_new (id), couchbase::codec::encoded_value{ cb_binary_new (content), FIX2UINT (flags) }, opts);
3208
+ .replace (cb_string_new (id), couchbase::codec::encoded_value{ cb_binary_new (content), FIX2UINT (flags) }, opts);
3195
3209
3196
3210
auto [ctx, resp] = cb_wait_for_future (f);
3197
3211
if (ctx.ec ()) {
@@ -3228,12 +3242,11 @@ cb_Backend_document_insert(VALUE self, VALUE bucket, VALUE scope, VALUE collecti
3228
3242
couchbase::ruby::set_expiry (opts, options);
3229
3243
couchbase::ruby::set_durability (opts, options);
3230
3244
3231
- auto f = couchbase::cluster (core)
3245
+ auto f = couchbase::cluster (* core)
3232
3246
.bucket (cb_string_new (bucket))
3233
3247
.scope (cb_string_new (scope))
3234
3248
.collection (cb_string_new (collection))
3235
- .insert <couchbase::ruby::passthrough_transcoder>(
3236
- cb_string_new (id), couchbase::codec::encoded_value{ cb_binary_new (content), FIX2UINT (flags) }, opts);
3249
+ .insert (cb_string_new (id), couchbase::codec::encoded_value{ cb_binary_new (content), FIX2UINT (flags) }, opts);
3237
3250
3238
3251
auto [ctx, resp] = cb_wait_for_future (f);
3239
3252
if (ctx.ec ()) {
@@ -3268,7 +3281,7 @@ cb_Backend_document_remove(VALUE self, VALUE bucket, VALUE scope, VALUE collecti
3268
3281
couchbase::ruby::set_durability (opts, options);
3269
3282
couchbase::ruby::set_cas (opts, options);
3270
3283
3271
- auto f = couchbase::cluster (core)
3284
+ auto f = couchbase::cluster (* core)
3272
3285
.bucket (cb_string_new (bucket))
3273
3286
.scope (cb_string_new (scope))
3274
3287
.collection (cb_string_new (collection))
@@ -3305,7 +3318,7 @@ cb_Backend_document_remove_multi(VALUE self, VALUE bucket, VALUE scope, VALUE co
3305
3318
std::vector<std::pair<std::string, couchbase::cas>> tuples{};
3306
3319
cb_extract_array_of_id_cas (tuples, id_cas);
3307
3320
3308
- auto c = couchbase::cluster (core).bucket (cb_string_new (bucket)).scope (cb_string_new (scope)).collection (cb_string_new (collection));
3321
+ auto c = couchbase::cluster (* core).bucket (cb_string_new (bucket)).scope (cb_string_new (scope)).collection (cb_string_new (collection));
3309
3322
3310
3323
auto num_of_tuples = tuples.size ();
3311
3324
std::vector<std::future<std::pair<couchbase::key_value_error_context, couchbase::mutation_result>>> futures;
@@ -3357,7 +3370,7 @@ cb_Backend_document_increment(VALUE self, VALUE bucket, VALUE scope, VALUE colle
3357
3370
couchbase::ruby::set_delta (opts, options);
3358
3371
couchbase::ruby::set_initial_value (opts, options);
3359
3372
3360
- auto f = couchbase::cluster (core)
3373
+ auto f = couchbase::cluster (* core)
3361
3374
.bucket (cb_string_new (bucket))
3362
3375
.scope (cb_string_new (scope))
3363
3376
.collection (cb_string_new (collection))
@@ -3401,7 +3414,7 @@ cb_Backend_document_decrement(VALUE self, VALUE bucket, VALUE scope, VALUE colle
3401
3414
couchbase::ruby::set_delta (opts, options);
3402
3415
couchbase::ruby::set_initial_value (opts, options);
3403
3416
3404
- auto f = couchbase::cluster (core)
3417
+ auto f = couchbase::cluster (* core)
3405
3418
.bucket (cb_string_new (bucket))
3406
3419
.scope (cb_string_new (scope))
3407
3420
.collection (cb_string_new (collection))
@@ -3873,7 +3886,7 @@ cb_Backend_document_mutate_in(VALUE self, VALUE bucket, VALUE scope, VALUE colle
3873
3886
}
3874
3887
}
3875
3888
3876
- auto f = couchbase::cluster (core)
3889
+ auto f = couchbase::cluster (* core)
3877
3890
.bucket (cb_string_new (bucket))
3878
3891
.scope (cb_string_new (scope))
3879
3892
.collection (cb_string_new (collection))
@@ -4095,7 +4108,7 @@ cb_Backend_document_scan_create(VALUE self, VALUE bucket, VALUE scope, VALUE col
4095
4108
auto collection_name = cb_string_new (collection);
4096
4109
4097
4110
// Getting the operation agent
4098
- auto agent_group = couchbase::core::agent_group (cluster->io_context (), couchbase::core::agent_group_config{ { cluster } });
4111
+ auto agent_group = couchbase::core::agent_group (cluster->io_context (), couchbase::core::agent_group_config{ { * cluster } });
4099
4112
agent_group.open_bucket (bucket_name);
4100
4113
auto agent = agent_group.get_agent (bucket_name);
4101
4114
if (!agent.has_value ()) {
@@ -6939,11 +6952,11 @@ cb_Backend_search_get_stats(VALUE self, VALUE timeout)
6939
6952
const auto & cluster = cb_backend_to_cluster (self);
6940
6953
6941
6954
try {
6942
- couchbase::core::operations::management::search_index_stats_request req{};
6955
+ couchbase::core::operations::management::search_get_stats_request req{};
6943
6956
cb_extract_timeout (req, timeout);
6944
- auto barrier = std::make_shared<std::promise<couchbase::core::operations::management::search_index_stats_response >>();
6957
+ auto barrier = std::make_shared<std::promise<couchbase::core::operations::management::search_get_stats_response >>();
6945
6958
auto f = barrier->get_future ();
6946
- cluster->execute (req, [barrier](couchbase::core::operations::management::search_index_stats_response && resp) {
6959
+ cluster->execute (req, [barrier](couchbase::core::operations::management::search_get_stats_response && resp) {
6947
6960
barrier->set_value (std::move (resp));
6948
6961
});
6949
6962
auto resp = cb_wait_for_future (f);
0 commit comments