couchbase 3.5.7 → 3.6.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/cache/extconf_include.rb +3 -3
- data/ext/cache/mozilla-ca-bundle.crt +3 -165
- data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
- data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/CMakeLists.txt +14 -10
- data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.cc +7 -4
- data/ext/couchbase/CMakeLists.txt +12 -1
- data/ext/couchbase/cmake/Profiler.cmake +15 -0
- data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +2 -2
- data/ext/couchbase/cmake/couchbase_cxx_client.pc.in +1 -1
- data/ext/couchbase/core/app_telemetry_address.cxx +55 -0
- data/ext/couchbase/core/app_telemetry_address.hxx +39 -0
- data/ext/couchbase/core/app_telemetry_meter.cxx +753 -0
- data/ext/couchbase/core/app_telemetry_meter.hxx +198 -0
- data/ext/couchbase/core/app_telemetry_reporter.cxx +895 -0
- data/ext/couchbase/core/app_telemetry_reporter.hxx +59 -0
- data/ext/couchbase/core/bucket.cxx +77 -35
- data/ext/couchbase/core/bucket.hxx +17 -10
- data/ext/couchbase/core/cluster.cxx +54 -16
- data/ext/couchbase/core/cluster_credentials.cxx +27 -0
- data/ext/couchbase/core/cluster_credentials.hxx +36 -0
- data/ext/couchbase/core/cluster_options.hxx +12 -0
- data/ext/couchbase/core/collections_component.cxx +7 -5
- data/ext/couchbase/core/http_component.cxx +6 -0
- data/ext/couchbase/core/impl/binary_collection.cxx +4 -0
- data/ext/couchbase/core/impl/bucket_manager.cxx +2 -0
- data/ext/couchbase/core/impl/cluster.cxx +9 -0
- data/ext/couchbase/core/impl/collection.cxx +2 -0
- data/ext/couchbase/core/impl/error.cxx +1 -0
- data/ext/couchbase/core/impl/logger.cxx +51 -0
- data/ext/couchbase/core/impl/replica_utils.cxx +1 -1
- data/ext/couchbase/core/impl/transaction_get_multi_replicas_from_preferred_server_group_spec.cxx +32 -0
- data/ext/couchbase/core/impl/transaction_get_multi_spec.cxx +30 -0
- data/ext/couchbase/core/impl/transaction_op_error_category.cxx +2 -0
- data/ext/couchbase/core/io/config_tracker.cxx +6 -6
- data/ext/couchbase/core/io/http_command.hxx +35 -11
- data/ext/couchbase/core/io/http_session.cxx +10 -0
- data/ext/couchbase/core/io/http_session.hxx +4 -0
- data/ext/couchbase/core/io/http_session_manager.hxx +83 -34
- data/ext/couchbase/core/io/mcbp_command.hxx +41 -2
- data/ext/couchbase/core/io/mcbp_session.cxx +52 -19
- data/ext/couchbase/core/io/mcbp_session.hxx +3 -0
- data/ext/couchbase/core/logger/logger.cxx +46 -0
- data/ext/couchbase/core/logger/logger.hxx +41 -1
- data/ext/couchbase/core/management/bucket_settings.hxx +1 -0
- data/ext/couchbase/core/management/bucket_settings_json.hxx +4 -0
- data/ext/couchbase/core/meta/features.hxx +32 -0
- data/ext/couchbase/core/operations/document_analytics.cxx +9 -9
- data/ext/couchbase/core/operations/document_append.cxx +1 -0
- data/ext/couchbase/core/operations/document_append.hxx +1 -0
- data/ext/couchbase/core/operations/document_get_all_replicas.hxx +10 -2
- data/ext/couchbase/core/operations/document_lookup_in.cxx +4 -0
- data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +14 -2
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +4 -0
- data/ext/couchbase/core/operations/document_mutate_in.cxx +4 -0
- data/ext/couchbase/core/operations/document_mutate_in.hxx +1 -0
- data/ext/couchbase/core/operations/document_prepend.cxx +1 -0
- data/ext/couchbase/core/operations/document_prepend.hxx +1 -0
- data/ext/couchbase/core/operations/document_query.cxx +12 -10
- data/ext/couchbase/core/operations/http_noop.cxx +1 -0
- data/ext/couchbase/core/operations/management/bucket_create.cxx +3 -0
- data/ext/couchbase/core/operations/management/bucket_update.cxx +3 -0
- data/ext/couchbase/core/origin.cxx +0 -5
- data/ext/couchbase/core/origin.hxx +2 -11
- data/ext/couchbase/core/platform/random.cc +6 -3
- data/ext/couchbase/core/platform/random.h +2 -2
- data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +9 -0
- data/ext/couchbase/core/timeout_defaults.hxx +4 -0
- data/ext/couchbase/core/topology/configuration.cxx +10 -13
- data/ext/couchbase/core/topology/configuration.hxx +14 -15
- data/ext/couchbase/core/topology/configuration_json.hxx +6 -0
- data/ext/couchbase/core/transactions/async_attempt_context.hxx +22 -2
- data/ext/couchbase/core/transactions/attempt_context.hxx +25 -7
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +688 -238
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +91 -12
- data/ext/couchbase/core/transactions/exceptions.cxx +5 -0
- data/ext/couchbase/core/transactions/exceptions.hxx +20 -0
- data/ext/couchbase/core/transactions/exceptions_fmt.hxx +3 -0
- data/ext/couchbase/core/transactions/forward_compat.cxx +71 -6
- data/ext/couchbase/core/transactions/forward_compat.hxx +45 -59
- data/ext/couchbase/core/transactions/get_multi_orchestrator.cxx +616 -0
- data/ext/couchbase/core/transactions/get_multi_orchestrator.hxx +61 -0
- data/ext/couchbase/core/transactions/internal/doc_record.cxx +8 -0
- data/ext/couchbase/core/transactions/internal/doc_record.hxx +16 -5
- data/ext/couchbase/core/transactions/internal/exceptions_internal.hxx +12 -0
- data/ext/couchbase/core/transactions/internal/transaction_context.hxx +13 -0
- data/ext/couchbase/core/transactions/internal/transaction_fields.hxx +1 -0
- data/ext/couchbase/core/transactions/staged_mutation.cxx +277 -96
- data/ext/couchbase/core/transactions/staged_mutation.hxx +28 -76
- data/ext/couchbase/core/transactions/transaction_context.cxx +33 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_mode.hxx +28 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +27 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +71 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_result.hxx +66 -0
- data/ext/couchbase/core/transactions/transaction_links.hxx +10 -0
- data/ext/couchbase/core/transactions/transactions.cxx +8 -3
- data/ext/couchbase/core/utils/connection_string.cxx +4 -0
- data/ext/couchbase/core/utils/url_codec.cxx +26 -0
- data/ext/couchbase/core/utils/url_codec.hxx +11 -0
- data/ext/couchbase/core/websocket_codec.cxx +647 -0
- data/ext/couchbase/core/websocket_codec.hxx +77 -0
- data/ext/couchbase/couchbase/analytics_options.hxx +70 -6
- data/ext/couchbase/couchbase/application_telemetry_options.hxx +124 -0
- data/ext/couchbase/couchbase/cluster_options.hxx +17 -0
- data/ext/couchbase/couchbase/error_codes.hxx +1 -0
- data/ext/couchbase/couchbase/logger.hxx +16 -0
- data/ext/couchbase/couchbase/management/bucket_settings.hxx +1 -0
- data/ext/couchbase/couchbase/query_options.hxx +70 -6
- data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +29 -5
- data/ext/couchbase/couchbase/transactions/attempt_context.hxx +24 -7
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_mode.hxx +47 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_options.hxx +44 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +46 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx +48 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +109 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx +47 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_result.hxx +102 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_spec.hxx +45 -0
- data/ext/rcb_buckets.cxx +26 -0
- data/lib/active_support/cache/couchbase_store.rb +1 -1
- data/lib/couchbase/cluster.rb +1 -1
- data/lib/couchbase/collection.rb +1 -1
- data/lib/couchbase/collection_options.rb +2 -2
- data/lib/couchbase/management/analytics_index_manager.rb +4 -4
- data/lib/couchbase/management/bucket_manager.rb +8 -2
- data/lib/couchbase/protostellar/cluster.rb +2 -2
- data/lib/couchbase/protostellar/collection.rb +1 -1
- data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +1 -1
- data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +4 -4
- data/lib/couchbase/protostellar/request_generator/admin/collection.rb +6 -6
- data/lib/couchbase/protostellar/request_generator/admin/query.rb +13 -13
- data/lib/couchbase/protostellar/request_generator/kv.rb +25 -25
- data/lib/couchbase/protostellar/request_generator/query.rb +4 -4
- data/lib/couchbase/protostellar/request_generator/search.rb +25 -25
- data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
- data/lib/couchbase/protostellar/retry/reason.rb +1 -1
- data/lib/couchbase/protostellar/timeouts.rb +1 -1
- data/lib/couchbase/scope.rb +1 -1
- data/lib/couchbase/transcoder_flags.rb +1 -1
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -1
- data/lib/couchbase/version.rb +1 -1
- metadata +47 -19
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/COPYING +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/SnappyConfig.cmake.in +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/config.h.in +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.cc +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-internal.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.cc +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.cc +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-public.h.in +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.h +0 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2024-Present Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
6
|
+
* except in compliance with the License. You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
12
|
+
* ANY KIND, either express or implied. See the License for the specific language governing
|
13
|
+
* permissions and limitations under the License.
|
14
|
+
*/
|
15
|
+
|
16
|
+
#pragma once
|
17
|
+
|
18
|
+
#include <gsl/span>
|
19
|
+
|
20
|
+
#include <cstddef>
|
21
|
+
#include <memory>
|
22
|
+
#include <string>
|
23
|
+
#include <string_view>
|
24
|
+
#include <vector>
|
25
|
+
|
26
|
+
namespace couchbase::core
|
27
|
+
{
|
28
|
+
class websocket_codec;
|
29
|
+
class websocket_handler;
|
30
|
+
|
31
|
+
class websocket_callbacks
|
32
|
+
{
|
33
|
+
public:
|
34
|
+
websocket_callbacks() = default;
|
35
|
+
websocket_callbacks(const websocket_callbacks&) = default;
|
36
|
+
websocket_callbacks(websocket_callbacks&&) noexcept = default;
|
37
|
+
auto operator=(const websocket_callbacks&) -> websocket_callbacks& = default;
|
38
|
+
auto operator=(websocket_callbacks&&) noexcept -> websocket_callbacks& = default;
|
39
|
+
virtual ~websocket_callbacks() = default;
|
40
|
+
|
41
|
+
virtual void on_text(const websocket_codec& ws, gsl::span<std::byte> payload) = 0;
|
42
|
+
virtual void on_binary(const websocket_codec& ws, gsl::span<std::byte> payload) = 0;
|
43
|
+
virtual void on_ping(const websocket_codec& ws, gsl::span<std::byte> payload) = 0;
|
44
|
+
virtual void on_pong(const websocket_codec& ws, gsl::span<std::byte> payload) = 0;
|
45
|
+
virtual void on_close(const websocket_codec& ws, gsl::span<std::byte> payload) = 0;
|
46
|
+
|
47
|
+
virtual void on_ready(const websocket_codec& ws) = 0;
|
48
|
+
virtual void on_error(const websocket_codec& ws, const std::string& message) = 0;
|
49
|
+
};
|
50
|
+
|
51
|
+
class websocket_codec
|
52
|
+
{
|
53
|
+
public:
|
54
|
+
explicit websocket_codec(websocket_callbacks* callbacks);
|
55
|
+
websocket_codec(const websocket_codec&) = delete;
|
56
|
+
websocket_codec(websocket_codec&&) = delete;
|
57
|
+
auto operator=(const websocket_codec&) -> websocket_codec& = delete;
|
58
|
+
auto operator=(websocket_codec&&) noexcept -> websocket_codec& = delete;
|
59
|
+
~websocket_codec();
|
60
|
+
|
61
|
+
[[nodiscard]] auto session_key() const -> const std::string&;
|
62
|
+
|
63
|
+
void feed(gsl::span<std::byte> chunk);
|
64
|
+
void feed(std::string_view chunk);
|
65
|
+
|
66
|
+
[[nodiscard]] auto text(std::string_view message) const -> std::vector<std::byte>;
|
67
|
+
[[nodiscard]] auto binary(gsl::span<std::byte> message) const -> std::vector<std::byte>;
|
68
|
+
[[nodiscard]] auto ping(gsl::span<std::byte> message = {}) const -> std::vector<std::byte>;
|
69
|
+
[[nodiscard]] auto pong(gsl::span<std::byte> message = {}) const -> std::vector<std::byte>;
|
70
|
+
[[nodiscard]] auto close(gsl::span<std::byte> message) const -> std::vector<std::byte>;
|
71
|
+
|
72
|
+
private:
|
73
|
+
std::string session_key_;
|
74
|
+
websocket_callbacks* callbacks_;
|
75
|
+
std::unique_ptr<websocket_handler> handler_;
|
76
|
+
};
|
77
|
+
} // namespace couchbase::core
|
@@ -246,7 +246,8 @@ struct analytics_options : public common_options<analytics_options> {
|
|
246
246
|
}
|
247
247
|
|
248
248
|
/**
|
249
|
-
* Set list of positional parameters for a query.
|
249
|
+
* Set list of positional parameters for a query. Any existing positional parameters will be
|
250
|
+
* overridden.
|
250
251
|
*
|
251
252
|
* @tparam Parameters types for the parameters
|
252
253
|
* @param parameters the sequence of positional parameters. Each entry will be encoded into JSON.
|
@@ -260,14 +261,13 @@ struct analytics_options : public common_options<analytics_options> {
|
|
260
261
|
std::enable_if_t<codec::is_serializer_v<Serializer>, bool> = true>
|
261
262
|
auto positional_parameters(const Parameters&... parameters) -> analytics_options&
|
262
263
|
{
|
263
|
-
named_parameters_.clear();
|
264
264
|
positional_parameters_.clear();
|
265
265
|
encode_positional_parameters<Serializer>(parameters...);
|
266
266
|
return self();
|
267
267
|
}
|
268
268
|
|
269
269
|
/**
|
270
|
-
* Set list of named parameters for a query.
|
270
|
+
* Set list of named parameters for a query. Any existing named parameters will be overridden.
|
271
271
|
*
|
272
272
|
* @tparam Parameters types for the parameter pairs
|
273
273
|
* @param parameters the sequence of name-value pairs. Each value will be encoded into JSON.
|
@@ -282,11 +282,77 @@ struct analytics_options : public common_options<analytics_options> {
|
|
282
282
|
auto named_parameters(const Parameters&... parameters) -> analytics_options&
|
283
283
|
{
|
284
284
|
named_parameters_.clear();
|
285
|
-
positional_parameters_.clear();
|
286
285
|
encode_named_parameters<Serializer>(parameters...);
|
287
286
|
return self();
|
288
287
|
}
|
289
288
|
|
289
|
+
/**
|
290
|
+
* Adds a positional parameter to the current list of positional parameters.
|
291
|
+
*
|
292
|
+
* @tparam Parameter type for the parameter.
|
293
|
+
* @param parameter the positional parameter. It will be encoded into JSON.
|
294
|
+
* @return this options builder for chaining purposes.
|
295
|
+
*
|
296
|
+
* @since 1.1.0
|
297
|
+
* @committed
|
298
|
+
*/
|
299
|
+
template<typename Serializer = codec::tao_json_serializer,
|
300
|
+
typename Parameter,
|
301
|
+
std::enable_if_t<codec::is_serializer_v<Serializer>, bool> = true>
|
302
|
+
auto add_positional_parameter(const Parameter& parameter) -> analytics_options&
|
303
|
+
{
|
304
|
+
encode_positional_parameters<Serializer>(parameter);
|
305
|
+
return self();
|
306
|
+
}
|
307
|
+
|
308
|
+
/**
|
309
|
+
* Adds a named parameter to the current list of named parameters.
|
310
|
+
*
|
311
|
+
* @tparam Value type for the named parameter's value.
|
312
|
+
* @param name the named parameter's name
|
313
|
+
* @param value the named parameter's value. It will be encoded into JSON.
|
314
|
+
* @return this options builder for chaining purposes.
|
315
|
+
*
|
316
|
+
* @since 1.1.0
|
317
|
+
* @committed
|
318
|
+
*/
|
319
|
+
template<typename Serializer = codec::tao_json_serializer,
|
320
|
+
typename Value,
|
321
|
+
std::enable_if_t<codec::is_serializer_v<Serializer>, bool> = true>
|
322
|
+
auto add_named_parameter(const std::string& name, const Value& value) -> analytics_options&
|
323
|
+
{
|
324
|
+
encode_named_parameters<Serializer>(std::make_pair(name, value));
|
325
|
+
return self();
|
326
|
+
}
|
327
|
+
|
328
|
+
/**
|
329
|
+
* Clears the list of positional parameters.
|
330
|
+
*
|
331
|
+
* @return this options builder for chaining purposes.
|
332
|
+
*
|
333
|
+
* @since 1.1.0
|
334
|
+
* @committed
|
335
|
+
*/
|
336
|
+
auto clear_positional_parameters() -> analytics_options&
|
337
|
+
{
|
338
|
+
positional_parameters_.clear();
|
339
|
+
return self();
|
340
|
+
}
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Clears the list of named parameters.
|
344
|
+
*
|
345
|
+
* @return this options builder for chaining purposes.
|
346
|
+
*
|
347
|
+
* @since 1.1.0
|
348
|
+
* @committed
|
349
|
+
*/
|
350
|
+
auto clear_named_parameters() -> analytics_options&
|
351
|
+
{
|
352
|
+
named_parameters_.clear();
|
353
|
+
return self();
|
354
|
+
}
|
355
|
+
|
290
356
|
/**
|
291
357
|
* Set map of raw options for a query.
|
292
358
|
*
|
@@ -325,7 +391,6 @@ struct analytics_options : public common_options<analytics_options> {
|
|
325
391
|
*/
|
326
392
|
auto encoded_positional_parameters(std::vector<codec::binary> parameters) -> analytics_options&
|
327
393
|
{
|
328
|
-
named_parameters_.clear();
|
329
394
|
positional_parameters_ = std::move(parameters);
|
330
395
|
return self();
|
331
396
|
}
|
@@ -348,7 +413,6 @@ struct analytics_options : public common_options<analytics_options> {
|
|
348
413
|
-> analytics_options&
|
349
414
|
{
|
350
415
|
named_parameters_ = std::move(parameters);
|
351
|
-
positional_parameters_.clear();
|
352
416
|
return self();
|
353
417
|
}
|
354
418
|
|
@@ -0,0 +1,124 @@
|
|
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 <chrono>
|
21
|
+
#include <cstddef>
|
22
|
+
#include <string>
|
23
|
+
|
24
|
+
namespace couchbase
|
25
|
+
{
|
26
|
+
class application_telemetry_options
|
27
|
+
{
|
28
|
+
public:
|
29
|
+
static constexpr std::chrono::milliseconds default_ping_interval{ std::chrono::seconds{ 30 } };
|
30
|
+
static constexpr std::chrono::milliseconds default_ping_timeout{ std::chrono::seconds{ 2 } };
|
31
|
+
static constexpr std::chrono::milliseconds default_backoff_interval{ std::chrono::hours{ 1 } };
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Whether to enable application telemetry.
|
35
|
+
*
|
36
|
+
* @param enable true if the application service telemetry have to be enabled.
|
37
|
+
*
|
38
|
+
* @since 1.1.0
|
39
|
+
*/
|
40
|
+
auto enable(bool enable) -> application_telemetry_options&
|
41
|
+
{
|
42
|
+
enabled_ = enable;
|
43
|
+
return *this;
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* How often the SDK should ping application service telemetry collector.
|
48
|
+
*
|
49
|
+
* @param interval ping interval in milliseconds.
|
50
|
+
*
|
51
|
+
* @since 1.1.0
|
52
|
+
*/
|
53
|
+
auto ping_interval(std::chrono::milliseconds interval) -> application_telemetry_options&
|
54
|
+
{
|
55
|
+
ping_interval_ = interval;
|
56
|
+
return *this;
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* How long the SDK should wait for ping response (pong frame) back from application service
|
61
|
+
* telemetry collector.
|
62
|
+
*
|
63
|
+
* @param timeout ping timeout in milliseconds.
|
64
|
+
*
|
65
|
+
* @since 1.1.0
|
66
|
+
*/
|
67
|
+
auto ping_timeout(std::chrono::milliseconds timeout) -> application_telemetry_options&
|
68
|
+
{
|
69
|
+
ping_timeout_ = timeout;
|
70
|
+
return *this;
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Override the endpoint for the application service telementry.
|
75
|
+
*
|
76
|
+
* The endpoint must use WebSocket protocol and the string should start from `ws://` and might
|
77
|
+
* have URL path.
|
78
|
+
*
|
79
|
+
* @param endpoint connection string for the telementry collector.
|
80
|
+
*
|
81
|
+
* @since 1.1.0
|
82
|
+
*/
|
83
|
+
auto override_endpoint(std::string endpoint) -> application_telemetry_options&
|
84
|
+
{
|
85
|
+
endpoint_ = std::move(endpoint);
|
86
|
+
return *this;
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* How long should the SDK wait between connection attempts to the collector to avoid performance
|
91
|
+
* and stability issues on the collector side.
|
92
|
+
*
|
93
|
+
* @param interval backoff interval in milliseconds
|
94
|
+
*
|
95
|
+
* @since 1.1.0
|
96
|
+
*/
|
97
|
+
auto backoff_interval(std::chrono::milliseconds interval) -> application_telemetry_options&
|
98
|
+
{
|
99
|
+
backoff_interval_ = interval;
|
100
|
+
return *this;
|
101
|
+
}
|
102
|
+
struct built {
|
103
|
+
bool enabled;
|
104
|
+
std::chrono::milliseconds ping_interval;
|
105
|
+
std::chrono::milliseconds ping_timeout;
|
106
|
+
std::chrono::milliseconds backoff_interval;
|
107
|
+
std::string endpoint;
|
108
|
+
};
|
109
|
+
|
110
|
+
[[nodiscard]] auto build() const -> built
|
111
|
+
{
|
112
|
+
return {
|
113
|
+
enabled_, ping_interval_, ping_timeout_, backoff_interval_, endpoint_,
|
114
|
+
};
|
115
|
+
}
|
116
|
+
|
117
|
+
private:
|
118
|
+
bool enabled_{ true };
|
119
|
+
std::chrono::milliseconds ping_interval_{ default_ping_interval };
|
120
|
+
std::chrono::milliseconds ping_timeout_{ default_ping_timeout };
|
121
|
+
std::chrono::milliseconds backoff_interval_{ default_backoff_interval };
|
122
|
+
std::string endpoint_{};
|
123
|
+
};
|
124
|
+
} // namespace couchbase
|
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
#pragma once
|
19
19
|
|
20
|
+
#include <couchbase/application_telemetry_options.hxx>
|
20
21
|
#include <couchbase/behavior_options.hxx>
|
21
22
|
#include <couchbase/certificate_authenticator.hxx>
|
22
23
|
#include <couchbase/compression_options.hxx>
|
@@ -221,6 +222,19 @@ public:
|
|
221
222
|
return transactions_;
|
222
223
|
}
|
223
224
|
|
225
|
+
/**
|
226
|
+
* Returns the Application Telemetry options.
|
227
|
+
*
|
228
|
+
* @return application telemetry options.
|
229
|
+
*
|
230
|
+
* @since 1.1.0
|
231
|
+
* @committed
|
232
|
+
*/
|
233
|
+
[[nodiscard]] auto application_telemetry() -> application_telemetry_options&
|
234
|
+
{
|
235
|
+
return application_telemetry_;
|
236
|
+
}
|
237
|
+
|
224
238
|
/**
|
225
239
|
* Override default retry strategy
|
226
240
|
*
|
@@ -254,6 +268,7 @@ public:
|
|
254
268
|
behavior_options::built behavior;
|
255
269
|
transactions::transactions_config::built transactions;
|
256
270
|
std::shared_ptr<retry_strategy> default_retry_strategy;
|
271
|
+
application_telemetry_options::built application_telemetry;
|
257
272
|
};
|
258
273
|
|
259
274
|
[[nodiscard]] auto build() const -> built
|
@@ -274,6 +289,7 @@ public:
|
|
274
289
|
behavior_.build(),
|
275
290
|
transactions_.build(),
|
276
291
|
default_retry_strategy_,
|
292
|
+
application_telemetry_.build(),
|
277
293
|
};
|
278
294
|
}
|
279
295
|
|
@@ -294,6 +310,7 @@ private:
|
|
294
310
|
behavior_options behavior_{};
|
295
311
|
transactions::transactions_config transactions_{};
|
296
312
|
std::shared_ptr<retry_strategy> default_retry_strategy_{ nullptr };
|
313
|
+
application_telemetry_options application_telemetry_{};
|
297
314
|
};
|
298
315
|
|
299
316
|
#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
|
@@ -17,6 +17,8 @@
|
|
17
17
|
|
18
18
|
#pragma once
|
19
19
|
|
20
|
+
#include <functional>
|
21
|
+
#include <string>
|
20
22
|
#include <string_view>
|
21
23
|
|
22
24
|
namespace couchbase::logger
|
@@ -31,6 +33,20 @@ enum class log_level {
|
|
31
33
|
off,
|
32
34
|
};
|
33
35
|
|
36
|
+
struct log_location {
|
37
|
+
std::string file;
|
38
|
+
std::string function;
|
39
|
+
int line;
|
40
|
+
};
|
41
|
+
|
42
|
+
using log_callback = std::function<void(std::string_view, log_level, log_location)>;
|
43
|
+
|
44
|
+
void
|
45
|
+
register_log_callback(const log_callback& callback);
|
46
|
+
|
47
|
+
void
|
48
|
+
unregister_log_callback();
|
49
|
+
|
34
50
|
void
|
35
51
|
set_level(log_level level);
|
36
52
|
|
@@ -126,6 +126,7 @@ struct bucket_settings {
|
|
126
126
|
std::optional<bool> history_retention_collection_default{};
|
127
127
|
std::optional<std::uint32_t> history_retention_bytes;
|
128
128
|
std::optional<std::uint32_t> history_retention_duration{};
|
129
|
+
std::optional<std::uint16_t> num_vbuckets{};
|
129
130
|
|
130
131
|
/**
|
131
132
|
* UNCOMMITTED: This API may change in the future
|
@@ -450,7 +450,8 @@ struct query_options : public common_options<query_options> {
|
|
450
450
|
}
|
451
451
|
|
452
452
|
/**
|
453
|
-
* Set list of positional parameters for a query.
|
453
|
+
* Set list of positional parameters for a query. Any existing positional parameters will be
|
454
|
+
* overridden.
|
454
455
|
*
|
455
456
|
* @tparam Parameters types for the parameters
|
456
457
|
* @param parameters the sequence of positional parameters. Each entry will be encoded into JSON.
|
@@ -464,14 +465,13 @@ struct query_options : public common_options<query_options> {
|
|
464
465
|
std::enable_if_t<codec::is_serializer_v<Serializer>, bool> = true>
|
465
466
|
auto positional_parameters(const Parameters&... parameters) -> query_options&
|
466
467
|
{
|
467
|
-
named_parameters_.clear();
|
468
468
|
positional_parameters_.clear();
|
469
469
|
encode_positional_parameters<Serializer>(parameters...);
|
470
470
|
return self();
|
471
471
|
}
|
472
472
|
|
473
473
|
/**
|
474
|
-
* Set list of named parameters for a query.
|
474
|
+
* Set list of named parameters for a query. Any existing named parameters will be overridden.
|
475
475
|
*
|
476
476
|
* @tparam Parameters types for the parameter pairs
|
477
477
|
* @param parameters the sequence of name-value pairs. Each value will be encoded into JSON.
|
@@ -486,11 +486,77 @@ struct query_options : public common_options<query_options> {
|
|
486
486
|
auto named_parameters(const Parameters&... parameters) -> query_options&
|
487
487
|
{
|
488
488
|
named_parameters_.clear();
|
489
|
-
positional_parameters_.clear();
|
490
489
|
encode_named_parameters<Serializer>(parameters...);
|
491
490
|
return self();
|
492
491
|
}
|
493
492
|
|
493
|
+
/**
|
494
|
+
* Adds a positional parameter to the current list of positional parameters.
|
495
|
+
*
|
496
|
+
* @tparam Parameter type for the parameter.
|
497
|
+
* @param parameter the positional parameter. It will be encoded into JSON.
|
498
|
+
* @return this options builder for chaining purposes.
|
499
|
+
*
|
500
|
+
* @since 1.1.0
|
501
|
+
* @committed
|
502
|
+
*/
|
503
|
+
template<typename Serializer = codec::tao_json_serializer,
|
504
|
+
typename Parameter,
|
505
|
+
std::enable_if_t<codec::is_serializer_v<Serializer>, bool> = true>
|
506
|
+
auto add_positional_parameter(const Parameter& parameter) -> query_options&
|
507
|
+
{
|
508
|
+
encode_positional_parameters<Serializer>(parameter);
|
509
|
+
return self();
|
510
|
+
}
|
511
|
+
|
512
|
+
/**
|
513
|
+
* Adds a named parameter to the current list of named parameters.
|
514
|
+
*
|
515
|
+
* @tparam Value type for the named parameter's value.
|
516
|
+
* @param name the named parameter's name
|
517
|
+
* @param value the named parameter's value. It will be encoded into JSON.
|
518
|
+
* @return this options builder for chaining purposes.
|
519
|
+
*
|
520
|
+
* @since 1.1.0
|
521
|
+
* @committed
|
522
|
+
*/
|
523
|
+
template<typename Serializer = codec::tao_json_serializer,
|
524
|
+
typename Value,
|
525
|
+
std::enable_if_t<codec::is_serializer_v<Serializer>, bool> = true>
|
526
|
+
auto add_named_parameter(const std::string& name, const Value& value) -> query_options&
|
527
|
+
{
|
528
|
+
encode_named_parameters<Serializer>(std::make_pair(name, value));
|
529
|
+
return self();
|
530
|
+
}
|
531
|
+
|
532
|
+
/**
|
533
|
+
* Clears the list of positional parameters.
|
534
|
+
*
|
535
|
+
* @return this options builder for chaining purposes.
|
536
|
+
*
|
537
|
+
* @since 1.1.0
|
538
|
+
* @committed
|
539
|
+
*/
|
540
|
+
auto clear_positional_parameters() -> query_options&
|
541
|
+
{
|
542
|
+
positional_parameters_.clear();
|
543
|
+
return self();
|
544
|
+
}
|
545
|
+
|
546
|
+
/**
|
547
|
+
* Clears the list of named parameters.
|
548
|
+
*
|
549
|
+
* @return this options builder for chaining purposes.
|
550
|
+
*
|
551
|
+
* @since 1.1.0
|
552
|
+
* @committed
|
553
|
+
*/
|
554
|
+
auto clear_named_parameters() -> query_options&
|
555
|
+
{
|
556
|
+
named_parameters_.clear();
|
557
|
+
return self();
|
558
|
+
}
|
559
|
+
|
494
560
|
/**
|
495
561
|
* Set map of raw options for a query.
|
496
562
|
*
|
@@ -529,7 +595,6 @@ struct query_options : public common_options<query_options> {
|
|
529
595
|
*/
|
530
596
|
auto encoded_positional_parameters(std::vector<codec::binary> parameters) -> query_options&
|
531
597
|
{
|
532
|
-
named_parameters_.clear();
|
533
598
|
positional_parameters_ = std::move(parameters);
|
534
599
|
return self();
|
535
600
|
}
|
@@ -552,7 +617,6 @@ struct query_options : public common_options<query_options> {
|
|
552
617
|
-> query_options&
|
553
618
|
{
|
554
619
|
named_parameters_ = std::move(parameters);
|
555
|
-
positional_parameters_.clear();
|
556
620
|
return self();
|
557
621
|
}
|
558
622
|
|
@@ -15,6 +15,12 @@
|
|
15
15
|
*/
|
16
16
|
#pragma once
|
17
17
|
|
18
|
+
#include <couchbase/transactions/transaction_get_multi_options.hxx>
|
19
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx>
|
20
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx>
|
21
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx>
|
22
|
+
#include <couchbase/transactions/transaction_get_multi_result.hxx>
|
23
|
+
#include <couchbase/transactions/transaction_get_multi_spec.hxx>
|
18
24
|
#include <couchbase/transactions/transaction_get_result.hxx>
|
19
25
|
#include <couchbase/transactions/transaction_query_options.hxx>
|
20
26
|
#include <couchbase/transactions/transaction_query_result.hxx>
|
@@ -40,8 +46,14 @@ using async_err_handler = std::function<void(error)>;
|
|
40
46
|
*/
|
41
47
|
class async_attempt_context
|
42
48
|
{
|
43
|
-
|
44
49
|
public:
|
50
|
+
virtual ~async_attempt_context() = default;
|
51
|
+
async_attempt_context() = default;
|
52
|
+
async_attempt_context(async_attempt_context&&) noexcept = default;
|
53
|
+
async_attempt_context(const async_attempt_context&) = default;
|
54
|
+
auto operator=(async_attempt_context&&) -> async_attempt_context& = default;
|
55
|
+
auto operator=(const async_attempt_context&) -> async_attempt_context& = default;
|
56
|
+
|
45
57
|
/**
|
46
58
|
* Get document from a collection.
|
47
59
|
*
|
@@ -80,6 +92,18 @@ public:
|
|
80
92
|
const std::string& id,
|
81
93
|
async_result_handler&& handler) = 0;
|
82
94
|
|
95
|
+
virtual void get_multi(
|
96
|
+
const std::vector<transaction_get_multi_spec>& specs,
|
97
|
+
const transaction_get_multi_options& options,
|
98
|
+
std::function<void(error, std::optional<transaction_get_multi_result>)>&& cb) = 0;
|
99
|
+
|
100
|
+
virtual void get_multi_replicas_from_preferred_server_group(
|
101
|
+
const std::vector<transaction_get_multi_replicas_from_preferred_server_group_spec>& specs,
|
102
|
+
const transaction_get_multi_replicas_from_preferred_server_group_options& options,
|
103
|
+
std::function<void(
|
104
|
+
error,
|
105
|
+
std::optional<transaction_get_multi_replicas_from_preferred_server_group_result>)>&& cb) = 0;
|
106
|
+
|
83
107
|
/**
|
84
108
|
* Remove a document from a collection.
|
85
109
|
*
|
@@ -114,7 +138,8 @@ public:
|
|
114
138
|
Document&& content,
|
115
139
|
async_result_handler&& handler)
|
116
140
|
{
|
117
|
-
return insert_raw(
|
141
|
+
return insert_raw(
|
142
|
+
coll, id, Transcoder::encode(std::forward<Document>(content)), std::move(handler));
|
118
143
|
}
|
119
144
|
/**
|
120
145
|
* Replace the contents of a document in a collection.
|
@@ -134,7 +159,8 @@ public:
|
|
134
159
|
std::enable_if_t<!std::is_same_v<codec::encoded_value, Document>, bool> = true>
|
135
160
|
void replace(transaction_get_result doc, Document&& content, async_result_handler&& handler)
|
136
161
|
{
|
137
|
-
return replace_raw(
|
162
|
+
return replace_raw(
|
163
|
+
std::move(doc), Transcoder::encode(std::forward<Document>(content)), std::move(handler));
|
138
164
|
}
|
139
165
|
/**
|
140
166
|
* Perform a query, within a scope.
|
@@ -178,8 +204,6 @@ public:
|
|
178
204
|
return query(std::move(statement), {}, std::move(handler));
|
179
205
|
}
|
180
206
|
|
181
|
-
virtual ~async_attempt_context() = default;
|
182
|
-
|
183
207
|
protected:
|
184
208
|
/** @private */
|
185
209
|
virtual void insert_raw(const collection& coll,
|
@@ -15,11 +15,18 @@
|
|
15
15
|
*/
|
16
16
|
#pragma once
|
17
17
|
|
18
|
+
#include <couchbase/transactions/transaction_get_multi_options.hxx>
|
19
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx>
|
20
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx>
|
21
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx>
|
22
|
+
#include <couchbase/transactions/transaction_get_multi_result.hxx>
|
23
|
+
#include <couchbase/transactions/transaction_get_multi_spec.hxx>
|
18
24
|
#include <couchbase/transactions/transaction_get_result.hxx>
|
19
25
|
#include <couchbase/transactions/transaction_query_options.hxx>
|
20
26
|
#include <couchbase/transactions/transaction_query_result.hxx>
|
21
27
|
|
22
28
|
#include <stdexcept>
|
29
|
+
#include <vector>
|
23
30
|
|
24
31
|
namespace couchbase
|
25
32
|
{
|
@@ -62,8 +69,8 @@ public:
|
|
62
69
|
*
|
63
70
|
* @see transactions::transaction_get_result for more complete example
|
64
71
|
*/
|
65
|
-
virtual auto get(const couchbase::collection& coll,
|
66
|
-
|
72
|
+
virtual auto get(const couchbase::collection& coll, const std::string& id)
|
73
|
+
-> std::pair<error, transaction_get_result> = 0;
|
67
74
|
|
68
75
|
/**
|
69
76
|
* Get a document copy from the selected server group.
|
@@ -91,6 +98,17 @@ public:
|
|
91
98
|
const std::string& id)
|
92
99
|
-> std::pair<error, transaction_get_result> = 0;
|
93
100
|
|
101
|
+
virtual auto get_multi(const std::vector<transaction_get_multi_spec>& specs,
|
102
|
+
const transaction_get_multi_options& options)
|
103
|
+
-> std::pair<error, std::optional<transaction_get_multi_result>> = 0;
|
104
|
+
|
105
|
+
virtual auto get_multi_replicas_from_preferred_server_group(
|
106
|
+
const std::vector<transaction_get_multi_replicas_from_preferred_server_group_spec>& specs,
|
107
|
+
const transaction_get_multi_replicas_from_preferred_server_group_options& options)
|
108
|
+
-> std::pair<
|
109
|
+
error,
|
110
|
+
std::optional<transaction_get_multi_replicas_from_preferred_server_group_result>> = 0;
|
111
|
+
|
94
112
|
/**
|
95
113
|
* Insert a document into a collection.
|
96
114
|
*
|
@@ -109,9 +127,8 @@ public:
|
|
109
127
|
template<typename Transcoder = codec::default_json_transcoder,
|
110
128
|
typename Document,
|
111
129
|
std::enable_if_t<!std::is_same_v<codec::encoded_value, Document>, bool> = true>
|
112
|
-
auto insert(const couchbase::collection& coll,
|
113
|
-
|
114
|
-
const Document& content) -> std::pair<error, transaction_get_result>
|
130
|
+
auto insert(const couchbase::collection& coll, const std::string& id, const Document& content)
|
131
|
+
-> std::pair<error, transaction_get_result>
|
115
132
|
{
|
116
133
|
codec::encoded_value data;
|
117
134
|
try {
|
@@ -151,8 +168,8 @@ public:
|
|
151
168
|
template<typename Transcoder = codec::default_json_transcoder,
|
152
169
|
typename Document,
|
153
170
|
std::enable_if_t<!std::is_same_v<codec::encoded_value, Document>, bool> = true>
|
154
|
-
auto replace(const transaction_get_result& doc,
|
155
|
-
|
171
|
+
auto replace(const transaction_get_result& doc, const Document& content)
|
172
|
+
-> std::pair<error, transaction_get_result>
|
156
173
|
{
|
157
174
|
codec::encoded_value data;
|
158
175
|
try {
|