couchbase 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +73 -4
- data/ext/build_config.hxx.in +2 -0
- data/ext/build_version.hxx.in +11 -8
- data/ext/cmake/BuildTracing.cmake +1 -1
- data/ext/cmake/CompilerWarnings.cmake +5 -0
- data/ext/cmake/Testing.cmake +3 -6
- data/ext/couchbase/bucket.hxx +9 -1
- data/ext/couchbase/cbsasl/client.h +1 -1
- data/ext/couchbase/cluster.hxx +89 -6
- data/ext/couchbase/configuration.hxx +2 -0
- data/ext/couchbase/couchbase.cxx +1647 -507
- data/ext/couchbase/diagnostics.hxx +0 -3
- data/ext/couchbase/io/dns_client.hxx +2 -2
- data/ext/couchbase/io/http_command.hxx +6 -3
- data/ext/couchbase/io/http_session.hxx +14 -18
- data/ext/couchbase/io/http_session_manager.hxx +83 -2
- data/ext/couchbase/io/mcbp_command.hxx +4 -1
- data/ext/couchbase/io/mcbp_context.hxx +37 -0
- data/ext/couchbase/io/mcbp_session.hxx +91 -30
- data/ext/couchbase/operations.hxx +5 -0
- data/ext/couchbase/operations/analytics_dataset_create.hxx +3 -2
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +3 -2
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +3 -2
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +3 -2
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +3 -2
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +3 -2
- data/ext/couchbase/operations/analytics_index_create.hxx +3 -2
- data/ext/couchbase/operations/analytics_index_drop.hxx +3 -2
- data/ext/couchbase/operations/analytics_index_get_all.hxx +5 -2
- data/ext/couchbase/operations/analytics_link_connect.hxx +3 -2
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +3 -2
- data/ext/couchbase/operations/bucket_create.hxx +3 -2
- data/ext/couchbase/operations/bucket_drop.hxx +3 -2
- data/ext/couchbase/operations/bucket_flush.hxx +3 -2
- data/ext/couchbase/operations/bucket_get.hxx +3 -2
- data/ext/couchbase/operations/bucket_get_all.hxx +3 -2
- data/ext/couchbase/operations/bucket_update.hxx +3 -2
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +3 -2
- data/ext/couchbase/operations/collection_create.hxx +3 -2
- data/ext/couchbase/operations/collection_drop.hxx +3 -2
- data/ext/couchbase/operations/collections_manifest_get.hxx +3 -2
- data/ext/couchbase/operations/document_analytics.hxx +3 -2
- data/ext/couchbase/operations/document_append.hxx +77 -0
- data/ext/couchbase/operations/document_decrement.hxx +3 -2
- data/ext/couchbase/operations/document_exists.hxx +3 -2
- data/ext/couchbase/operations/document_get.hxx +3 -2
- data/ext/couchbase/operations/document_get_and_lock.hxx +3 -2
- data/ext/couchbase/operations/document_get_and_touch.hxx +3 -2
- data/ext/couchbase/operations/document_get_projected.hxx +3 -2
- data/ext/couchbase/operations/document_increment.hxx +3 -2
- data/ext/couchbase/operations/document_insert.hxx +3 -2
- data/ext/couchbase/operations/document_lookup_in.hxx +8 -2
- data/ext/couchbase/operations/document_mutate_in.hxx +13 -2
- data/ext/couchbase/operations/document_prepend.hxx +77 -0
- data/ext/couchbase/operations/document_query.hxx +3 -2
- data/ext/couchbase/operations/document_remove.hxx +5 -2
- data/ext/couchbase/operations/document_replace.hxx +3 -2
- data/ext/couchbase/operations/document_search.hxx +3 -2
- data/ext/couchbase/operations/document_touch.hxx +3 -2
- data/ext/couchbase/operations/document_unlock.hxx +3 -2
- data/ext/couchbase/operations/document_upsert.hxx +3 -2
- data/ext/couchbase/operations/document_view.hxx +3 -2
- data/ext/couchbase/operations/group_drop.hxx +3 -2
- data/ext/couchbase/operations/group_get.hxx +3 -2
- data/ext/couchbase/operations/group_get_all.hxx +3 -2
- data/ext/couchbase/operations/group_upsert.hxx +3 -2
- data/ext/couchbase/operations/http_noop.hxx +78 -0
- data/ext/couchbase/operations/mcbp_noop.hxx +61 -0
- data/ext/couchbase/operations/query_index_build_deferred.hxx +3 -2
- data/ext/couchbase/operations/query_index_create.hxx +3 -2
- data/ext/couchbase/operations/query_index_drop.hxx +3 -2
- data/ext/couchbase/operations/query_index_get_all.hxx +3 -2
- data/ext/couchbase/operations/role_get_all.hxx +3 -2
- data/ext/couchbase/operations/scope_create.hxx +3 -2
- data/ext/couchbase/operations/scope_drop.hxx +3 -2
- data/ext/couchbase/operations/scope_get_all.hxx +3 -2
- data/ext/couchbase/operations/search_get_stats.hxx +3 -2
- data/ext/couchbase/operations/search_index_analyze_document.hxx +3 -2
- data/ext/couchbase/operations/search_index_control_ingest.hxx +3 -2
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +3 -2
- data/ext/couchbase/operations/search_index_control_query.hxx +3 -2
- data/ext/couchbase/operations/search_index_drop.hxx +3 -2
- data/ext/couchbase/operations/search_index_get.hxx +3 -2
- data/ext/couchbase/operations/search_index_get_all.hxx +3 -2
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +3 -2
- data/ext/couchbase/operations/search_index_get_stats.hxx +3 -2
- data/ext/couchbase/operations/search_index_upsert.hxx +3 -2
- data/ext/couchbase/operations/user_drop.hxx +3 -2
- data/ext/couchbase/operations/user_get.hxx +3 -2
- data/ext/couchbase/operations/user_get_all.hxx +3 -2
- data/ext/couchbase/operations/user_upsert.hxx +3 -2
- data/ext/couchbase/operations/view_index_drop.hxx +3 -2
- data/ext/couchbase/operations/view_index_get.hxx +3 -2
- data/ext/couchbase/operations/view_index_get_all.hxx +3 -2
- data/ext/couchbase/operations/view_index_upsert.hxx +3 -2
- data/ext/couchbase/platform/terminate_handler.cc +5 -2
- data/ext/couchbase/protocol/client_opcode.hxx +368 -0
- data/ext/couchbase/protocol/cmd_append.hxx +145 -0
- data/ext/couchbase/protocol/cmd_hello.hxx +1 -0
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +11 -3
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +46 -4
- data/ext/couchbase/protocol/cmd_noop.hxx +82 -0
- data/ext/couchbase/protocol/cmd_prepend.hxx +145 -0
- data/ext/couchbase/protocol/durability_level.hxx +16 -0
- data/ext/couchbase/protocol/hello_feature.hxx +9 -0
- data/ext/couchbase/protocol/unsigned_leb128.h +2 -2
- data/ext/couchbase/service_type.hxx +1 -1
- data/ext/couchbase/version.hxx +18 -4
- data/ext/extconf.rb +9 -6
- data/ext/test/CMakeLists.txt +5 -0
- data/ext/test/test_helper.hxx +3 -3
- data/ext/test/test_helper_native.hxx +2 -5
- data/ext/test/test_native_binary_operations.cxx +186 -0
- data/ext/test/test_native_diagnostics.cxx +54 -3
- data/ext/test/test_ruby_trivial_crud.cxx +1 -1
- data/lib/couchbase.rb +1 -0
- data/lib/couchbase/analytics_options.rb +1 -71
- data/lib/couchbase/binary_collection.rb +60 -22
- data/lib/couchbase/binary_collection_options.rb +0 -76
- data/lib/couchbase/bucket.rb +40 -36
- data/lib/couchbase/cluster.rb +89 -156
- data/lib/couchbase/collection.rb +290 -72
- data/lib/couchbase/collection_options.rb +30 -243
- data/lib/couchbase/datastructures/couchbase_list.rb +5 -16
- data/lib/couchbase/datastructures/couchbase_map.rb +5 -16
- data/lib/couchbase/datastructures/couchbase_queue.rb +5 -16
- data/lib/couchbase/datastructures/couchbase_set.rb +5 -16
- data/lib/couchbase/diagnostics.rb +181 -0
- data/lib/couchbase/json_transcoder.rb +1 -1
- data/lib/couchbase/{common_options.rb → logger.rb} +24 -11
- data/lib/couchbase/management/query_index_manager.rb +1 -1
- data/lib/couchbase/management/user_manager.rb +3 -0
- data/lib/couchbase/options.rb +2094 -0
- data/lib/couchbase/query_options.rb +1 -144
- data/lib/couchbase/scope.rb +8 -25
- data/lib/couchbase/search_options.rb +0 -93
- data/lib/couchbase/version.rb +20 -1
- data/lib/couchbase/view_options.rb +1 -91
- metadata +19 -7
@@ -196,7 +196,7 @@ struct query_request {
|
|
196
196
|
std::optional<http_context> ctx_{};
|
197
197
|
bool extract_encoded_plan_{ false };
|
198
198
|
|
199
|
-
|
199
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& context)
|
200
200
|
{
|
201
201
|
ctx_.emplace(context);
|
202
202
|
tao::json::value body{};
|
@@ -324,11 +324,12 @@ struct query_request {
|
|
324
324
|
} else {
|
325
325
|
spdlog::debug("QUERY: prep={}, {}", tao::json::to_string(prep), tao::json::to_string(stmt));
|
326
326
|
}
|
327
|
+
return {};
|
327
328
|
}
|
328
329
|
};
|
329
330
|
|
330
331
|
query_response
|
331
|
-
make_response(std::error_code ec, query_request& request, query_request::encoded_response_type encoded)
|
332
|
+
make_response(std::error_code ec, query_request& request, query_request::encoded_response_type&& encoded)
|
332
333
|
{
|
333
334
|
query_response response{ request.client_context_id, ec };
|
334
335
|
if (!ec) {
|
@@ -39,24 +39,27 @@ struct remove_request {
|
|
39
39
|
document_id id;
|
40
40
|
uint16_t partition{};
|
41
41
|
uint32_t opaque{};
|
42
|
+
uint64_t cas{ 0 };
|
42
43
|
protocol::durability_level durability_level{ protocol::durability_level::none };
|
43
44
|
std::optional<std::uint16_t> durability_timeout{};
|
44
45
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
45
46
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
46
47
|
|
47
|
-
|
48
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
48
49
|
{
|
49
50
|
encoded.opaque(opaque);
|
50
51
|
encoded.partition(partition);
|
52
|
+
encoded.cas(cas);
|
51
53
|
encoded.body().id(id);
|
52
54
|
if (durability_level != protocol::durability_level::none) {
|
53
55
|
encoded.body().durability(durability_level, durability_timeout);
|
54
56
|
}
|
57
|
+
return {};
|
55
58
|
}
|
56
59
|
};
|
57
60
|
|
58
61
|
remove_response
|
59
|
-
make_response(std::error_code ec, remove_request& request, remove_request::encoded_response_type encoded)
|
62
|
+
make_response(std::error_code ec, remove_request& request, remove_request::encoded_response_type&& encoded)
|
60
63
|
{
|
61
64
|
remove_response response{ request.id, encoded.opaque(), ec };
|
62
65
|
if (ec && response.opaque == 0) {
|
@@ -49,7 +49,7 @@ struct replace_request {
|
|
49
49
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
50
50
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
51
51
|
|
52
|
-
|
52
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
53
53
|
{
|
54
54
|
encoded.opaque(opaque);
|
55
55
|
encoded.partition(partition);
|
@@ -61,11 +61,12 @@ struct replace_request {
|
|
61
61
|
if (durability_level != protocol::durability_level::none) {
|
62
62
|
encoded.body().durability(durability_level, durability_timeout);
|
63
63
|
}
|
64
|
+
return {};
|
64
65
|
}
|
65
66
|
};
|
66
67
|
|
67
68
|
replace_response
|
68
|
-
make_response(std::error_code ec, replace_request& request, replace_request::encoded_response_type encoded)
|
69
|
+
make_response(std::error_code ec, replace_request& request, replace_request::encoded_response_type&& encoded)
|
69
70
|
{
|
70
71
|
replace_response response{ request.id, encoded.opaque(), ec };
|
71
72
|
if (ec && response.opaque == 0) {
|
@@ -128,7 +128,7 @@ struct search_request {
|
|
128
128
|
|
129
129
|
std::map<std::string, tao::json::value> raw{};
|
130
130
|
|
131
|
-
|
131
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& context)
|
132
132
|
{
|
133
133
|
tao::json::value body{
|
134
134
|
{ "query", query },
|
@@ -201,11 +201,12 @@ struct search_request {
|
|
201
201
|
} else {
|
202
202
|
spdlog::debug("SEARCH: {}", tao::json::to_string(body["query"]));
|
203
203
|
}
|
204
|
+
return {};
|
204
205
|
}
|
205
206
|
};
|
206
207
|
|
207
208
|
search_response
|
208
|
-
make_response(std::error_code ec, search_request& request, search_request::encoded_response_type encoded)
|
209
|
+
make_response(std::error_code ec, search_request& request, search_request::encoded_response_type&& encoded)
|
209
210
|
{
|
210
211
|
search_response response{ ec };
|
211
212
|
response.meta_data.client_context_id = request.client_context_id;
|
@@ -42,17 +42,18 @@ struct touch_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
43
43
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
44
44
|
|
45
|
-
|
45
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
46
46
|
{
|
47
47
|
encoded.opaque(opaque);
|
48
48
|
encoded.partition(partition);
|
49
49
|
encoded.body().id(id);
|
50
50
|
encoded.body().expiry(expiry);
|
51
|
+
return {};
|
51
52
|
}
|
52
53
|
};
|
53
54
|
|
54
55
|
touch_response
|
55
|
-
make_response(std::error_code ec, touch_request& request, touch_request::encoded_response_type encoded)
|
56
|
+
make_response(std::error_code ec, touch_request& request, touch_request::encoded_response_type&& encoded)
|
56
57
|
{
|
57
58
|
touch_response response{ request.id, encoded.opaque(), ec };
|
58
59
|
if (ec && response.opaque == 0) {
|
@@ -42,17 +42,18 @@ struct unlock_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
43
43
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
44
44
|
|
45
|
-
|
45
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
46
46
|
{
|
47
47
|
encoded.opaque(opaque);
|
48
48
|
encoded.partition(partition);
|
49
49
|
encoded.body().id(id);
|
50
50
|
encoded.cas(cas);
|
51
|
+
return {};
|
51
52
|
}
|
52
53
|
};
|
53
54
|
|
54
55
|
unlock_response
|
55
|
-
make_response(std::error_code ec, unlock_request& request, unlock_request::encoded_response_type encoded)
|
56
|
+
make_response(std::error_code ec, unlock_request& request, unlock_request::encoded_response_type&& encoded)
|
56
57
|
{
|
57
58
|
unlock_response response{ request.id, encoded.opaque(), ec };
|
58
59
|
if (ec && response.opaque == 0) {
|
@@ -48,7 +48,7 @@ struct upsert_request {
|
|
48
48
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
49
49
|
io::retry_context<io::retry_strategy::best_effort> retries{ false };
|
50
50
|
|
51
|
-
|
51
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
52
52
|
{
|
53
53
|
encoded.opaque(opaque);
|
54
54
|
encoded.partition(partition);
|
@@ -59,11 +59,12 @@ struct upsert_request {
|
|
59
59
|
if (durability_level != protocol::durability_level::none) {
|
60
60
|
encoded.body().durability(durability_level, durability_timeout);
|
61
61
|
}
|
62
|
+
return {};
|
62
63
|
}
|
63
64
|
};
|
64
65
|
|
65
66
|
upsert_response
|
66
|
-
make_response(std::error_code ec, upsert_request& request, upsert_request::encoded_response_type encoded)
|
67
|
+
make_response(std::error_code ec, upsert_request& request, upsert_request::encoded_response_type&& encoded)
|
67
68
|
{
|
68
69
|
upsert_response response{ request.id, encoded.opaque(), ec };
|
69
70
|
if (ec && response.opaque == 0) {
|
@@ -89,7 +89,7 @@ struct document_view_request {
|
|
89
89
|
enum class sort_order { ascending, descending };
|
90
90
|
std::optional<sort_order> order;
|
91
91
|
|
92
|
-
|
92
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
93
93
|
{
|
94
94
|
std::vector<std::string> query_string;
|
95
95
|
|
@@ -172,11 +172,12 @@ struct document_view_request {
|
|
172
172
|
view_name,
|
173
173
|
fmt::join(query_string, "&"));
|
174
174
|
encoded.body = tao::json::to_string(body);
|
175
|
+
return {};
|
175
176
|
}
|
176
177
|
};
|
177
178
|
|
178
179
|
document_view_response
|
179
|
-
make_response(std::error_code ec, document_view_request& request, document_view_request::encoded_response_type encoded)
|
180
|
+
make_response(std::error_code ec, document_view_request& request, document_view_request::encoded_response_type&& encoded)
|
180
181
|
{
|
181
182
|
document_view_response response{ request.client_context_id, ec };
|
182
183
|
if (!ec) {
|
@@ -42,15 +42,16 @@ struct group_drop_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
43
43
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
44
44
|
|
45
|
-
|
45
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
46
46
|
{
|
47
47
|
encoded.method = "DELETE";
|
48
48
|
encoded.path = fmt::format("/settings/rbac/groups/{}", name);
|
49
|
+
return {};
|
49
50
|
}
|
50
51
|
};
|
51
52
|
|
52
53
|
group_drop_response
|
53
|
-
make_response(std::error_code ec, group_drop_request& request, group_drop_request::encoded_response_type encoded)
|
54
|
+
make_response(std::error_code ec, group_drop_request& request, group_drop_request::encoded_response_type&& encoded)
|
54
55
|
{
|
55
56
|
group_drop_response response{ request.client_context_id, ec };
|
56
57
|
if (!ec) {
|
@@ -43,16 +43,17 @@ struct group_get_request {
|
|
43
43
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
44
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
45
45
|
|
46
|
-
|
46
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
47
47
|
{
|
48
48
|
encoded.method = "GET";
|
49
49
|
encoded.path = fmt::format("/settings/rbac/groups/{}", name);
|
50
50
|
encoded.headers["content-type"] = "application/x-www-form-urlencoded";
|
51
|
+
return {};
|
51
52
|
}
|
52
53
|
};
|
53
54
|
|
54
55
|
group_get_response
|
55
|
-
make_response(std::error_code ec, group_get_request& request, group_get_request::encoded_response_type encoded)
|
56
|
+
make_response(std::error_code ec, group_get_request& request, group_get_request::encoded_response_type&& encoded)
|
56
57
|
{
|
57
58
|
group_get_response response{ request.client_context_id, ec };
|
58
59
|
if (!ec) {
|
@@ -42,16 +42,17 @@ struct group_get_all_request {
|
|
42
42
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
43
43
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
44
44
|
|
45
|
-
|
45
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
46
46
|
{
|
47
47
|
encoded.method = "GET";
|
48
48
|
encoded.path = fmt::format("/settings/rbac/groups");
|
49
49
|
encoded.headers["content-type"] = "application/x-www-form-urlencoded";
|
50
|
+
return {};
|
50
51
|
}
|
51
52
|
};
|
52
53
|
|
53
54
|
group_get_all_response
|
54
|
-
make_response(std::error_code ec, group_get_all_request& request, group_get_all_request::encoded_response_type encoded)
|
55
|
+
make_response(std::error_code ec, group_get_all_request& request, group_get_all_request::encoded_response_type&& encoded)
|
55
56
|
{
|
56
57
|
group_get_all_response response{ request.client_context_id, ec };
|
57
58
|
if (!ec) {
|
@@ -47,7 +47,7 @@ struct group_upsert_request {
|
|
47
47
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
48
48
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
49
49
|
|
50
|
-
|
50
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
51
51
|
{
|
52
52
|
encoded.method = "PUT";
|
53
53
|
encoded.path = fmt::format("/settings/rbac/groups/{}", group.name);
|
@@ -86,11 +86,12 @@ struct group_upsert_request {
|
|
86
86
|
}
|
87
87
|
encoded.body = fmt::format("{}", fmt::join(params, "&"));
|
88
88
|
encoded.headers["content-type"] = "application/x-www-form-urlencoded";
|
89
|
+
return {};
|
89
90
|
}
|
90
91
|
};
|
91
92
|
|
92
93
|
group_upsert_response
|
93
|
-
make_response(std::error_code ec, group_upsert_request& request, group_upsert_request::encoded_response_type encoded)
|
94
|
+
make_response(std::error_code ec, group_upsert_request& request, group_upsert_request::encoded_response_type&& encoded)
|
94
95
|
{
|
95
96
|
group_upsert_response response{ request.client_context_id, ec };
|
96
97
|
if (!ec) {
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <tao/json.hpp>
|
21
|
+
|
22
|
+
#include <version.hxx>
|
23
|
+
|
24
|
+
namespace couchbase::operations
|
25
|
+
{
|
26
|
+
struct http_noop_response {
|
27
|
+
std::string client_context_id;
|
28
|
+
std::error_code ec;
|
29
|
+
uint32_t status_code;
|
30
|
+
};
|
31
|
+
|
32
|
+
struct http_noop_request {
|
33
|
+
using response_type = http_noop_response;
|
34
|
+
using encoded_request_type = io::http_request;
|
35
|
+
using encoded_response_type = io::http_response;
|
36
|
+
|
37
|
+
service_type type;
|
38
|
+
std::chrono::milliseconds timeout;
|
39
|
+
|
40
|
+
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
41
|
+
|
42
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
43
|
+
{
|
44
|
+
encoded.headers["connection"] = "keep-alive";
|
45
|
+
encoded.method = "GET";
|
46
|
+
switch (type) {
|
47
|
+
case service_type::query:
|
48
|
+
timeout = timeout_defaults::query_timeout;
|
49
|
+
encoded.path = "/admin/ping";
|
50
|
+
break;
|
51
|
+
case service_type::analytics:
|
52
|
+
timeout = timeout_defaults::analytics_timeout;
|
53
|
+
encoded.path = "/admin/ping";
|
54
|
+
break;
|
55
|
+
case service_type::search:
|
56
|
+
timeout = timeout_defaults::search_timeout;
|
57
|
+
encoded.path = "/api/ping";
|
58
|
+
break;
|
59
|
+
case service_type::views:
|
60
|
+
timeout = timeout_defaults::view_timeout;
|
61
|
+
encoded.path = "/";
|
62
|
+
break;
|
63
|
+
case service_type::management:
|
64
|
+
case service_type::kv:
|
65
|
+
return std::make_error_code(error::common_errc::feature_not_available);
|
66
|
+
}
|
67
|
+
return {};
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
http_noop_response
|
72
|
+
make_response(std::error_code ec, http_noop_request& request, http_noop_request::encoded_response_type&& encoded)
|
73
|
+
{
|
74
|
+
http_noop_response response{ request.client_context_id, ec, encoded.status_code };
|
75
|
+
return response;
|
76
|
+
}
|
77
|
+
|
78
|
+
} // namespace couchbase::operations
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <document_id.hxx>
|
21
|
+
#include <protocol/cmd_noop.hxx>
|
22
|
+
#include <io/retry_context.hxx>
|
23
|
+
|
24
|
+
namespace couchbase::operations
|
25
|
+
{
|
26
|
+
|
27
|
+
struct mcbp_noop_response {
|
28
|
+
std::uint32_t opaque;
|
29
|
+
std::error_code ec{};
|
30
|
+
std::chrono::steady_clock::time_point start{};
|
31
|
+
std::chrono::steady_clock::time_point stop{};
|
32
|
+
};
|
33
|
+
|
34
|
+
struct mcbp_noop_request {
|
35
|
+
using encoded_request_type = protocol::client_request<protocol::mcbp_noop_request_body>;
|
36
|
+
using encoded_response_type = protocol::client_response<protocol::mcbp_noop_response_body>;
|
37
|
+
|
38
|
+
uint16_t partition{};
|
39
|
+
uint32_t opaque{};
|
40
|
+
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
41
|
+
io::retry_context<io::retry_strategy::best_effort> retries{ true };
|
42
|
+
|
43
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
44
|
+
{
|
45
|
+
encoded.opaque(opaque);
|
46
|
+
encoded.partition(partition);
|
47
|
+
return {};
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
51
|
+
mcbp_noop_response
|
52
|
+
make_response(std::error_code ec, mcbp_noop_request& request, mcbp_noop_request::encoded_response_type&& encoded)
|
53
|
+
{
|
54
|
+
mcbp_noop_response response{ encoded.opaque(), ec };
|
55
|
+
if (ec && response.opaque == 0) {
|
56
|
+
response.opaque = request.opaque;
|
57
|
+
}
|
58
|
+
return response;
|
59
|
+
}
|
60
|
+
|
61
|
+
} // namespace couchbase::operations
|
@@ -45,7 +45,7 @@ struct query_index_build_deferred_request {
|
|
45
45
|
std::string bucket_name;
|
46
46
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
47
47
|
|
48
|
-
|
48
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
49
49
|
{
|
50
50
|
encoded.headers["content-type"] = "application/json";
|
51
51
|
tao::json::value body{
|
@@ -58,13 +58,14 @@ struct query_index_build_deferred_request {
|
|
58
58
|
encoded.method = "POST";
|
59
59
|
encoded.path = "/query/service";
|
60
60
|
encoded.body = tao::json::to_string(body);
|
61
|
+
return {};
|
61
62
|
}
|
62
63
|
};
|
63
64
|
|
64
65
|
query_index_build_deferred_response
|
65
66
|
make_response(std::error_code ec,
|
66
67
|
query_index_build_deferred_request& request,
|
67
|
-
query_index_build_deferred_request::encoded_response_type encoded)
|
68
|
+
query_index_build_deferred_request::encoded_response_type&& encoded)
|
68
69
|
{
|
69
70
|
query_index_build_deferred_response response{ request.client_context_id, ec };
|
70
71
|
if (!ec) {
|
@@ -55,7 +55,7 @@ struct query_index_create_request {
|
|
55
55
|
std::optional<int> num_replicas{};
|
56
56
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
57
57
|
|
58
|
-
|
58
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
59
59
|
{
|
60
60
|
encoded.headers["content-type"] = "application/json";
|
61
61
|
tao::json::value with{};
|
@@ -95,11 +95,12 @@ struct query_index_create_request {
|
|
95
95
|
encoded.method = "POST";
|
96
96
|
encoded.path = "/query/service";
|
97
97
|
encoded.body = tao::json::to_string(body);
|
98
|
+
return {};
|
98
99
|
}
|
99
100
|
};
|
100
101
|
|
101
102
|
query_index_create_response
|
102
|
-
make_response(std::error_code ec, query_index_create_request& request, query_index_create_request::encoded_response_type encoded)
|
103
|
+
make_response(std::error_code ec, query_index_create_request& request, query_index_create_request::encoded_response_type&& encoded)
|
103
104
|
{
|
104
105
|
query_index_create_response response{ request.client_context_id, ec };
|
105
106
|
if (!ec) {
|