Couchbase C++ SDK 1.0.1 (rev. 58d46d7)
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
25#include <couchbase/error.hxx>
34
35#include <functional>
36#include <stdexcept>
37#include <string>
38#include <system_error>
39#include <vector>
40
41namespace couchbase
42{
44{
45public:
54 cluster_options(std::string username, std::string password)
55 : username_{ std::move(username) }
56 , password_{ std::move(password) }
57 {
58 }
59
68 : username_{ std::move(authenticator.username_) }
69 , password_{ std::move(authenticator.password_) }
70 {
71 if (authenticator.ldap_compatible_) {
72 sasl_mechanisms_ = { { "PLAIN" } };
73 }
74 }
75
84 : certificate_path_{ std::move(authenticator.certificate_path_) }
85 , key_path_{ std::move(authenticator.key_path_) }
86 {
87 }
88
102 void apply_profile(const std::string& profile_name)
103 {
105 }
106
115 [[nodiscard]] auto compression() -> compression_options&
116 {
117 return compression_;
118 }
119
128 [[nodiscard]] auto timeouts() -> timeout_options&
129 {
130 return timeouts_;
131 }
132
141 [[nodiscard]] auto dns() -> dns_options&
142 {
143 return dns_;
144 }
145
154 [[nodiscard]] auto security() -> security_options&
155 {
156 return security_;
157 }
158
167 [[nodiscard]] auto network() -> network_options&
168 {
169 return network_;
170 }
171
180 [[nodiscard]] auto metrics() -> metrics_options&
181 {
182 return metrics_;
183 }
184
193 [[nodiscard]] auto tracing() -> tracing_options&
194 {
195 return tracing_;
196 }
197
206 [[nodiscard]] auto behavior() -> behavior_options&
207 {
208 return behavior_;
209 }
210
220 {
221 return transactions_;
222 }
223
232 auto default_retry_strategy(std::shared_ptr<retry_strategy> strategy) -> cluster_options&
233 {
234 if (strategy == nullptr) {
235 throw std::invalid_argument("retry strategy cannot be null");
236 }
237 default_retry_strategy_ = std::move(strategy);
238 return *this;
239 }
240
258
259 [[nodiscard]] auto build() const -> built
260 {
261 return {
262 username_,
263 password_,
264 certificate_path_,
265 key_path_,
266 sasl_mechanisms_,
267 compression_.build(),
268 timeouts_.build(),
269 dns_.build(),
270 security_.build(),
271 network_.build(),
272 metrics_.build(),
273 tracing_.build(),
274 behavior_.build(),
275 transactions_.build(),
276 default_retry_strategy_,
277 };
278 }
279
280private:
281 std::string username_{};
282 std::string password_{};
283 std::string certificate_path_{};
284 std::string key_path_{};
285 std::optional<std::vector<std::string>> sasl_mechanisms_{};
286
287 compression_options compression_{};
288 timeout_options timeouts_{};
289 dns_options dns_{};
290 security_options security_{};
291 network_options network_{};
292 metrics_options metrics_{};
293 tracing_options tracing_{};
294 behavior_options behavior_{};
295 transactions::transactions_config transactions_{};
296 std::shared_ptr<retry_strategy> default_retry_strategy_{ nullptr };
297};
298
299#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
300class cluster;
301#endif
302
309using cluster_connect_handler = std::function<void(error, cluster)>;
310} // namespace couchbase
Definition behavior_options.hxx:25
auto build() const -> built
Definition behavior_options.hxx:89
Definition certificate_authenticator.hxx:25
Definition cluster_options.hxx:44
auto behavior() -> behavior_options &
Returns misc options that affects cluster behavior.
Definition cluster_options.hxx:206
cluster_options(password_authenticator authenticator)
Definition cluster_options.hxx:67
cluster_options(certificate_authenticator authenticator)
Definition cluster_options.hxx:83
cluster_options(std::string username, std::string password)
Definition cluster_options.hxx:54
auto tracing() -> tracing_options &
Returns tracing options.
Definition cluster_options.hxx:193
auto build() const -> built
Definition cluster_options.hxx:259
auto default_retry_strategy(std::shared_ptr< retry_strategy > strategy) -> cluster_options &
Override default retry strategy.
Definition cluster_options.hxx:232
auto security() -> security_options &
Returns security options (including TLS)
Definition cluster_options.hxx:154
void apply_profile(const std::string &profile_name)
Apply settings profile by name.
Definition cluster_options.hxx:102
auto network() -> network_options &
Returns network options.
Definition cluster_options.hxx:167
auto dns() -> dns_options &
Returns options for DNS-SRV bootstrap.
Definition cluster_options.hxx:141
auto compression() -> compression_options &
Returns compression options.
Definition cluster_options.hxx:115
auto timeouts() -> timeout_options &
Returns various timeout options.
Definition cluster_options.hxx:128
auto transactions() -> transactions::transactions_config &
Returns the transactions options which effect the transactions behavior.
Definition cluster_options.hxx:219
auto metrics() -> metrics_options &
Returns metrics and observability options.
Definition cluster_options.hxx:180
The cluster is the main entry point when connecting to a Couchbase cluster.
Definition cluster.hxx:60
Definition compression_options.hxx:25
auto build() const -> built
Definition compression_options.hxx:51
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
auto build() const -> built
Definition dns_options.hxx:51
Definition error.hxx:30
Definition metrics_options.hxx:29
auto build() const -> built
Definition metrics_options.hxx:57
Definition network_options.hxx:30
auto build() const -> built
Definition network_options.hxx:118
Definition password_authenticator.hxx:25
Definition security_options.hxx:28
auto build() const -> built
Definition security_options.hxx:64
Definition timeout_options.hxx:26
auto build() const -> built
Definition timeout_options.hxx:125
Definition tracing_options.hxx:29
auto build() const -> built
Definition tracing_options.hxx:143
Configuration parameters for transactions.
Definition transactions_config.hxx:43
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, cluster)> cluster_connect_handler
The signature for the handler of the cluster::connect()
Definition cluster_options.hxx:309
Definition behavior_options.hxx:79
Definition cluster_options.hxx:241
std::string password
Definition cluster_options.hxx:243
metrics_options::built metrics
Definition cluster_options.hxx:252
network_options::built network
Definition cluster_options.hxx:251
compression_options::built compression
Definition cluster_options.hxx:247
std::shared_ptr< retry_strategy > default_retry_strategy
Definition cluster_options.hxx:256
security_options::built security
Definition cluster_options.hxx:250
std::string username
Definition cluster_options.hxx:242
timeout_options::built timeouts
Definition cluster_options.hxx:248
transactions::transactions_config::built transactions
Definition cluster_options.hxx:255
std::optional< std::vector< std::string > > allowed_sasl_mechanisms
Definition cluster_options.hxx:246
std::string certificate_path
Definition cluster_options.hxx:244
std::string key_path
Definition cluster_options.hxx:245
tracing_options::built tracing
Definition cluster_options.hxx:253
behavior_options::built behavior
Definition cluster_options.hxx:254
dns_options::built dns
Definition cluster_options.hxx:249
Definition compression_options.hxx:45
Definition dns_options.hxx:45
Definition metrics_options.hxx:51
Definition network_options.hxx:107
Definition security_options.hxx:54
Definition timeout_options.hxx:111
Definition tracing_options.hxx:127