couchbase 3.0.0.alpha.5-universal-darwin-19 → 3.0.0.beta.1-universal-darwin-19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -3
- data/README.md +4 -2
- data/Rakefile +1 -1
- data/couchbase.gemspec +17 -12
- data/ext/.idea/misc.xml +12 -0
- data/ext/CMakeLists.txt +10 -1
- data/ext/build_config.hxx.in +20 -0
- data/ext/build_version.hxx.in +1 -1
- data/ext/couchbase/bucket.hxx +90 -24
- data/ext/couchbase/cluster.hxx +125 -84
- data/ext/couchbase/cluster_options.hxx +53 -0
- data/ext/couchbase/configuration.hxx +220 -2
- data/ext/couchbase/couchbase.cxx +134 -127
- data/ext/couchbase/io/dns_client.hxx +3 -1
- data/ext/couchbase/io/http_command.hxx +91 -0
- data/ext/couchbase/io/http_session.hxx +58 -19
- data/ext/couchbase/io/http_session_manager.hxx +26 -31
- data/ext/couchbase/io/mcbp_command.hxx +180 -0
- data/ext/couchbase/io/mcbp_message.hxx +5 -0
- data/ext/couchbase/io/mcbp_session.hxx +213 -98
- data/ext/couchbase/io/streams.hxx +165 -0
- data/ext/couchbase/operations.hxx +1 -1
- data/ext/couchbase/operations/analytics_dataset_create.hxx +1 -1
- data/ext/couchbase/operations/bucket_create.hxx +4 -2
- data/ext/couchbase/operations/bucket_drop.hxx +4 -2
- data/ext/couchbase/operations/bucket_flush.hxx +4 -2
- data/ext/couchbase/operations/bucket_get.hxx +4 -2
- data/ext/couchbase/operations/bucket_get_all.hxx +4 -2
- data/ext/couchbase/operations/bucket_update.hxx +4 -2
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +4 -2
- data/ext/couchbase/operations/collection_create.hxx +4 -2
- data/ext/couchbase/operations/collection_drop.hxx +4 -2
- data/ext/couchbase/operations/document_analytics.hxx +0 -4
- data/ext/couchbase/operations/document_decrement.hxx +6 -3
- data/ext/couchbase/operations/document_get.hxx +3 -0
- data/ext/couchbase/operations/document_get_and_lock.hxx +3 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +5 -2
- data/ext/couchbase/operations/document_get_projected.hxx +12 -9
- data/ext/couchbase/operations/document_increment.hxx +6 -3
- data/ext/couchbase/operations/document_insert.hxx +5 -2
- data/ext/couchbase/operations/document_lookup_in.hxx +3 -0
- data/ext/couchbase/operations/document_mutate_in.hxx +6 -3
- data/ext/couchbase/operations/document_remove.hxx +3 -0
- data/ext/couchbase/operations/document_replace.hxx +5 -2
- data/ext/couchbase/operations/document_search.hxx +6 -7
- data/ext/couchbase/operations/document_touch.hxx +5 -2
- data/ext/couchbase/operations/document_unlock.hxx +3 -0
- data/ext/couchbase/operations/document_upsert.hxx +5 -2
- data/ext/couchbase/operations/query_index_build_deferred.hxx +3 -3
- data/ext/couchbase/operations/query_index_create.hxx +3 -3
- data/ext/couchbase/operations/query_index_drop.hxx +3 -3
- data/ext/couchbase/operations/query_index_get_all.hxx +3 -3
- data/ext/couchbase/operations/scope_create.hxx +4 -2
- data/ext/couchbase/operations/scope_drop.hxx +4 -2
- data/ext/couchbase/operations/scope_get_all.hxx +4 -2
- data/ext/couchbase/operations/search_index_analyze_document.hxx +2 -2
- data/ext/couchbase/operations/search_index_control_ingest.hxx +2 -2
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +2 -2
- data/ext/couchbase/operations/search_index_control_query.hxx +2 -2
- data/ext/couchbase/operations/search_index_drop.hxx +2 -2
- data/ext/couchbase/operations/search_index_get.hxx +2 -2
- data/ext/couchbase/operations/search_index_get_all.hxx +2 -2
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +2 -2
- data/ext/couchbase/operations/search_index_upsert.hxx +2 -2
- data/ext/couchbase/origin.hxx +148 -0
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +1 -6
- data/ext/couchbase/protocol/cmd_decrement.hxx +5 -5
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +5 -5
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +1 -6
- data/ext/couchbase/protocol/cmd_increment.hxx +5 -5
- data/ext/couchbase/protocol/cmd_info.hxx +0 -11
- data/ext/couchbase/protocol/cmd_insert.hxx +5 -5
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +6 -6
- data/ext/couchbase/protocol/cmd_replace.hxx +5 -5
- data/ext/couchbase/protocol/cmd_touch.hxx +1 -1
- data/ext/couchbase/protocol/cmd_upsert.hxx +5 -5
- data/ext/couchbase/timeout_defaults.hxx +7 -0
- data/ext/couchbase/utils/connection_string.hxx +139 -0
- data/ext/extconf.rb +44 -11
- data/ext/test/main.cxx +93 -15
- data/ext/third_party/http_parser/Makefile +160 -0
- data/ext/third_party/json/Makefile +77 -0
- data/lib/couchbase/analytics_options.rb +18 -4
- data/lib/couchbase/binary_collection.rb +2 -2
- data/lib/couchbase/binary_collection_options.rb +2 -2
- data/lib/couchbase/bucket.rb +4 -4
- data/lib/couchbase/cluster.rb +60 -46
- data/lib/couchbase/collection.rb +13 -13
- data/lib/couchbase/collection_options.rb +15 -9
- data/{bin/console → lib/couchbase/datastructures.rb} +4 -7
- data/lib/couchbase/datastructures/couchbase_list.rb +171 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +205 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +145 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +138 -0
- data/lib/couchbase/errors.rb +66 -63
- data/lib/couchbase/libcouchbase.bundle +0 -0
- data/lib/couchbase/management/user_manager.rb +1 -1
- data/lib/couchbase/mutation_state.rb +1 -0
- data/lib/couchbase/query_options.rb +25 -2
- data/lib/couchbase/scope.rb +0 -7
- data/lib/couchbase/search_options.rb +7 -0
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase/view_options.rb +4 -3
- metadata +20 -82
- data/.github/workflows/tests-6.0.3.yml +0 -52
- data/.github/workflows/tests-dev-preview.yml +0 -55
- data/.github/workflows/tests.yml +0 -50
- data/.gitignore +0 -20
- data/.gitmodules +0 -21
- data/.idea/.gitignore +0 -5
- data/.idea/dictionaries/gem_terms.xml +0 -18
- data/.idea/inspectionProfiles/Project_Default.xml +0 -8
- data/.idea/vcs.xml +0 -13
- data/bin/check-cluster +0 -31
- data/bin/fetch-stats +0 -19
- data/bin/init-cluster +0 -82
- data/bin/jenkins/build-extension +0 -35
- data/bin/jenkins/install-dependencies +0 -47
- data/bin/jenkins/test-with-cbdyncluster +0 -58
- data/bin/setup +0 -24
- data/ext/couchbase/configuration_monitor.hxx +0 -93
- data/ext/couchbase/operations/command.hxx +0 -163
- data/rbi/couchbase.rbi +0 -79
@@ -79,7 +79,7 @@ class get_and_touch_request_body
|
|
79
79
|
|
80
80
|
private:
|
81
81
|
std::string key_;
|
82
|
-
std::uint32_t
|
82
|
+
std::uint32_t expiry_;
|
83
83
|
std::vector<std::uint8_t> extras_{};
|
84
84
|
|
85
85
|
public:
|
@@ -92,9 +92,9 @@ class get_and_touch_request_body
|
|
92
92
|
}
|
93
93
|
}
|
94
94
|
|
95
|
-
void
|
95
|
+
void expiry(std::uint32_t seconds)
|
96
96
|
{
|
97
|
-
|
97
|
+
expiry_ = seconds;
|
98
98
|
}
|
99
99
|
|
100
100
|
const std::string& key()
|
@@ -133,8 +133,8 @@ class get_and_touch_request_body
|
|
133
133
|
private:
|
134
134
|
void fill_extras()
|
135
135
|
{
|
136
|
-
extras_.resize(sizeof(
|
137
|
-
uint32_t field = htonl(
|
136
|
+
extras_.resize(sizeof(expiry_));
|
137
|
+
uint32_t field = htonl(expiry_);
|
138
138
|
memcpy(extras_.data(), &field, sizeof(field));
|
139
139
|
}
|
140
140
|
};
|
@@ -67,17 +67,12 @@ class get_cluster_config_response_body
|
|
67
67
|
std::uint16_t key_size,
|
68
68
|
std::uint8_t extras_size,
|
69
69
|
const std::vector<uint8_t>& body,
|
70
|
-
const cmd_info&
|
70
|
+
const cmd_info&)
|
71
71
|
{
|
72
72
|
Expects(header[1] == static_cast<uint8_t>(opcode));
|
73
73
|
if (status == protocol::status::success) {
|
74
74
|
std::vector<uint8_t>::difference_type offset = framing_extras_size + key_size + extras_size;
|
75
75
|
config_ = tao::json::from_string<deduplicate_keys>(std::string(body.begin() + offset, body.end())).as<configuration>();
|
76
|
-
for (auto& node : config_.nodes) {
|
77
|
-
if (node.this_node && node.hostname.empty()) {
|
78
|
-
node.hostname = info.remote_endpoint.address().to_string();
|
79
|
-
}
|
80
|
-
}
|
81
76
|
return true;
|
82
77
|
}
|
83
78
|
return false;
|
@@ -85,7 +85,7 @@ class increment_request_body
|
|
85
85
|
std::vector<std::uint8_t> framing_extras_{};
|
86
86
|
std::uint64_t delta_{ 1 };
|
87
87
|
std::uint64_t initial_value_{ 0 };
|
88
|
-
std::uint32_t
|
88
|
+
std::uint32_t expiry_{ 0 };
|
89
89
|
std::vector<std::uint8_t> extras_{};
|
90
90
|
|
91
91
|
public:
|
@@ -108,9 +108,9 @@ class increment_request_body
|
|
108
108
|
initial_value_ = value;
|
109
109
|
}
|
110
110
|
|
111
|
-
void
|
111
|
+
void expiry(std::uint32_t value)
|
112
112
|
{
|
113
|
-
|
113
|
+
expiry_ = value;
|
114
114
|
}
|
115
115
|
|
116
116
|
void durability(protocol::durability_level level, std::optional<std::uint16_t> timeout)
|
@@ -167,7 +167,7 @@ class increment_request_body
|
|
167
167
|
private:
|
168
168
|
void fill_extras()
|
169
169
|
{
|
170
|
-
extras_.resize(sizeof(delta_) + sizeof(initial_value_) + sizeof(
|
170
|
+
extras_.resize(sizeof(delta_) + sizeof(initial_value_) + sizeof(expiry_));
|
171
171
|
using offset_type = std::vector<uint8_t>::difference_type;
|
172
172
|
offset_type offset = 0;
|
173
173
|
|
@@ -179,7 +179,7 @@ class increment_request_body
|
|
179
179
|
memcpy(extras_.data() + offset, &num, sizeof(num));
|
180
180
|
offset += static_cast<offset_type>(sizeof(delta_));
|
181
181
|
|
182
|
-
std::uint32_t ttl = htonl(
|
182
|
+
std::uint32_t ttl = htonl(expiry_);
|
183
183
|
memcpy(extras_.data() + offset, &ttl, sizeof(ttl));
|
184
184
|
}
|
185
185
|
};
|
@@ -20,17 +20,6 @@
|
|
20
20
|
namespace couchbase::protocol
|
21
21
|
{
|
22
22
|
struct cmd_info {
|
23
|
-
asio::ip::tcp::endpoint local_endpoint{};
|
24
|
-
asio::ip::tcp::endpoint remote_endpoint{};
|
25
23
|
double server_duration_us{ 0 };
|
26
|
-
|
27
|
-
template<class AsyncStream>
|
28
|
-
void extract_from_stream(AsyncStream& stream)
|
29
|
-
{
|
30
|
-
std::error_code err;
|
31
|
-
local_endpoint = stream.local_endpoint(err);
|
32
|
-
remote_endpoint = stream.remote_endpoint(err);
|
33
|
-
(void)err;
|
34
|
-
}
|
35
24
|
};
|
36
25
|
} // namespace couchbase::protocol
|
@@ -78,7 +78,7 @@ class insert_request_body
|
|
78
78
|
std::vector<std::uint8_t> extras_{};
|
79
79
|
std::vector<std::uint8_t> content_{};
|
80
80
|
std::uint32_t flags_{};
|
81
|
-
std::uint32_t
|
81
|
+
std::uint32_t expiry_{};
|
82
82
|
std::vector<std::uint8_t> framing_extras_{};
|
83
83
|
|
84
84
|
public:
|
@@ -120,9 +120,9 @@ class insert_request_body
|
|
120
120
|
flags_ = flags;
|
121
121
|
}
|
122
122
|
|
123
|
-
void
|
123
|
+
void expiry(uint32_t value)
|
124
124
|
{
|
125
|
-
|
125
|
+
expiry_ = value;
|
126
126
|
}
|
127
127
|
|
128
128
|
const std::string& key()
|
@@ -159,12 +159,12 @@ class insert_request_body
|
|
159
159
|
private:
|
160
160
|
void fill_extention()
|
161
161
|
{
|
162
|
-
extras_.resize(sizeof(flags_) + sizeof(
|
162
|
+
extras_.resize(sizeof(flags_) + sizeof(expiry_));
|
163
163
|
|
164
164
|
uint32_t field = htonl(flags_);
|
165
165
|
memcpy(extras_.data(), &field, sizeof(field));
|
166
166
|
|
167
|
-
field = htonl(
|
167
|
+
field = htonl(expiry_);
|
168
168
|
memcpy(extras_.data() + sizeof(flags_), &field, sizeof(field));
|
169
169
|
}
|
170
170
|
};
|
@@ -208,7 +208,7 @@ class mutate_in_request_body
|
|
208
208
|
std::vector<std::uint8_t> extras_{};
|
209
209
|
std::vector<std::uint8_t> value_{};
|
210
210
|
|
211
|
-
std::uint32_t
|
211
|
+
std::uint32_t expiry_{ 0 };
|
212
212
|
std::uint8_t flags_{ 0 };
|
213
213
|
mutate_in_specs specs_;
|
214
214
|
std::vector<std::uint8_t> framing_extras_{};
|
@@ -223,9 +223,9 @@ class mutate_in_request_body
|
|
223
223
|
}
|
224
224
|
}
|
225
225
|
|
226
|
-
void
|
226
|
+
void expiry(uint32_t value)
|
227
227
|
{
|
228
|
-
|
228
|
+
expiry_ = value;
|
229
229
|
}
|
230
230
|
|
231
231
|
void access_deleted(bool value)
|
@@ -317,9 +317,9 @@ class mutate_in_request_body
|
|
317
317
|
private:
|
318
318
|
void fill_extention()
|
319
319
|
{
|
320
|
-
if (
|
321
|
-
extras_.resize(sizeof(
|
322
|
-
std::uint32_t field = htonl(
|
320
|
+
if (expiry_ != 0) {
|
321
|
+
extras_.resize(sizeof(expiry_));
|
322
|
+
std::uint32_t field = htonl(expiry_);
|
323
323
|
memcpy(extras_.data(), &field, sizeof(field));
|
324
324
|
}
|
325
325
|
if (flags_ != 0) {
|
@@ -78,7 +78,7 @@ class replace_request_body
|
|
78
78
|
std::vector<std::uint8_t> extras_{};
|
79
79
|
std::vector<std::uint8_t> content_{};
|
80
80
|
std::uint32_t flags_{};
|
81
|
-
std::uint32_t
|
81
|
+
std::uint32_t expiry_{};
|
82
82
|
std::vector<std::uint8_t> framing_extras_{};
|
83
83
|
|
84
84
|
public:
|
@@ -120,9 +120,9 @@ class replace_request_body
|
|
120
120
|
flags_ = flags;
|
121
121
|
}
|
122
122
|
|
123
|
-
void
|
123
|
+
void expiry(uint32_t value)
|
124
124
|
{
|
125
|
-
|
125
|
+
expiry_ = value;
|
126
126
|
}
|
127
127
|
|
128
128
|
const std::string& key()
|
@@ -159,12 +159,12 @@ class replace_request_body
|
|
159
159
|
private:
|
160
160
|
void fill_extention()
|
161
161
|
{
|
162
|
-
extras_.resize(sizeof(flags_) + sizeof(
|
162
|
+
extras_.resize(sizeof(flags_) + sizeof(expiry_));
|
163
163
|
|
164
164
|
uint32_t field = htonl(flags_);
|
165
165
|
memcpy(extras_.data(), &field, sizeof(field));
|
166
166
|
|
167
|
-
field = htonl(
|
167
|
+
field = htonl(expiry_);
|
168
168
|
memcpy(extras_.data() + sizeof(flags_), &field, sizeof(field));
|
169
169
|
}
|
170
170
|
};
|
@@ -78,7 +78,7 @@ class upsert_request_body
|
|
78
78
|
std::vector<std::uint8_t> extras_{};
|
79
79
|
std::vector<std::uint8_t> content_{};
|
80
80
|
std::uint32_t flags_{};
|
81
|
-
std::uint32_t
|
81
|
+
std::uint32_t expiry_{};
|
82
82
|
std::vector<std::uint8_t> framing_extras_{};
|
83
83
|
|
84
84
|
public:
|
@@ -120,9 +120,9 @@ class upsert_request_body
|
|
120
120
|
flags_ = flags;
|
121
121
|
}
|
122
122
|
|
123
|
-
void
|
123
|
+
void expiry(uint32_t value)
|
124
124
|
{
|
125
|
-
|
125
|
+
expiry_ = value;
|
126
126
|
}
|
127
127
|
|
128
128
|
const std::string& key()
|
@@ -159,12 +159,12 @@ class upsert_request_body
|
|
159
159
|
private:
|
160
160
|
void fill_extention()
|
161
161
|
{
|
162
|
-
extras_.resize(sizeof(flags_) + sizeof(
|
162
|
+
extras_.resize(sizeof(flags_) + sizeof(expiry_));
|
163
163
|
|
164
164
|
uint32_t field = htonl(flags_);
|
165
165
|
memcpy(extras_.data(), &field, sizeof(field));
|
166
166
|
|
167
|
-
field = htonl(
|
167
|
+
field = htonl(expiry_);
|
168
168
|
memcpy(extras_.data() + sizeof(flags_), &field, sizeof(field));
|
169
169
|
}
|
170
170
|
};
|
@@ -21,6 +21,8 @@
|
|
21
21
|
|
22
22
|
namespace couchbase::timeout_defaults
|
23
23
|
{
|
24
|
+
constexpr std::chrono::milliseconds bootstrap_timeout{ 10'000 };
|
25
|
+
|
24
26
|
constexpr std::chrono::milliseconds connect_timeout{ 10'000 };
|
25
27
|
constexpr std::chrono::milliseconds key_value_timeout{ 2'500 };
|
26
28
|
constexpr std::chrono::milliseconds key_value_durable_timeout{ 10'000 };
|
@@ -31,4 +33,9 @@ constexpr std::chrono::milliseconds search_timeout{ 75'000 };
|
|
31
33
|
constexpr std::chrono::milliseconds management_timeout{ 75'000 };
|
32
34
|
|
33
35
|
constexpr std::chrono::milliseconds dns_srv_timeout{ 500 };
|
36
|
+
constexpr std::chrono::milliseconds tcp_keep_alive_interval{ 60'000 };
|
37
|
+
constexpr std::chrono::milliseconds config_poll_interval{ 2'500 };
|
38
|
+
constexpr std::chrono::milliseconds config_poll_floor{ 50'000 };
|
39
|
+
constexpr std::chrono::milliseconds config_idle_redial_timeout{ 5 * 60'000 };
|
40
|
+
constexpr std::chrono::milliseconds idle_http_connection_timeout{ 4'500 };
|
34
41
|
} // namespace couchbase::timeout_defaults
|
@@ -22,6 +22,8 @@
|
|
22
22
|
#include <tao/json/external/pegtl.hpp>
|
23
23
|
#include <tao/json/external/pegtl/contrib/uri.hpp>
|
24
24
|
|
25
|
+
#include <cluster_options.hxx>
|
26
|
+
|
25
27
|
namespace couchbase::utils
|
26
28
|
{
|
27
29
|
|
@@ -48,6 +50,8 @@ struct connection_string {
|
|
48
50
|
std::string scheme{};
|
49
51
|
bool tls{ false };
|
50
52
|
std::map<std::string, std::string> params{};
|
53
|
+
cluster_options options{};
|
54
|
+
|
51
55
|
std::vector<node> bootstrap_nodes{};
|
52
56
|
|
53
57
|
std::optional<std::string> default_bucket_name{};
|
@@ -200,6 +204,140 @@ struct action<bucket_name> {
|
|
200
204
|
};
|
201
205
|
} // namespace priv
|
202
206
|
|
207
|
+
static void
|
208
|
+
extract_options(connection_string& connstr)
|
209
|
+
{
|
210
|
+
connstr.options.enable_tls = connstr.tls;
|
211
|
+
if (connstr.bootstrap_nodes.size() != 1 || connstr.bootstrap_nodes[0].type != connection_string::address_type::dns) {
|
212
|
+
connstr.options.enable_dns_srv = false;
|
213
|
+
}
|
214
|
+
for (const auto& param : connstr.params) {
|
215
|
+
try {
|
216
|
+
if (param.first == "kv_connect_timeout") {
|
217
|
+
/**
|
218
|
+
* Number of seconds the client should wait while attempting to connect to a node’s KV service via a socket. Initial
|
219
|
+
* connection, reconnecting, node added, etc.
|
220
|
+
*/
|
221
|
+
connstr.options.connect_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
222
|
+
} else if (param.first == "kv_timeout") {
|
223
|
+
/**
|
224
|
+
* Number of milliseconds to wait before timing out a KV operation by the client.
|
225
|
+
*/
|
226
|
+
connstr.options.key_value_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
227
|
+
} else if (param.first == "kv_durable_timeout") {
|
228
|
+
/**
|
229
|
+
* Number of milliseconds to wait before timing out a KV operation that is either using synchronous durability or
|
230
|
+
* observe-based durability.
|
231
|
+
*/
|
232
|
+
connstr.options.key_value_durable_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
233
|
+
} else if (param.first == "view_timeout") {
|
234
|
+
/**
|
235
|
+
* Number of seconds to wait before timing out a View request by the client..
|
236
|
+
*/
|
237
|
+
connstr.options.view_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
238
|
+
} else if (param.first == "query_timeout") {
|
239
|
+
/**
|
240
|
+
* Number of seconds to wait before timing out a Query or N1QL request by the client.
|
241
|
+
*/
|
242
|
+
connstr.options.query_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
243
|
+
} else if (param.first == "analytics_timeout") {
|
244
|
+
/**
|
245
|
+
* Number of seconds to wait before timing out an Analytics request by the client.
|
246
|
+
*/
|
247
|
+
connstr.options.analytics_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
248
|
+
} else if (param.first == "search_timeout") {
|
249
|
+
/**
|
250
|
+
* Number of seconds to wait before timing out a Search request by the client.
|
251
|
+
*/
|
252
|
+
connstr.options.search_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
253
|
+
} else if (param.first == "management_timeout") {
|
254
|
+
/**
|
255
|
+
* Number of seconds to wait before timing out a Management API request by the client.
|
256
|
+
*/
|
257
|
+
connstr.options.management_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
258
|
+
} else if (param.first == "trust_certificate") {
|
259
|
+
connstr.options.trust_certificate = param.second;
|
260
|
+
} else if (param.first == "enable_mutation_tokens") {
|
261
|
+
/**
|
262
|
+
* Request mutation tokens at connection negotiation time. Turning this off will save 16 bytes per operation response.
|
263
|
+
*/
|
264
|
+
if (param.second == "true" || param.second == "yes" || param.second == "on") {
|
265
|
+
connstr.options.enable_mutation_tokens = true;
|
266
|
+
} else if (param.second == "false" || param.second == "no" || param.second == "off") {
|
267
|
+
connstr.options.enable_mutation_tokens = false;
|
268
|
+
}
|
269
|
+
} else if (param.first == "enable_tcp_keep_alive") {
|
270
|
+
/**
|
271
|
+
* Gets or sets a value indicating whether enable TCP keep-alive.
|
272
|
+
*/
|
273
|
+
if (param.second == "true" || param.second == "yes" || param.second == "on") {
|
274
|
+
connstr.options.enable_tcp_keep_alive = true;
|
275
|
+
} else if (param.second == "false" || param.second == "no" || param.second == "off") {
|
276
|
+
connstr.options.enable_tcp_keep_alive = false;
|
277
|
+
}
|
278
|
+
} else if (param.first == "tcp_keep_alive_interval") {
|
279
|
+
/**
|
280
|
+
* Specifies the timeout, in milliseconds, with no activity until the first keep-alive packet is sent. This applies to all
|
281
|
+
* services, but is advisory: if the underlying platform does not support this on all connections, it will be applied only
|
282
|
+
* on those it can be.
|
283
|
+
*/
|
284
|
+
connstr.options.tcp_keep_alive_interval = std::chrono::milliseconds(std::stoull(param.second));
|
285
|
+
} else if (param.first == "force_ipv4") {
|
286
|
+
/**
|
287
|
+
* Sets the SDK configuration to do IPv4 Name Resolution
|
288
|
+
*/
|
289
|
+
if (param.second == "true" || param.second == "yes" || param.second == "on") {
|
290
|
+
connstr.options.force_ipv4 = true;
|
291
|
+
} else if (param.second == "false" || param.second == "no" || param.second == "off") {
|
292
|
+
connstr.options.force_ipv4 = false;
|
293
|
+
}
|
294
|
+
} else if (param.first == "config_poll_interval") {
|
295
|
+
connstr.options.config_poll_interval = std::chrono::milliseconds(std::stoull(param.second));
|
296
|
+
} else if (param.first == "config_poll_floor") {
|
297
|
+
connstr.options.config_poll_floor = std::chrono::milliseconds(std::stoull(param.second));
|
298
|
+
} else if (param.first == "max_http_connections") {
|
299
|
+
/**
|
300
|
+
* The maximum number of HTTP connections allowed on a per-host and per-port basis. 0 indicates an unlimited number of
|
301
|
+
* connections are permitted.
|
302
|
+
*/
|
303
|
+
connstr.options.max_http_connections = std::stoul(param.second);
|
304
|
+
} else if (param.first == "idle_http_connection_timeout") {
|
305
|
+
/**
|
306
|
+
* The period of time an HTTP connection can be idle before it is forcefully disconnected.
|
307
|
+
*/
|
308
|
+
connstr.options.idle_http_connection_timeout = std::chrono::milliseconds(std::stoull(param.second));
|
309
|
+
} else if (param.first == "enable_dns_srv") {
|
310
|
+
if (connstr.bootstrap_nodes.size() == 1) {
|
311
|
+
if (param.second == "true" || param.second == "yes" || param.second == "on") {
|
312
|
+
connstr.options.enable_dns_srv = true;
|
313
|
+
} else if (param.second == "false" || param.second == "no" || param.second == "off") {
|
314
|
+
connstr.options.enable_dns_srv = false;
|
315
|
+
}
|
316
|
+
} else {
|
317
|
+
spdlog::warn(
|
318
|
+
R"(parameter "{}" require single entry in bootstrap nodes list of the connection string, ignoring (value "{}"))",
|
319
|
+
param.first,
|
320
|
+
param.second);
|
321
|
+
}
|
322
|
+
} else if (param.first == "network") {
|
323
|
+
connstr.options.network = param.second; /* current known values are "auto", "default" and "external" */
|
324
|
+
} else {
|
325
|
+
spdlog::warn(R"(unknown parameter "{}" in connection string (value "{}"))", param.first, param.second);
|
326
|
+
}
|
327
|
+
} catch (std::invalid_argument& ex1) {
|
328
|
+
spdlog::warn(R"(unable to parse "{}" parameter in connection string (value "{}" cannot be converted): {})",
|
329
|
+
param.first,
|
330
|
+
param.second,
|
331
|
+
ex1.what());
|
332
|
+
} catch (std::out_of_range& ex2) {
|
333
|
+
spdlog::warn(R"(unable to parse "{}" parameter in connection string (value "{}" is out of range): {})",
|
334
|
+
param.first,
|
335
|
+
param.second,
|
336
|
+
ex2.what());
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
203
341
|
static connection_string
|
204
342
|
parse_connection_string(const std::string& input)
|
205
343
|
{
|
@@ -226,6 +364,7 @@ parse_connection_string(const std::string& input)
|
|
226
364
|
res.error = e.what();
|
227
365
|
}
|
228
366
|
}
|
367
|
+
extract_options(res);
|
229
368
|
return res;
|
230
369
|
}
|
231
370
|
} // namespace couchbase::utils
|
data/ext/extconf.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "mkmf"
|
2
|
-
require "fileutils"
|
3
2
|
require "tempfile"
|
4
3
|
|
4
|
+
require_relative "../lib/couchbase/version"
|
5
|
+
SDK_VERSION = Couchbase::VERSION[:sdk]
|
6
|
+
|
5
7
|
unless find_executable("cmake")
|
6
8
|
abort "ERROR: CMake is required to build couchbase extension."
|
7
9
|
end
|
@@ -14,28 +16,40 @@ end
|
|
14
16
|
|
15
17
|
|
16
18
|
build_type = ENV["DEBUG"] ? "Debug" : "RelWithDebInfo"
|
17
|
-
cmake_flags = [
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
cmake_flags = %W[
|
20
|
+
-DCMAKE_BUILD_TYPE=#{build_type}
|
21
|
+
-DRUBY_HDR_DIR=#{RbConfig::CONFIG["rubyhdrdir"]}
|
22
|
+
-DRUBY_ARCH_HDR_DIR=#{RbConfig::CONFIG["rubyarchhdrdir"]}
|
23
|
+
-DTAOCPP_JSON_BUILD_TESTS=OFF
|
24
|
+
-DTAOCPP_JSON_BUILD_EXAMPLES=OFF
|
25
|
+
-DSNAPPY_BUILD_TESTS=OFF
|
26
|
+
-DSNAPPY_INSTALL=OFF
|
25
27
|
]
|
28
|
+
|
29
|
+
if ENV["CB_CC"]
|
30
|
+
cmake_flags << "-DCMAKE_C_COMPILER=#{ENV["CB_CC"]}"
|
31
|
+
end
|
32
|
+
if ENV["CB_CXX"]
|
33
|
+
cmake_flags << "-DCMAKE_CXX_COMPILER=#{ENV["CB_CXX"]}"
|
34
|
+
end
|
35
|
+
if ENV["CB_STATIC"]
|
36
|
+
cmake_flags << "-DSTATIC_STDLIB=ON"
|
37
|
+
end
|
38
|
+
|
26
39
|
openssl_root = `brew --prefix openssl 2> /dev/null`.strip
|
27
40
|
unless openssl_root.empty?
|
28
41
|
cmake_flags << "-DOPENSSL_ROOT_DIR=#{openssl_root}"
|
29
42
|
end
|
30
43
|
|
31
44
|
project_path = File.expand_path(File.join(__dir__))
|
32
|
-
build_dir = ENV['
|
45
|
+
build_dir = ENV['CB_EXT_BUILD_DIR'] || File.join(Dir.tmpdir, "cb-#{build_type}-#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}-#{SDK_VERSION}")
|
33
46
|
FileUtils.mkdir_p(build_dir)
|
34
47
|
Dir.chdir(build_dir) do
|
48
|
+
puts "-- build #{build_type} extension #{SDK_VERSION} for ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}"
|
35
49
|
sys("cmake", *cmake_flags, project_path)
|
36
50
|
sys("make -j4 VERBOSE=1")
|
37
51
|
end
|
38
|
-
extension_name = "libcouchbase.#{RbConfig::CONFIG["SOEXT"]}"
|
52
|
+
extension_name = "libcouchbase.#{RbConfig::CONFIG["SOEXT"] || RbConfig::CONFIG["DLEXT"]}"
|
39
53
|
extension_path = File.expand_path(File.join(build_dir, extension_name))
|
40
54
|
unless File.file?(extension_path)
|
41
55
|
abort "ERROR: failed to build extension in #{extension_path}"
|
@@ -44,4 +58,23 @@ extension_name.gsub!(/\.dylib/, '.bundle')
|
|
44
58
|
install_path = File.expand_path(File.join(__dir__, "..", "lib", "couchbase", extension_name))
|
45
59
|
puts "-- copy extension to #{install_path}"
|
46
60
|
FileUtils.cp(extension_path, install_path)
|
61
|
+
ext_directory = File.expand_path(__dir__)
|
47
62
|
create_makefile("libcouchbase")
|
63
|
+
if ENV["CB_REMOVE_EXT_DIRECTORY"]
|
64
|
+
puts "-- CB_REMOVE_EXT_DIRECTORY is set, remove #{ext_directory}"
|
65
|
+
Dir
|
66
|
+
.glob("#{ext_directory}/*", File::FNM_DOTMATCH)
|
67
|
+
.reject { |path| %w[. .. extconf.rb].include?(File.basename(path)) || File.basename(path).start_with?(".gem") }
|
68
|
+
.each do |entry|
|
69
|
+
puts "-- remove #{entry}"
|
70
|
+
FileUtils.rm_rf(entry)
|
71
|
+
end
|
72
|
+
File.truncate("#{ext_directory}/extconf.rb", 0)
|
73
|
+
puts "-- truncate #{ext_directory}/extconf.rb"
|
74
|
+
File.write("#{ext_directory}/Makefile", <<EOF)
|
75
|
+
.PHONY: all clean install
|
76
|
+
all:
|
77
|
+
clean:
|
78
|
+
install:
|
79
|
+
EOF
|
80
|
+
end
|