couchbase 4.2.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/.gitmodules +3 -0
- package/deps/couchbase-cxx-client/.idea/misc.xml +1 -0
- package/deps/couchbase-cxx-client/.idea/vcs.xml +1 -0
- package/deps/couchbase-cxx-client/CMakeLists.txt +11 -1
- package/deps/couchbase-cxx-client/README.md +3 -3
- package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +4 -1
- package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +13 -1
- package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
- package/deps/couchbase-cxx-client/core/cluster.hxx +15 -5
- package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +17 -6
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +93 -0
- package/deps/couchbase-cxx-client/core/impl/configuration_profiles_registry.cxx +11 -0
- package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +119 -0
- package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +108 -0
- package/deps/couchbase-cxx-client/core/impl/get.cxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +76 -0
- package/deps/couchbase-cxx-client/core/impl/query.cxx +5 -7
- package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +168 -0
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +15 -1
- package/deps/couchbase-cxx-client/core/logger/configuration.hxx +3 -0
- package/deps/couchbase-cxx-client/core/logger/level.hxx +21 -0
- package/deps/couchbase-cxx-client/core/logger/logger.hxx +4 -6
- package/deps/couchbase-cxx-client/core/meta/CMakeLists.txt +4 -2
- package/deps/couchbase-cxx-client/core/meta/features.hxx +31 -0
- package/deps/couchbase-cxx-client/core/meta/version.cxx +67 -5
- package/deps/couchbase-cxx-client/core/meta/version.hxx +12 -1
- package/deps/couchbase-cxx-client/core/metrics/CMakeLists.txt +4 -1
- package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +46 -5
- package/deps/couchbase-cxx-client/core/metrics/logging_meter.hxx +10 -26
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -2
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +10 -12
- package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -3
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build.cxx +8 -14
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +15 -8
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +7 -14
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +11 -16
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.cxx +8 -12
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.cxx +21 -12
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -2
- package/deps/couchbase-cxx-client/core/origin.hxx +1 -1
- package/deps/couchbase-cxx-client/core/platform/uuid.cc +1 -2
- package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +5 -1
- package/deps/couchbase-cxx-client/core/query_context.hxx +79 -0
- package/deps/couchbase-cxx-client/core/tracing/CMakeLists.txt +3 -1
- package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +19 -4
- package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.hxx +2 -2
- package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +10 -4
- package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +52 -63
- package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +8 -3
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +163 -126
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +24 -37
- package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +4 -4
- package/deps/couchbase-cxx-client/core/transactions/internal/atr_cleanup_entry.hxx +51 -13
- package/deps/couchbase-cxx-client/core/transactions/internal/client_record.hxx +26 -1
- package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +21 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/logging.hxx +40 -18
- package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +5 -0
- package/deps/couchbase-cxx-client/core/transactions/result.hxx +26 -0
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +48 -47
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +6 -6
- package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -19
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +18 -2
- package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +25 -2
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +4 -4
- package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +49 -56
- package/deps/couchbase-cxx-client/core/transactions/waitable_op_list.hxx +7 -7
- package/deps/couchbase-cxx-client/core/transactions.hxx +0 -12
- package/deps/couchbase-cxx-client/core/utils/binary.hxx +1 -1
- package/deps/couchbase-cxx-client/core/utils/keyspace.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +12 -45
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +6 -7
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +8 -0
- package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +218 -0
- package/deps/couchbase-cxx-client/couchbase/configuration_profiles_registry.hxx +3 -0
- package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +166 -0
- package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +172 -0
- package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +129 -0
- package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +116 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/cas.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/fmt/query_scan_consistency.hxx +46 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/query_status.hxx +70 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/tls_verify_mode.hxx +46 -0
- package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +100 -0
- package/deps/couchbase-cxx-client/{core → couchbase}/management/query_index.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +178 -6
- package/deps/couchbase-cxx-client/couchbase/query_options.hxx +1 -18
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +5 -2
- package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +11 -4
- package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +5 -3
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +0 -6
- package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +115 -0
- package/deps/couchbase-cxx-client/examples/minimal.cxx +3 -1
- package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +72 -0
- package/deps/couchbase-cxx-client/test/test_integration_management.cxx +727 -310
- package/deps/couchbase-cxx-client/test/test_integration_query.cxx +4 -8
- package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +14 -0
- package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_blocking_api.cxx +34 -19
- package/deps/couchbase-cxx-client/test/test_unit_transaction_logging.cxx +66 -22
- package/deps/couchbase-cxx-client/test/test_unit_utils.cxx +51 -0
- package/deps/couchbase-cxx-client/test/tools/tool_kv_loader.cxx +2 -2
- package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -0
- package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +4 -4
- package/deps/couchbase-cxx-client/third_party/docopt/.travis.yml +103 -0
- package/deps/couchbase-cxx-client/third_party/docopt/CMakeLists.txt +129 -0
- package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-Boost-1.0 +23 -0
- package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-MIT +23 -0
- package/deps/couchbase-cxx-client/third_party/docopt/README.rst +479 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt-config.cmake +1 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt.cpp +687 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt.h +98 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt.pc.in +9 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt_private.h +676 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt_util.h +122 -0
- package/deps/couchbase-cxx-client/third_party/docopt/docopt_value.h +341 -0
- package/deps/couchbase-cxx-client/third_party/docopt/examples/naval_fate.cpp +36 -0
- package/deps/couchbase-cxx-client/third_party/docopt/main.cpp +16 -0
- package/deps/couchbase-cxx-client/third_party/docopt/run_testcase.cpp +40 -0
- package/deps/couchbase-cxx-client/third_party/docopt/run_tests.py +72 -0
- package/deps/couchbase-cxx-client/third_party/docopt/testcases.docopt +957 -0
- package/deps/couchbase-cxx-client/tools/CMakeLists.txt +14 -0
- package/deps/couchbase-cxx-client/tools/cbc.cxx +65 -0
- package/deps/couchbase-cxx-client/tools/command.hxx +31 -0
- package/deps/couchbase-cxx-client/tools/command_registry.cxx +43 -0
- package/deps/couchbase-cxx-client/tools/command_registry.hxx +39 -0
- package/deps/couchbase-cxx-client/tools/get.cxx +267 -0
- package/deps/couchbase-cxx-client/tools/get.hxx +26 -0
- package/deps/couchbase-cxx-client/tools/query.cxx +441 -0
- package/deps/couchbase-cxx-client/tools/query.hxx +26 -0
- package/deps/couchbase-cxx-client/tools/utils.cxx +418 -0
- package/deps/couchbase-cxx-client/tools/utils.hxx +150 -0
- package/deps/couchbase-cxx-client/tools/version.cxx +82 -0
- package/deps/couchbase-cxx-client/tools/version.hxx +26 -0
- package/dist/authenticators.d.ts +2 -2
- package/dist/authenticators.js +1 -2
- package/dist/binding.d.ts +32 -16
- package/dist/cluster.js +14 -7
- package/dist/collection.d.ts +6 -0
- package/dist/collection.js +8 -0
- package/dist/queryexecutor.js +1 -1
- package/dist/queryindexmanager.d.ts +100 -4
- package/dist/queryindexmanager.js +344 -118
- package/dist/transactions.js +0 -2
- package/package.json +1 -1
- package/src/connection.cpp +2 -0
- package/src/connection.hpp +1 -0
- package/src/connection_autogen.cpp +16 -0
- package/src/jstocbpp_autogen.hpp +93 -23
- package/src/jstocbpp_basic.hpp +24 -0
- package/src/jstocbpp_transactions.hpp +0 -8
- package/tools/gen-bindings-js.js +1 -0
- package/tools/gen-bindings-json.py +4 -2
- package/deps/couchbase-cxx-client/core/transactions/logging.cxx +0 -107
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023-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
|
+
#include "utils.hxx"
|
|
19
|
+
|
|
20
|
+
#include <core/logger/configuration.hxx>
|
|
21
|
+
#include <core/logger/logger.hxx>
|
|
22
|
+
#include <core/meta/version.hxx>
|
|
23
|
+
|
|
24
|
+
#include <couchbase/fmt/durability_level.hxx>
|
|
25
|
+
#include <couchbase/fmt/query_scan_consistency.hxx>
|
|
26
|
+
#include <couchbase/fmt/tls_verify_mode.hxx>
|
|
27
|
+
|
|
28
|
+
#include <spdlog/details/os.h>
|
|
29
|
+
#include <spdlog/spdlog.h>
|
|
30
|
+
|
|
31
|
+
#include <regex>
|
|
32
|
+
|
|
33
|
+
namespace cbc
|
|
34
|
+
{
|
|
35
|
+
docopt::Options
|
|
36
|
+
parse_options(const std::string& doc, const std::vector<std::string>& argv, bool options_first)
|
|
37
|
+
{
|
|
38
|
+
try {
|
|
39
|
+
return docopt::docopt_parse(doc, argv, false, true, options_first);
|
|
40
|
+
} catch (const docopt::DocoptExitHelp&) {
|
|
41
|
+
fmt::print(stdout, doc);
|
|
42
|
+
std::exit(0);
|
|
43
|
+
} catch (const docopt::DocoptExitVersion&) {
|
|
44
|
+
fmt::print(stdout, "cbc {}\n", couchbase::core::meta::sdk_semver());
|
|
45
|
+
std::exit(0);
|
|
46
|
+
} catch (const docopt::DocoptLanguageError& error) {
|
|
47
|
+
fmt::print(stdout, "Docopt usage string could not be parsed. Please report this error.\n{}\n", error.what());
|
|
48
|
+
std::exit(-1);
|
|
49
|
+
} catch (const docopt::DocoptArgumentError&) {
|
|
50
|
+
fmt::print(stdout, doc);
|
|
51
|
+
fflush(stdout);
|
|
52
|
+
throw;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static auto
|
|
57
|
+
getenv_or_default(std::string_view var_name, const std::string& default_value) -> std::string
|
|
58
|
+
{
|
|
59
|
+
if (auto val = spdlog::details::os::getenv(var_name.data()); !val.empty()) {
|
|
60
|
+
return val;
|
|
61
|
+
}
|
|
62
|
+
return default_value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
auto
|
|
66
|
+
default_cluster_options() -> const couchbase::cluster_options&
|
|
67
|
+
{
|
|
68
|
+
static const couchbase::cluster_options default_cluster_options_(getenv_or_default("CBC_USERNAME", "Administrator"),
|
|
69
|
+
getenv_or_default("CBC_PASSWORD", "password"));
|
|
70
|
+
return default_cluster_options_;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
auto
|
|
74
|
+
default_connection_string() -> const std::string&
|
|
75
|
+
{
|
|
76
|
+
static const std::string default_connection_string_ = getenv_or_default("CBC_CONNECTION_STRING", "couchbase://localhost");
|
|
77
|
+
|
|
78
|
+
return default_connection_string_;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
auto
|
|
82
|
+
usage_block_for_cluster_options() -> std::string
|
|
83
|
+
{
|
|
84
|
+
const auto default_user_agent_extra{ "cbc" };
|
|
85
|
+
const auto default_options = default_cluster_options().build();
|
|
86
|
+
const auto connection_string = default_connection_string();
|
|
87
|
+
|
|
88
|
+
return fmt::format(
|
|
89
|
+
R"(
|
|
90
|
+
Connection options:
|
|
91
|
+
--connection-string=STRING Connection string for the cluster. CBC_CONNECTION_STRING. [default: {connection_string}]
|
|
92
|
+
--username=STRING Username for the cluster. CBC_USERNAME. [default: {username}]
|
|
93
|
+
--password=STRING Password for the cluster. CBC_PASSWORD. [default: {password}]
|
|
94
|
+
--certificate-path=STRING Path to the certificate.
|
|
95
|
+
--key-path=STRING Path to the key.
|
|
96
|
+
--ldap-compatible Whether to select authentication mechanism that is compatible with LDAP.
|
|
97
|
+
--configuration-profile=STRING Apply configuration profile. (available profiles: {available_configuration_profiles})
|
|
98
|
+
|
|
99
|
+
Security options:
|
|
100
|
+
--disable-tls Whether to disable TLS.
|
|
101
|
+
--trust-certificate-path=STRING Path to the trust certificate bundle.
|
|
102
|
+
--tls-verify-mode=MODE Path to the certificate (allowed values: peer, none). [default: {tls_verify_mode}]
|
|
103
|
+
|
|
104
|
+
Timeout options:
|
|
105
|
+
--bootstrap-timeout=DURATION Timeout for overall bootstrap of the SDK. [default: {bootstrap_timeout}]
|
|
106
|
+
--connect-timeout=DURATION Timeout for socket connection. [default: {connect_timeout}]
|
|
107
|
+
--resolve-timeout=DURATION Timeout to resolve DNS address for the sockets. [default: {resolve_timeout}]
|
|
108
|
+
--key-value-timeout=DURATION Timeout for Key/Value operations. [default: {key_value_timeout}]
|
|
109
|
+
--key-value-durable-timeout=DURATION Timeout for Key/Value durable operations. [default: {key_value_durable_timeout}]
|
|
110
|
+
--query-timeout=DURATION Timeout for Query service. [default: {query_timeout}]
|
|
111
|
+
--search-timeout=DURATION Timeout for Search service. [default: {search_timeout}]
|
|
112
|
+
--eventing-timeout=DURATION Timeout for Eventing service. [default: {eventing_timeout}]
|
|
113
|
+
--analytics-timeout=DURATION Timeout for Analytics service. [default: {analytics_timeout}]
|
|
114
|
+
--view-timeout=DURATION Timeout for View service. [default: {view_timeout}]
|
|
115
|
+
--management-timeout=DURATION Timeout for management operations. [default: {management_timeout}]
|
|
116
|
+
|
|
117
|
+
Compression options:
|
|
118
|
+
--disable-compression Whether to disable compression.
|
|
119
|
+
--compression-minimum-size=INTEGER The minimum size of the document (in bytes), that will be compressed. [default: {compression_minimum_size}]
|
|
120
|
+
--compression-minimum-ratio=FLOAT The minimum compression ratio to allow compressed form to be used. [default: {compression_minimum_ratio}]
|
|
121
|
+
|
|
122
|
+
DNS-SRV options:
|
|
123
|
+
--dns-srv-timeout=DURATION Timeout for DNS SRV requests. [default: {dns_srv_timeout}]
|
|
124
|
+
--dns-srv-nameserver=STRING Hostname of the DNS server where the DNS SRV requests will be sent.
|
|
125
|
+
--dns-srv-port=INTEGER Port of the DNS server where the DNS SRV requests will be sent.
|
|
126
|
+
|
|
127
|
+
Network options:
|
|
128
|
+
--tcp-keep-alive-interval=DURATION Interval for TCP keep alive. [default: {tcp_keep_alive_interval}]
|
|
129
|
+
--config-poll-interval=DURATION How often the library should poll for new configuration. [default: {config_poll_interval}]
|
|
130
|
+
--idle-http-connection-timeout=DURATION Period to wait before calling HTTP connection idle. [default: {idle_http_connection_timeout}]
|
|
131
|
+
|
|
132
|
+
Transactions options:
|
|
133
|
+
--transactions-durability-level=LEVEL Durability level of the transaction (allowed values: none, majority, majority_and_persist_to_active, persist_to_majority). [default: {transactions_durability_level}]
|
|
134
|
+
--transactions-expiration-time=DURATION Expiration time of the transaction. [default: {transactions_expiration_time}]
|
|
135
|
+
--transactions-key-value-timeout=DURATION Override Key/Value timeout just for the transaction.
|
|
136
|
+
--transactions-metadata-bucket=STRING Bucket name where transaction metadata is stored.
|
|
137
|
+
--transactions-metadata-scope=STRING Scope name where transaction metadata is stored. [default: {transactions_metadata_scope}]
|
|
138
|
+
--transactions-metadata-collection=STRING Collection name where transaction metadata is stored. [default: {transactions_metadata_collection}]
|
|
139
|
+
--transactions-query-scan-consistency=MODE Scan consistency for queries in transactions (allowed values: not_bounded, request_plus). [default: {transactions_query_scan_consistency}]
|
|
140
|
+
--transactions-cleanup-ignore-lost-attempts Do not cleanup lost attempts.
|
|
141
|
+
--transactions-cleanup-ignore-client-attempts Do not cleanup client attempts.
|
|
142
|
+
--transactions-cleanup-window=DURATION Cleanup window. [default: {transactions_cleanup_window}]
|
|
143
|
+
|
|
144
|
+
Metrics options:
|
|
145
|
+
--disable-metrics Disable collecting and reporting metrics.
|
|
146
|
+
--metrics-emit-interval=DURATION Interval to emit metrics report on INFO log level. [default:{metrics_emit_interval}]
|
|
147
|
+
|
|
148
|
+
Tracing options:
|
|
149
|
+
--disable-tracing Disable collecting and reporting trace information.
|
|
150
|
+
--tracing-orphaned-emit-interval=DURATION Interval to emit report about orphan operations. [default: {tracing_orphaned_emit_interval}]
|
|
151
|
+
--tracing-orphaned-sample-size=INTEGER Size of the sample of the orphan report. [default: {tracing_orphaned_sample_size}]
|
|
152
|
+
--tracing-threshold-emit-interval=DURATION Interval to emit report about operations exceeding threshold. [default: {tracing_threshold_emit_interval}]
|
|
153
|
+
--tracing-threshold-sample-size=INTEGER Size of the sample of the threshold report. [default: {tracing_threshold_sample_size}]
|
|
154
|
+
--tracing-threshold-key-value=DURATION Threshold for Key/Value service. [default: {tracing_threshold_key_value}]
|
|
155
|
+
--tracing-threshold-query=DURATION Threshold for Query service. [default: {tracing_threshold_query}]
|
|
156
|
+
--tracing-threshold-search=DURATION Threshold for Search service. [default: {tracing_threshold_search}]
|
|
157
|
+
--tracing-threshold-analytics=DURATION Threshold for Analytics service. [default: {tracing_threshold_analytics}]
|
|
158
|
+
--tracing-threshold-management=DURATION Threshold for Management operations. [default: {tracing_threshold_management}]
|
|
159
|
+
--tracing-threshold-eventing=DURATION Threshold for Eventing service. [default: {tracing_threshold_eventing}]
|
|
160
|
+
--tracing-threshold-view=DURATION Threshold for View service. [default: {tracing_threshold_view}]
|
|
161
|
+
|
|
162
|
+
Behavior options:
|
|
163
|
+
--user-agent-extra=STRING Append extra string SDK identifiers (full user-agent is "{sdk_id};{user_agent_extra}"). [default: {user_agent_extra}].
|
|
164
|
+
--show-queries Log queries on INFO level.
|
|
165
|
+
--enable-clustermap-notifications Allow server to send notifications when cluster configuration changes.
|
|
166
|
+
--disable-mutation-tokens Do not request Key/Value service to send mutation tokens.
|
|
167
|
+
--disable-unordered-execution Disable unordered execution for Key/Value service.
|
|
168
|
+
)",
|
|
169
|
+
fmt::arg("connection_string", connection_string),
|
|
170
|
+
fmt::arg("username", default_options.username),
|
|
171
|
+
fmt::arg("password", default_options.password),
|
|
172
|
+
fmt::arg("available_configuration_profiles", fmt::join(couchbase::configuration_profiles_registry::available_profiles(), ", ")),
|
|
173
|
+
fmt::arg("tls_verify_mode", default_options.security.tls_verify),
|
|
174
|
+
fmt::arg("bootstrap_timeout", default_options.timeouts.bootstrap_timeout),
|
|
175
|
+
fmt::arg("connect_timeout", default_options.timeouts.connect_timeout),
|
|
176
|
+
fmt::arg("resolve_timeout", default_options.timeouts.resolve_timeout),
|
|
177
|
+
fmt::arg("key_value_timeout", default_options.timeouts.key_value_timeout),
|
|
178
|
+
fmt::arg("key_value_durable_timeout", default_options.timeouts.key_value_durable_timeout),
|
|
179
|
+
fmt::arg("query_timeout", default_options.timeouts.query_timeout),
|
|
180
|
+
fmt::arg("search_timeout", default_options.timeouts.search_timeout),
|
|
181
|
+
fmt::arg("eventing_timeout", default_options.timeouts.eventing_timeout),
|
|
182
|
+
fmt::arg("analytics_timeout", default_options.timeouts.analytics_timeout),
|
|
183
|
+
fmt::arg("view_timeout", default_options.timeouts.view_timeout),
|
|
184
|
+
fmt::arg("management_timeout", default_options.timeouts.management_timeout),
|
|
185
|
+
fmt::arg("compression_minimum_size", default_options.compression.min_size),
|
|
186
|
+
fmt::arg("compression_minimum_ratio", default_options.compression.min_ratio),
|
|
187
|
+
fmt::arg("dns_srv_timeout", default_options.dns.timeout),
|
|
188
|
+
fmt::arg("tcp_keep_alive_interval", default_options.network.tcp_keep_alive_interval),
|
|
189
|
+
fmt::arg("config_poll_interval", default_options.network.config_poll_interval),
|
|
190
|
+
fmt::arg("idle_http_connection_timeout", default_options.network.idle_http_connection_timeout),
|
|
191
|
+
fmt::arg("transactions_durability_level", default_options.transactions.level),
|
|
192
|
+
fmt::arg("transactions_expiration_time",
|
|
193
|
+
std::chrono::duration_cast<std::chrono::milliseconds>(default_options.transactions.expiration_time)),
|
|
194
|
+
fmt::arg("transactions_metadata_scope", couchbase::scope::default_name),
|
|
195
|
+
fmt::arg("transactions_metadata_collection", couchbase::scope::default_name),
|
|
196
|
+
fmt::arg("transactions_query_scan_consistency", default_options.transactions.query_config.scan_consistency),
|
|
197
|
+
fmt::arg("transactions_cleanup_window", default_options.transactions.cleanup_config.cleanup_window),
|
|
198
|
+
fmt::arg("metrics_emit_interval", default_options.metrics.emit_interval),
|
|
199
|
+
fmt::arg("tracing_orphaned_emit_interval", default_options.tracing.orphaned_emit_interval),
|
|
200
|
+
fmt::arg("tracing_orphaned_sample_size", default_options.tracing.orphaned_sample_size),
|
|
201
|
+
fmt::arg("tracing_threshold_emit_interval", default_options.tracing.threshold_emit_interval),
|
|
202
|
+
fmt::arg("tracing_threshold_sample_size", default_options.tracing.threshold_sample_size),
|
|
203
|
+
fmt::arg("tracing_threshold_key_value", default_options.tracing.key_value_threshold),
|
|
204
|
+
fmt::arg("tracing_threshold_query", default_options.tracing.query_threshold),
|
|
205
|
+
fmt::arg("tracing_threshold_view", default_options.tracing.view_threshold),
|
|
206
|
+
fmt::arg("tracing_threshold_search", default_options.tracing.search_threshold),
|
|
207
|
+
fmt::arg("tracing_threshold_analytics", default_options.tracing.analytics_threshold),
|
|
208
|
+
fmt::arg("tracing_threshold_management", default_options.tracing.management_threshold),
|
|
209
|
+
fmt::arg("tracing_threshold_eventing", default_options.tracing.eventing_threshold),
|
|
210
|
+
fmt::arg("sdk_id", couchbase::core::meta::sdk_id()),
|
|
211
|
+
fmt::arg("user_agent_extra", default_user_agent_extra));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void
|
|
215
|
+
fill_cluster_options(const docopt::Options& options, couchbase::cluster_options& cluster_options, std::string& connection_string)
|
|
216
|
+
{
|
|
217
|
+
connection_string = options.at("--connection-string").asString();
|
|
218
|
+
if (options.find("--certificate-path") != options.end() && options.at("--certificate-path") &&
|
|
219
|
+
options.find("--key-path") != options.end() && options.at("--key-path")) {
|
|
220
|
+
cluster_options = couchbase::cluster_options(
|
|
221
|
+
couchbase::certificate_authenticator(options.at("--certificate-path").asString(), options.at("--key-path").asString()));
|
|
222
|
+
} else {
|
|
223
|
+
auto username = options.at("--username").asString();
|
|
224
|
+
auto password = options.at("--password").asString();
|
|
225
|
+
if (options.find("--ldap-compatible") != options.end() && options.at("--ldap-compatible") &&
|
|
226
|
+
options.at("--ldap-compatible").asBool()) {
|
|
227
|
+
cluster_options = couchbase::cluster_options(couchbase::password_authenticator::ldap_compatible(username, password));
|
|
228
|
+
} else {
|
|
229
|
+
cluster_options = couchbase::cluster_options(couchbase::password_authenticator(username, password));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (options.find("--configuration-profile") != options.end() && options.at("--configuration-profile")) {
|
|
234
|
+
cluster_options.apply_profile(options.at("--configuration-profile").asString());
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
parse_disable_option(cluster_options.security().enabled, "--disable-tls");
|
|
238
|
+
parse_string_option(cluster_options.security().trust_certificate, "--trust-certificate-path");
|
|
239
|
+
if (options.find("--tls-verify-mode") != options.end() && options.at("--tls-verify-mode")) {
|
|
240
|
+
if (auto value = options.at("--tls-verify-mode").asString(); value == "none") {
|
|
241
|
+
cluster_options.security().tls_verify(couchbase::tls_verify_mode::none);
|
|
242
|
+
} else if (value == "peer") {
|
|
243
|
+
cluster_options.security().tls_verify(couchbase::tls_verify_mode::peer);
|
|
244
|
+
} else {
|
|
245
|
+
throw docopt::DocoptArgumentError(fmt::format("unexpected value '{}' for --tls-verify-mode", value));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
parse_duration_option(cluster_options.timeouts().bootstrap_timeout, "--bootstrap-timeout");
|
|
250
|
+
parse_duration_option(cluster_options.timeouts().connect_timeout, "--connect-timeout");
|
|
251
|
+
parse_duration_option(cluster_options.timeouts().resolve_timeout, "--resolve-timeout");
|
|
252
|
+
parse_duration_option(cluster_options.timeouts().key_value_timeout, "--key-value-timeout");
|
|
253
|
+
parse_duration_option(cluster_options.timeouts().key_value_durable_timeout, "--key-value-durable-timeout");
|
|
254
|
+
parse_duration_option(cluster_options.timeouts().query_timeout, "--query-timeout");
|
|
255
|
+
parse_duration_option(cluster_options.timeouts().search_timeout, "--search-timeout");
|
|
256
|
+
parse_duration_option(cluster_options.timeouts().eventing_timeout, "--eventing-timeout");
|
|
257
|
+
parse_duration_option(cluster_options.timeouts().analytics_timeout, "--analytics-timeout");
|
|
258
|
+
parse_duration_option(cluster_options.timeouts().view_timeout, "--view-timeout");
|
|
259
|
+
parse_duration_option(cluster_options.timeouts().management_timeout, "--management-timeout");
|
|
260
|
+
|
|
261
|
+
parse_disable_option(cluster_options.compression().enabled, "--disable-compression");
|
|
262
|
+
parse_integer_option(cluster_options.compression().min_size, "--compression-minimum-size");
|
|
263
|
+
parse_float_option(cluster_options.compression().min_ratio, "--compression-minimum-ratio");
|
|
264
|
+
|
|
265
|
+
parse_duration_option(cluster_options.dns().timeout, "--dns-srv-timeout");
|
|
266
|
+
if (options.find("--dns-srv-nameserver") != options.end() && options.at("--dns-srv-nameserver")) {
|
|
267
|
+
auto hostname = options.at("--dns-srv-nameserver").asString();
|
|
268
|
+
if (options.find("--dns-srv-port") != options.end() && options.at("--dns-srv-port")) {
|
|
269
|
+
auto value = options.at("--dns-srv-port").asString();
|
|
270
|
+
try {
|
|
271
|
+
cluster_options.dns().nameserver(hostname, static_cast<std::uint16_t>(std::stoul(value, nullptr, 10)));
|
|
272
|
+
} catch (const std::invalid_argument&) {
|
|
273
|
+
throw docopt::DocoptArgumentError(fmt::format("cannot parse '{}' as integer in --dns-srv-port: not a number", value));
|
|
274
|
+
} catch (const std::out_of_range&) {
|
|
275
|
+
throw docopt::DocoptArgumentError(fmt::format("cannot parse '{}' as integer in --dns-srv-port: out of range", value));
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
cluster_options.dns().nameserver(hostname);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
parse_duration_option(cluster_options.network().tcp_keep_alive_interval, "--tcp-keep-alive-interval");
|
|
283
|
+
parse_duration_option(cluster_options.network().config_poll_interval, "--config-poll-interval");
|
|
284
|
+
parse_duration_option(cluster_options.network().idle_http_connection_timeout, "--idle-http-connection-timeout");
|
|
285
|
+
|
|
286
|
+
if (options.find("--transactions-durability-level") != options.end() && options.at("--transactions-durability-level")) {
|
|
287
|
+
if (auto value = options.at("--transactions-durability-level").asString(); value == "none") {
|
|
288
|
+
cluster_options.transactions().durability_level(couchbase::durability_level::none);
|
|
289
|
+
} else if (value == "majority") {
|
|
290
|
+
cluster_options.transactions().durability_level(couchbase::durability_level::majority);
|
|
291
|
+
} else if (value == "majority_and_persist_to_active") {
|
|
292
|
+
cluster_options.transactions().durability_level(couchbase::durability_level::majority_and_persist_to_active);
|
|
293
|
+
} else if (value == "persist_to_majority") {
|
|
294
|
+
cluster_options.transactions().durability_level(couchbase::durability_level::persist_to_majority);
|
|
295
|
+
} else {
|
|
296
|
+
throw docopt::DocoptArgumentError(fmt::format("unexpected value '{}' for --transactions-durability-level", value));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
parse_duration_option(cluster_options.transactions().expiration_time, "--transactions-expiration-time");
|
|
300
|
+
parse_duration_option(cluster_options.transactions().kv_timeout, "--transactions-key-value-timeout");
|
|
301
|
+
if (options.find("--transactions-metadata-bucket") != options.end() && options.at("--transactions-metadata-bucket")) {
|
|
302
|
+
if (auto bucket = options.at("--transactions-metadata-bucket").asString(); !bucket.empty()) {
|
|
303
|
+
cluster_options.transactions().metadata_collection({ bucket,
|
|
304
|
+
options.at("--transactions-metadata-scope").asString(),
|
|
305
|
+
options.at("--transactions-metadata-collection").asString() });
|
|
306
|
+
} else {
|
|
307
|
+
throw docopt::DocoptArgumentError("empty value for --transactions-metadata-bucket");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (options.find("--transactions-query-scan-consistency") != options.end() && options.at("--transactions-query-scan-consistency")) {
|
|
311
|
+
if (auto value = options.at("--transactions-query-scan-consistency").asString(); value == "not_bounded") {
|
|
312
|
+
cluster_options.transactions().query_config().scan_consistency(couchbase::query_scan_consistency::not_bounded);
|
|
313
|
+
} else if (value == "request_plus") {
|
|
314
|
+
cluster_options.transactions().query_config().scan_consistency(couchbase::query_scan_consistency::request_plus);
|
|
315
|
+
} else {
|
|
316
|
+
throw docopt::DocoptArgumentError(fmt::format("unexpected value '{}' for --transactions-query-scan-consistency", value));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
parse_disable_option(cluster_options.transactions().cleanup_config().cleanup_lost_attempts,
|
|
320
|
+
"--transactions-cleanup-ignore-lost-attempts");
|
|
321
|
+
parse_disable_option(cluster_options.transactions().cleanup_config().cleanup_client_attempts,
|
|
322
|
+
"--transactions-cleanup-ignore-client-attempts");
|
|
323
|
+
parse_duration_option(cluster_options.transactions().cleanup_config().cleanup_window, "--transactions-cleanup-window");
|
|
324
|
+
|
|
325
|
+
parse_disable_option(cluster_options.metrics().enable, "--disable-metrics");
|
|
326
|
+
parse_duration_option(cluster_options.metrics().emit_interval, "--metrics-emit-interval");
|
|
327
|
+
|
|
328
|
+
parse_disable_option(cluster_options.tracing().enable, "--disable-tracing");
|
|
329
|
+
parse_duration_option(cluster_options.tracing().orphaned_emit_interval, "--tracing-orphaned-emit-interval");
|
|
330
|
+
parse_integer_option(cluster_options.tracing().orphaned_sample_size, "--tracing-orphaned-sample-size");
|
|
331
|
+
parse_duration_option(cluster_options.tracing().threshold_emit_interval, "--tracing-threshold-emit-interval");
|
|
332
|
+
parse_integer_option(cluster_options.tracing().threshold_sample_size, "--tracing-threshold-sample-size");
|
|
333
|
+
parse_duration_option(cluster_options.tracing().key_value_threshold, "--tracing-threshold-key-value");
|
|
334
|
+
parse_duration_option(cluster_options.tracing().query_threshold, "--tracing-threshold-query");
|
|
335
|
+
parse_duration_option(cluster_options.tracing().search_threshold, "--tracing-threshold-search");
|
|
336
|
+
parse_duration_option(cluster_options.tracing().analytics_threshold, "--tracing-threshold-analytics");
|
|
337
|
+
parse_duration_option(cluster_options.tracing().management_threshold, "--tracing-threshold-management");
|
|
338
|
+
parse_duration_option(cluster_options.tracing().eventing_threshold, "--tracing-threshold-eventing");
|
|
339
|
+
parse_duration_option(cluster_options.tracing().view_threshold, "--tracing-threshold-view");
|
|
340
|
+
|
|
341
|
+
parse_string_option(cluster_options.behavior().append_to_user_agent, "--user-agent-extra");
|
|
342
|
+
parse_enable_option(cluster_options.behavior().show_queries, "--show-queries");
|
|
343
|
+
parse_enable_option(cluster_options.behavior().enable_clustermap_notification, "--enable-clustermap-notification");
|
|
344
|
+
parse_disable_option(cluster_options.behavior().enable_mutation_tokens, "--disable-mutation-tokens");
|
|
345
|
+
parse_disable_option(cluster_options.behavior().enable_unordered_execution, "--disable-disable-unordered-execution");
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
auto
|
|
349
|
+
default_log_level() -> const std::string&
|
|
350
|
+
{
|
|
351
|
+
static const std::string default_log_level_ = getenv_or_default("CBC_LOG_LEVEL", "off");
|
|
352
|
+
|
|
353
|
+
return default_log_level_;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
auto
|
|
357
|
+
usage_block_for_logger() -> std::string
|
|
358
|
+
{
|
|
359
|
+
static const std::vector<std::string> allowed_log_levels{
|
|
360
|
+
"trace", "debug", "info", "warning", "error", "critical", "off",
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
return fmt::format(R"(
|
|
364
|
+
Logger options:
|
|
365
|
+
--log-level=LEVEL Log level (allowed values are: {allowed_levels}). CBC_LOG_LEVEL. [default: {log_level}]
|
|
366
|
+
--log-output=PATH File to send logs (when is not set, logs will be written to STDERR).
|
|
367
|
+
)",
|
|
368
|
+
fmt::arg("allowed_levels", fmt::join(allowed_log_levels, ", ")),
|
|
369
|
+
fmt::arg("log_level", default_log_level()));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
void
|
|
373
|
+
apply_logger_options(const docopt::Options& options)
|
|
374
|
+
{
|
|
375
|
+
auto log_level = options.at("--log-level").asString();
|
|
376
|
+
auto level = couchbase::core::logger::level_from_str(log_level);
|
|
377
|
+
|
|
378
|
+
if (level != couchbase::core::logger::level::off) {
|
|
379
|
+
couchbase::core::logger::configuration configuration{};
|
|
380
|
+
|
|
381
|
+
if (options.find("--log-output") != options.end() && options.at("--log-output")) {
|
|
382
|
+
configuration.filename = options.at("--log-output").asString();
|
|
383
|
+
} else {
|
|
384
|
+
configuration.console = true;
|
|
385
|
+
configuration.unit_test = true;
|
|
386
|
+
}
|
|
387
|
+
configuration.log_level = level;
|
|
388
|
+
couchbase::core::logger::create_file_logger(configuration);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
spdlog::set_level(spdlog::level::from_str(log_level));
|
|
392
|
+
couchbase::core::logger::set_log_levels(level);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
auto
|
|
396
|
+
extract_inlined_keyspace(const std::string& id) -> std::optional<keyspace_with_id>
|
|
397
|
+
{
|
|
398
|
+
static const std::regex inlined_keyspace_regex{ R"(^(.*?):(.*?)\.(.*?):(.*)$)" };
|
|
399
|
+
|
|
400
|
+
std::smatch match;
|
|
401
|
+
if (std::regex_match(id, match, inlined_keyspace_regex)) {
|
|
402
|
+
keyspace_with_id ks_id{};
|
|
403
|
+
ks_id.bucket_name = match[1];
|
|
404
|
+
ks_id.scope_name = match[2];
|
|
405
|
+
ks_id.collection_name = match[3];
|
|
406
|
+
ks_id.id = match[4];
|
|
407
|
+
return ks_id;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return {};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
bool
|
|
414
|
+
get_bool_option(const docopt::Options& options, const std::string& name)
|
|
415
|
+
{
|
|
416
|
+
return options.find(name) != options.end() && options.at(name) && options.at(name).asBool();
|
|
417
|
+
}
|
|
418
|
+
} // namespace cbc
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023-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 <core/utils/duration_parser.hxx>
|
|
21
|
+
#include <couchbase/cluster_options.hxx>
|
|
22
|
+
#include <couchbase/codec/transcoder_traits.hxx>
|
|
23
|
+
|
|
24
|
+
#include <docopt.h>
|
|
25
|
+
#include <fmt/chrono.h>
|
|
26
|
+
|
|
27
|
+
#include <string>
|
|
28
|
+
#include <vector>
|
|
29
|
+
|
|
30
|
+
namespace cbc
|
|
31
|
+
{
|
|
32
|
+
auto
|
|
33
|
+
parse_options(const std::string& doc, const std::vector<std::string>& argv, bool options_first = false) -> docopt::Options;
|
|
34
|
+
|
|
35
|
+
void
|
|
36
|
+
fill_cluster_options(const docopt::Options& options, couchbase::cluster_options& cluster_options, std::string& connection_string);
|
|
37
|
+
|
|
38
|
+
auto
|
|
39
|
+
default_cluster_options() -> const couchbase::cluster_options&;
|
|
40
|
+
|
|
41
|
+
auto
|
|
42
|
+
default_connection_string() -> const std::string&;
|
|
43
|
+
|
|
44
|
+
auto
|
|
45
|
+
usage_block_for_cluster_options() -> std::string;
|
|
46
|
+
|
|
47
|
+
auto
|
|
48
|
+
default_log_level() -> const std::string&;
|
|
49
|
+
|
|
50
|
+
auto
|
|
51
|
+
usage_block_for_logger() -> std::string;
|
|
52
|
+
|
|
53
|
+
void
|
|
54
|
+
apply_logger_options(const docopt::Options& options);
|
|
55
|
+
|
|
56
|
+
struct keyspace_with_id {
|
|
57
|
+
std::string bucket_name;
|
|
58
|
+
std::string scope_name;
|
|
59
|
+
std::string collection_name;
|
|
60
|
+
std::string id;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
auto
|
|
64
|
+
extract_inlined_keyspace(const std::string& id) -> std::optional<keyspace_with_id>;
|
|
65
|
+
|
|
66
|
+
struct passthrough_transcoder {
|
|
67
|
+
using document_type = std::pair<std::vector<std::byte>, std::uint32_t>;
|
|
68
|
+
|
|
69
|
+
static auto decode(const couchbase::codec::encoded_value& encoded) -> document_type
|
|
70
|
+
{
|
|
71
|
+
return { encoded.data, encoded.flags };
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
[[nodiscard]] bool
|
|
76
|
+
get_bool_option(const docopt::Options& options, const std::string& name);
|
|
77
|
+
} // namespace cbc
|
|
78
|
+
|
|
79
|
+
template<>
|
|
80
|
+
struct couchbase::codec::is_transcoder<cbc::passthrough_transcoder> : public std::true_type {
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
#define parse_duration_option(setter, option_name) \
|
|
84
|
+
do { \
|
|
85
|
+
if (options.find(option_name) != options.end() && options.at(option_name)) { \
|
|
86
|
+
auto value = options.at(option_name).asString(); \
|
|
87
|
+
try { \
|
|
88
|
+
setter(std::chrono::duration_cast<std::chrono::milliseconds>(couchbase::core::utils::parse_duration(value))); \
|
|
89
|
+
} catch (const couchbase::core::utils::duration_parse_error&) { \
|
|
90
|
+
try { \
|
|
91
|
+
setter(std::chrono::milliseconds(std::stoull(value, nullptr, 10))); \
|
|
92
|
+
} catch (const std::invalid_argument&) { \
|
|
93
|
+
throw docopt::DocoptArgumentError( \
|
|
94
|
+
fmt::format("cannot parse '{}' as duration in " option_name ": not a number", value)); \
|
|
95
|
+
} catch (const std::out_of_range&) { \
|
|
96
|
+
throw docopt::DocoptArgumentError( \
|
|
97
|
+
fmt::format("cannot parse '{}' as duration in " option_name ": out of range", value)); \
|
|
98
|
+
} \
|
|
99
|
+
} \
|
|
100
|
+
} \
|
|
101
|
+
} while (0)
|
|
102
|
+
|
|
103
|
+
#define parse_string_option(setter, option_name) \
|
|
104
|
+
do { \
|
|
105
|
+
if (options.find(option_name) != options.end() && options.at(option_name)) { \
|
|
106
|
+
setter(options.at(option_name).asString()); \
|
|
107
|
+
} \
|
|
108
|
+
} while (0)
|
|
109
|
+
|
|
110
|
+
#define parse_disable_option(setter, option_name) \
|
|
111
|
+
do { \
|
|
112
|
+
if (options.find(option_name) != options.end() && options.at(option_name)) { \
|
|
113
|
+
setter(!options.at(option_name).asBool()); \
|
|
114
|
+
} \
|
|
115
|
+
} while (0)
|
|
116
|
+
|
|
117
|
+
#define parse_enable_option(setter, option_name) \
|
|
118
|
+
do { \
|
|
119
|
+
if (options.find(option_name) != options.end() && options.at(option_name)) { \
|
|
120
|
+
setter(options.at(option_name).asBool()); \
|
|
121
|
+
} \
|
|
122
|
+
} while (0)
|
|
123
|
+
|
|
124
|
+
#define parse_integer_option(setter, option_name) \
|
|
125
|
+
do { \
|
|
126
|
+
if (options.find(option_name) != options.end() && options.at(option_name)) { \
|
|
127
|
+
auto value = options.at(option_name).asString(); \
|
|
128
|
+
try { \
|
|
129
|
+
setter(std::stoull(value, nullptr, 10)); \
|
|
130
|
+
} catch (const std::invalid_argument&) { \
|
|
131
|
+
throw docopt::DocoptArgumentError(fmt::format("cannot parse '{}' as integer in " option_name ": not a number", value)); \
|
|
132
|
+
} catch (const std::out_of_range&) { \
|
|
133
|
+
throw docopt::DocoptArgumentError(fmt::format("cannot parse '{}' as integer in " option_name ": out of range", value)); \
|
|
134
|
+
} \
|
|
135
|
+
} \
|
|
136
|
+
} while (0)
|
|
137
|
+
|
|
138
|
+
#define parse_float_option(setter, option_name) \
|
|
139
|
+
do { \
|
|
140
|
+
if (options.find(option_name) != options.end() && options.at(option_name)) { \
|
|
141
|
+
auto value = options.at(option_name).asString(); \
|
|
142
|
+
try { \
|
|
143
|
+
setter(std::stod(value, nullptr)); \
|
|
144
|
+
} catch (const std::invalid_argument&) { \
|
|
145
|
+
throw docopt::DocoptArgumentError(fmt::format("cannot parse '{}' as float in " option_name ": not a number", value)); \
|
|
146
|
+
} catch (const std::out_of_range&) { \
|
|
147
|
+
throw docopt::DocoptArgumentError(fmt::format("cannot parse '{}' as float in " option_name ": out of range", value)); \
|
|
148
|
+
} \
|
|
149
|
+
} \
|
|
150
|
+
} while (0)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023-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
|
+
#include "version.hxx"
|
|
19
|
+
|
|
20
|
+
#include "utils.hxx"
|
|
21
|
+
|
|
22
|
+
#include <core/meta/version.hxx>
|
|
23
|
+
|
|
24
|
+
#include <tao/json.hpp>
|
|
25
|
+
|
|
26
|
+
namespace cbc
|
|
27
|
+
{
|
|
28
|
+
static constexpr auto* USAGE =
|
|
29
|
+
R"(Display version information.
|
|
30
|
+
|
|
31
|
+
Usage:
|
|
32
|
+
cbc version [options]
|
|
33
|
+
cbc version (-h|--help)
|
|
34
|
+
|
|
35
|
+
Options:
|
|
36
|
+
-h --help Show this screen.
|
|
37
|
+
--json Dump version and build info in JSON format.
|
|
38
|
+
)";
|
|
39
|
+
|
|
40
|
+
void
|
|
41
|
+
cbc::version::execute(const std::vector<std::string>& argv)
|
|
42
|
+
{
|
|
43
|
+
try {
|
|
44
|
+
auto options = cbc::parse_options(USAGE, argv);
|
|
45
|
+
if (options["--help"].asBool()) {
|
|
46
|
+
fmt::print(stdout, USAGE);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (options["--json"].asBool()) {
|
|
50
|
+
tao::json::value info;
|
|
51
|
+
for (const auto& [name, value] : couchbase::core::meta::sdk_build_info()) {
|
|
52
|
+
if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build") {
|
|
53
|
+
info[name] = std::stoi(value);
|
|
54
|
+
} else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl") {
|
|
55
|
+
info[name] = value == "true";
|
|
56
|
+
} else {
|
|
57
|
+
info[name] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
fmt::print(stdout, "{}\n", tao::json::to_string(info, 2));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
fmt::print(stdout, "Version: {}\n", couchbase::core::meta::sdk_semver());
|
|
64
|
+
auto info = couchbase::core::meta::sdk_build_info();
|
|
65
|
+
fmt::print(stdout, "Build date: {}\n", info["build_timestamp"]);
|
|
66
|
+
fmt::print(stdout, "Build type: {}\n", info["cmake_build_type"]);
|
|
67
|
+
fmt::print(stdout, "Platform: {}, {}\n", info["platform"], info["cpu"]);
|
|
68
|
+
fmt::print(stdout, "C compiler: {}\n", info["cc"]);
|
|
69
|
+
fmt::print(stdout, "C++ compiler: {}\n", info["cxx"]);
|
|
70
|
+
fmt::print(stdout, "CMake: {}\n", info["cmake_version"]);
|
|
71
|
+
fmt::print(stdout, "ASIO: {}\n", info["asio"]);
|
|
72
|
+
fmt::print(stdout, "Snappy: {}\n", info["snappy"]);
|
|
73
|
+
fmt::print(stdout, "OpenSSL:\n");
|
|
74
|
+
fmt::print(stdout, " headers: {}\n", info["openssl_headers"]);
|
|
75
|
+
fmt::print(stdout, " runtime: {}\n", info["openssl_runtime"]);
|
|
76
|
+
fmt::print(stdout, " default certificate directory: {}\n", info["openssl_default_cert_dir"]);
|
|
77
|
+
fmt::print(stdout, " default certificate file: {}\n", info["openssl_default_cert_file"]);
|
|
78
|
+
} catch (const docopt::DocoptArgumentError& e) {
|
|
79
|
+
fmt::print(stderr, "Error: {}\n", e.what());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} // namespace cbc
|