Couchbase C++ SDK 1.1.0 (rev. effbd6e)
Loading...
Searching...
No Matches
cluster_options.hxx
Go to the documentation of this file.
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
26#include <couchbase/error.hxx>
35
36#include <functional>
37#include <stdexcept>
38#include <string>
39#include <system_error>
40#include <vector>
41
42namespace couchbase
43{
45{
46public:
55 cluster_options(std::string username, std::string password)
56 : username_{ std::move(username) }
57 , password_{ std::move(password) }
58 {
59 }
60
69 : username_{ std::move(authenticator.username_) }
70 , password_{ std::move(authenticator.password_) }
71 {
72 if (authenticator.ldap_compatible_) {
73 sasl_mechanisms_ = { { "PLAIN" } };
74 }
75 }
76
85 : certificate_path_{ std::move(authenticator.certificate_path_) }
86 , key_path_{ std::move(authenticator.key_path_) }
87 {
88 }
89
103 void apply_profile(const std::string& profile_name)
104 {
106 }
107
116 [[nodiscard]] auto compression() -> compression_options&
117 {
118 return compression_;
119 }
120
129 [[nodiscard]] auto timeouts() -> timeout_options&
130 {
131 return timeouts_;
132 }
133
142 [[nodiscard]] auto dns() -> dns_options&
143 {
144 return dns_;
145 }
146
155 [[nodiscard]] auto security() -> security_options&
156 {
157 return security_;
158 }
159
168 [[nodiscard]] auto network() -> network_options&
169 {
170 return network_;
171 }
172
181 [[nodiscard]] auto metrics() -> metrics_options&
182 {
183 return metrics_;
184 }
185
194 [[nodiscard]] auto tracing() -> tracing_options&
195 {
196 return tracing_;
197 }
198
207 [[nodiscard]] auto behavior() -> behavior_options&
208 {
209 return behavior_;
210 }
211
221 {
222 return transactions_;
223 }
224
234 {
235 return application_telemetry_;
236 }
237
246 auto default_retry_strategy(std::shared_ptr<retry_strategy> strategy) -> cluster_options&
247 {
248 if (strategy == nullptr) {
249 throw std::invalid_argument("retry strategy cannot be null");
250 }
251 default_retry_strategy_ = std::move(strategy);
252 return *this;
253 }
254
273
274 [[nodiscard]] auto build() const -> built
275 {
276 return {
277 username_,
278 password_,
279 certificate_path_,
280 key_path_,
281 sasl_mechanisms_,
282 compression_.build(),
283 timeouts_.build(),
284 dns_.build(),
285 security_.build(),
286 network_.build(),
287 metrics_.build(),
288 tracing_.build(),
289 behavior_.build(),
290 transactions_.build(),
291 default_retry_strategy_,
292 application_telemetry_.build(),
293 };
294 }
295
296private:
297 std::string username_{};
298 std::string password_{};
299 std::string certificate_path_{};
300 std::string key_path_{};
301 std::optional<std::vector<std::string>> sasl_mechanisms_{};
302
303 compression_options compression_{};
304 timeout_options timeouts_{};
305 dns_options dns_{};
306 security_options security_{};
307 network_options network_{};
308 metrics_options metrics_{};
309 tracing_options tracing_{};
310 behavior_options behavior_{};
311 transactions::transactions_config transactions_{};
312 std::shared_ptr<retry_strategy> default_retry_strategy_{ nullptr };
313 application_telemetry_options application_telemetry_{};
314};
315
316#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
317class cluster;
318#endif
319
326using cluster_connect_handler = std::function<void(error, cluster)>;
327} // namespace couchbase
Definition application_telemetry_options.hxx:27
Definition behavior_options.hxx:25
Definition certificate_authenticator.hxx:25
auto behavior() -> behavior_options &
Returns misc options that affects cluster behavior.
Definition cluster_options.hxx:207
cluster_options(password_authenticator authenticator)
Definition cluster_options.hxx:68
cluster_options(certificate_authenticator authenticator)
Definition cluster_options.hxx:84
cluster_options(std::string username, std::string password)
Definition cluster_options.hxx:55
auto application_telemetry() -> application_telemetry_options &
Returns the Application Telemetry options.
Definition cluster_options.hxx:233
auto tracing() -> tracing_options &
Returns tracing options.
Definition cluster_options.hxx:194
auto build() const -> built
Definition cluster_options.hxx:274
auto default_retry_strategy(std::shared_ptr< retry_strategy > strategy) -> cluster_options &
Override default retry strategy.
Definition cluster_options.hxx:246
auto security() -> security_options &
Returns security options (including TLS)
Definition cluster_options.hxx:155
void apply_profile(const std::string &profile_name)
Apply settings profile by name.
Definition cluster_options.hxx:103
auto network() -> network_options &
Returns network options.
Definition cluster_options.hxx:168
auto dns() -> dns_options &
Returns options for DNS-SRV bootstrap.
Definition cluster_options.hxx:142
auto compression() -> compression_options &
Returns compression options.
Definition cluster_options.hxx:116
auto timeouts() -> timeout_options &
Returns various timeout options.
Definition cluster_options.hxx:129
auto transactions() -> transactions::transactions_config &
Returns the transactions options which effect the transactions behavior.
Definition cluster_options.hxx:220
auto metrics() -> metrics_options &
Returns metrics and observability options.
Definition cluster_options.hxx:181
The cluster is the main entry point when connecting to a Couchbase cluster.
Definition cluster.hxx:60
Definition compression_options.hxx:25
static void apply_profile(const std::string &name, couchbase::cluster_options &options)
Apply a profile to an instance of cluster_options.
Definition dns_options.hxx:28
Definition error.hxx:30
Definition metrics_options.hxx:29
Definition network_options.hxx:30
Definition password_authenticator.hxx:25
Definition security_options.hxx:28
Definition timeout_options.hxx:26
Definition tracing_options.hxx:29
Configuration parameters for transactions.
Definition transactions_config.hxx:43
Represents a single item from the result of scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, cluster)> cluster_connect_handler
The signature for the handler of the connect()
Definition cluster_options.hxx:326
Definition application_telemetry_options.hxx:102
Definition behavior_options.hxx:70
Definition cluster_options.hxx:255
std::string password
Definition cluster_options.hxx:257
metrics_options::built metrics
Definition cluster_options.hxx:266
network_options::built network
Definition cluster_options.hxx:265
compression_options::built compression
Definition cluster_options.hxx:261
std::shared_ptr< retry_strategy > default_retry_strategy
Definition cluster_options.hxx:270
security_options::built security
Definition cluster_options.hxx:264
std::string username
Definition cluster_options.hxx:256
timeout_options::built timeouts
Definition cluster_options.hxx:262
transactions::transactions_config::built transactions
Definition cluster_options.hxx:269
std::optional< std::vector< std::string > > allowed_sasl_mechanisms
Definition cluster_options.hxx:260
std::string certificate_path
Definition cluster_options.hxx:258
std::string key_path
Definition cluster_options.hxx:259
tracing_options::built tracing
Definition cluster_options.hxx:267
behavior_options::built behavior
Definition cluster_options.hxx:268
dns_options::built dns
Definition cluster_options.hxx:263
application_telemetry_options::built application_telemetry
Definition cluster_options.hxx:271
Definition compression_options.hxx:45
Definition dns_options.hxx:45
Definition metrics_options.hxx:51
Definition network_options.hxx:117
Definition security_options.hxx:54
Definition timeout_options.hxx:111
Definition tracing_options.hxx:127