couchbase 3.0.2 → 3.0.3
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/CMakeLists.txt +3 -0
- data/ext/build_version.hxx.in +1 -1
- data/ext/cmake/CompilerWarnings.cmake +1 -0
- data/ext/cmake/PreventInSourceBuilds.cmake +4 -1
- data/ext/couchbase/bucket.hxx +28 -2
- data/ext/couchbase/cluster.hxx +8 -2
- data/ext/couchbase/couchbase.cxx +955 -511
- data/ext/couchbase/error_context/analytics.hxx +46 -0
- data/ext/couchbase/error_context/http.hxx +44 -0
- data/ext/couchbase/error_context/key_value.hxx +47 -0
- data/ext/couchbase/error_context/query.hxx +46 -0
- data/ext/couchbase/error_context/search.hxx +47 -0
- data/ext/couchbase/error_context/view.hxx +47 -0
- data/ext/couchbase/io/dns_codec.hxx +1 -2
- data/ext/couchbase/io/http_command.hxx +16 -3
- data/ext/couchbase/io/http_context.hxx +1 -1
- data/ext/couchbase/io/http_session.hxx +12 -6
- data/ext/couchbase/io/http_session_manager.hxx +25 -24
- data/ext/couchbase/io/mcbp_session.hxx +8 -2
- data/ext/couchbase/io/retry_context.hxx +1 -1
- data/ext/couchbase/operations/analytics_dataset_create.hxx +19 -12
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +18 -10
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +16 -10
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +18 -11
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +17 -11
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +17 -10
- data/ext/couchbase/operations/analytics_index_create.hxx +17 -11
- data/ext/couchbase/operations/analytics_index_drop.hxx +16 -10
- data/ext/couchbase/operations/analytics_index_get_all.hxx +14 -10
- data/ext/couchbase/operations/analytics_link_connect.hxx +15 -9
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +16 -10
- data/ext/couchbase/operations/bucket_create.hxx +33 -10
- data/ext/couchbase/operations/bucket_drop.hxx +9 -8
- data/ext/couchbase/operations/bucket_flush.hxx +8 -8
- data/ext/couchbase/operations/bucket_get.hxx +15 -10
- data/ext/couchbase/operations/bucket_get_all.hxx +14 -7
- data/ext/couchbase/operations/bucket_settings.hxx +16 -0
- data/ext/couchbase/operations/bucket_update.hxx +32 -10
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +6 -6
- data/ext/couchbase/operations/collection_create.hxx +19 -13
- data/ext/couchbase/operations/collection_drop.hxx +18 -12
- data/ext/couchbase/operations/collections_manifest_get.hxx +5 -10
- data/ext/couchbase/operations/document_analytics.hxx +39 -17
- data/ext/couchbase/operations/document_append.hxx +5 -10
- data/ext/couchbase/operations/document_decrement.hxx +5 -10
- data/ext/couchbase/operations/document_exists.hxx +4 -6
- data/ext/couchbase/operations/document_get.hxx +6 -10
- data/ext/couchbase/operations/document_get_and_lock.hxx +4 -9
- data/ext/couchbase/operations/document_get_and_touch.hxx +4 -9
- data/ext/couchbase/operations/document_get_projected.hxx +21 -14
- data/ext/couchbase/operations/document_increment.hxx +5 -10
- data/ext/couchbase/operations/document_insert.hxx +5 -10
- data/ext/couchbase/operations/document_lookup_in.hxx +4 -9
- data/ext/couchbase/operations/document_mutate_in.hxx +7 -12
- data/ext/couchbase/operations/document_prepend.hxx +5 -10
- data/ext/couchbase/operations/document_query.hxx +45 -28
- data/ext/couchbase/operations/document_remove.hxx +5 -10
- data/ext/couchbase/operations/document_replace.hxx +5 -10
- data/ext/couchbase/operations/document_search.hxx +37 -16
- data/ext/couchbase/operations/document_touch.hxx +4 -9
- data/ext/couchbase/operations/document_unlock.hxx +4 -9
- data/ext/couchbase/operations/document_upsert.hxx +5 -10
- data/ext/couchbase/operations/document_view.hxx +29 -13
- data/ext/couchbase/operations/group_drop.hxx +7 -7
- data/ext/couchbase/operations/group_get.hxx +14 -10
- data/ext/couchbase/operations/group_get_all.hxx +14 -8
- data/ext/couchbase/operations/group_upsert.hxx +15 -9
- data/ext/couchbase/operations/http_noop.hxx +5 -5
- data/ext/couchbase/operations/mcbp_noop.hxx +3 -9
- data/ext/couchbase/operations/query_index_build_deferred.hxx +15 -9
- data/ext/couchbase/operations/query_index_create.hxx +16 -10
- data/ext/couchbase/operations/query_index_drop.hxx +16 -10
- data/ext/couchbase/operations/query_index_get_all.hxx +13 -7
- data/ext/couchbase/operations/role_get_all.hxx +14 -8
- data/ext/couchbase/operations/scope_create.hxx +19 -13
- data/ext/couchbase/operations/scope_drop.hxx +17 -11
- data/ext/couchbase/operations/scope_get_all.hxx +15 -10
- data/ext/couchbase/operations/search_get_stats.hxx +5 -5
- data/ext/couchbase/operations/search_index_analyze_document.hxx +25 -13
- data/ext/couchbase/operations/search_index_control_ingest.hxx +23 -11
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +23 -11
- data/ext/couchbase/operations/search_index_control_query.hxx +23 -11
- data/ext/couchbase/operations/search_index_drop.hxx +22 -10
- data/ext/couchbase/operations/search_index_get.hxx +22 -10
- data/ext/couchbase/operations/search_index_get_all.hxx +13 -7
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +24 -13
- data/ext/couchbase/operations/search_index_get_stats.hxx +16 -10
- data/ext/couchbase/operations/search_index_upsert.hxx +23 -11
- data/ext/couchbase/operations/user_drop.hxx +8 -8
- data/ext/couchbase/operations/user_get.hxx +14 -10
- data/ext/couchbase/operations/user_get_all.hxx +14 -8
- data/ext/couchbase/operations/user_upsert.hxx +15 -9
- data/ext/couchbase/operations/view_index_drop.hxx +7 -7
- data/ext/couchbase/operations/view_index_get.hxx +15 -9
- data/ext/couchbase/operations/view_index_get_all.hxx +15 -9
- data/ext/couchbase/operations/view_index_upsert.hxx +8 -8
- data/ext/couchbase/origin.hxx +1 -0
- data/ext/couchbase/platform/terminate_handler.cc +12 -8
- data/ext/couchbase/protocol/client_request.hxx +2 -1
- data/ext/couchbase/protocol/client_response.hxx +18 -15
- data/ext/couchbase/protocol/cmd_exists.hxx +1 -0
- data/ext/couchbase/protocol/cmd_get.hxx +1 -1
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +3 -4
- data/ext/couchbase/protocol/enhanced_error_info.hxx +28 -0
- data/ext/couchbase/utils/connection_string.hxx +1 -1
- data/ext/couchbase/version.hxx +1 -1
- data/ext/extconf.rb +1 -1
- data/ext/test/test_native_binary_operations.cxx +18 -18
- data/ext/test/test_native_diagnostics.cxx +2 -2
- data/ext/test/test_native_trivial_crud.cxx +2 -2
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_reader.hpp +1 -5
- data/lib/active_support/cache/couchbase_store.rb +362 -0
- data/lib/couchbase.rb +2 -0
- data/lib/couchbase/authenticator.rb +26 -0
- data/lib/couchbase/binary_collection.rb +1 -0
- data/lib/couchbase/bucket.rb +1 -0
- data/lib/couchbase/cluster.rb +51 -27
- data/lib/couchbase/collection.rb +19 -4
- data/lib/couchbase/collection_options.rb +10 -0
- data/lib/couchbase/configuration.rb +57 -0
- data/lib/couchbase/datastructures.rb +6 -0
- data/lib/couchbase/errors.rb +111 -3
- data/lib/couchbase/management.rb +27 -0
- data/lib/couchbase/management/bucket_manager.rb +9 -2
- data/lib/couchbase/management/collection_manager.rb +1 -1
- data/lib/couchbase/management/user_manager.rb +18 -2
- data/lib/couchbase/options.rb +33 -23
- data/lib/couchbase/railtie.rb +45 -0
- data/lib/couchbase/scope.rb +44 -3
- data/lib/couchbase/utils.rb +21 -0
- data/lib/couchbase/utils/time.rb +52 -0
- data/lib/couchbase/version.rb +1 -1
- data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
- metadata +19 -5
|
@@ -0,0 +1,46 @@
|
|
|
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 <optional>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include <io/retry_reason.hxx>
|
|
25
|
+
|
|
26
|
+
namespace couchbase::error_context
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
struct analytics {
|
|
30
|
+
std::error_code ec{};
|
|
31
|
+
std::string client_context_id{};
|
|
32
|
+
std::string statement{};
|
|
33
|
+
std::optional<std::string> parameters{};
|
|
34
|
+
|
|
35
|
+
std::string method{};
|
|
36
|
+
std::string path{};
|
|
37
|
+
std::uint32_t http_status{};
|
|
38
|
+
std::string http_body{};
|
|
39
|
+
|
|
40
|
+
std::optional<std::string> last_dispatched_to{};
|
|
41
|
+
std::optional<std::string> last_dispatched_from{};
|
|
42
|
+
int retry_attempts{ 0 };
|
|
43
|
+
std::set<io::retry_reason> retry_reasons{};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace couchbase::error_context
|
|
@@ -0,0 +1,44 @@
|
|
|
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 <optional>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include <io/retry_reason.hxx>
|
|
25
|
+
|
|
26
|
+
namespace couchbase::error_context
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
struct http {
|
|
30
|
+
std::error_code ec{};
|
|
31
|
+
std::string client_context_id{};
|
|
32
|
+
|
|
33
|
+
std::string method{};
|
|
34
|
+
std::string path{};
|
|
35
|
+
std::uint32_t http_status{};
|
|
36
|
+
std::string http_body{};
|
|
37
|
+
|
|
38
|
+
std::optional<std::string> last_dispatched_to{};
|
|
39
|
+
std::optional<std::string> last_dispatched_from{};
|
|
40
|
+
int retry_attempts{ 0 };
|
|
41
|
+
std::set<io::retry_reason> retry_reasons{};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace couchbase::error_context
|
|
@@ -0,0 +1,47 @@
|
|
|
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 <optional>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include <document_id.hxx>
|
|
25
|
+
#include <error_map.hxx>
|
|
26
|
+
#include <io/retry_reason.hxx>
|
|
27
|
+
#include <protocol/enhanced_error_info.hxx>
|
|
28
|
+
#include <protocol/status.hxx>
|
|
29
|
+
|
|
30
|
+
namespace couchbase::error_context
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
struct key_value {
|
|
34
|
+
document_id id{};
|
|
35
|
+
std::error_code ec{};
|
|
36
|
+
std::uint32_t opaque{};
|
|
37
|
+
std::optional<protocol::status> status_code{};
|
|
38
|
+
std::optional<error_map::error_info> error_map_info{};
|
|
39
|
+
std::optional<protocol::enhanced_error_info> enhanced_error_info{};
|
|
40
|
+
|
|
41
|
+
std::optional<std::string> last_dispatched_to{};
|
|
42
|
+
std::optional<std::string> last_dispatched_from{};
|
|
43
|
+
int retry_attempts{ 0 };
|
|
44
|
+
std::set<io::retry_reason> retry_reasons{};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace couchbase::error_context
|
|
@@ -0,0 +1,46 @@
|
|
|
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 <optional>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include <io/retry_reason.hxx>
|
|
25
|
+
|
|
26
|
+
namespace couchbase::error_context
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
struct query {
|
|
30
|
+
std::error_code ec{};
|
|
31
|
+
std::string client_context_id{};
|
|
32
|
+
std::string statement{};
|
|
33
|
+
std::optional<std::string> parameters{};
|
|
34
|
+
|
|
35
|
+
std::string method{};
|
|
36
|
+
std::string path{};
|
|
37
|
+
std::uint32_t http_status{};
|
|
38
|
+
std::string http_body{};
|
|
39
|
+
|
|
40
|
+
std::optional<std::string> last_dispatched_to{};
|
|
41
|
+
std::optional<std::string> last_dispatched_from{};
|
|
42
|
+
int retry_attempts{ 0 };
|
|
43
|
+
std::set<io::retry_reason> retry_reasons{};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace couchbase::error_context
|
|
@@ -0,0 +1,47 @@
|
|
|
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 <optional>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include <io/retry_reason.hxx>
|
|
25
|
+
|
|
26
|
+
namespace couchbase::error_context
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
struct search {
|
|
30
|
+
std::error_code ec{};
|
|
31
|
+
std::string client_context_id{};
|
|
32
|
+
std::string index_name{};
|
|
33
|
+
std::optional<std::string> query{};
|
|
34
|
+
std::optional<std::string> parameters{};
|
|
35
|
+
|
|
36
|
+
std::string method{};
|
|
37
|
+
std::string path{};
|
|
38
|
+
std::uint32_t http_status{};
|
|
39
|
+
std::string http_body{};
|
|
40
|
+
|
|
41
|
+
std::optional<std::string> last_dispatched_to{};
|
|
42
|
+
std::optional<std::string> last_dispatched_from{};
|
|
43
|
+
int retry_attempts{ 0 };
|
|
44
|
+
std::set<io::retry_reason> retry_reasons{};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace couchbase::error_context
|
|
@@ -0,0 +1,47 @@
|
|
|
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 <optional>
|
|
21
|
+
#include <set>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include <io/retry_reason.hxx>
|
|
25
|
+
|
|
26
|
+
namespace couchbase::error_context
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
struct view {
|
|
30
|
+
std::error_code ec{};
|
|
31
|
+
std::string client_context_id{};
|
|
32
|
+
std::string design_document_name{};
|
|
33
|
+
std::string view_name{};
|
|
34
|
+
std::vector<std::string> query_string{};
|
|
35
|
+
|
|
36
|
+
std::string method{};
|
|
37
|
+
std::string path{};
|
|
38
|
+
std::uint32_t http_status{};
|
|
39
|
+
std::string http_body{};
|
|
40
|
+
|
|
41
|
+
std::optional<std::string> last_dispatched_to{};
|
|
42
|
+
std::optional<std::string> last_dispatched_from{};
|
|
43
|
+
int retry_attempts{ 0 };
|
|
44
|
+
std::set<io::retry_reason> retry_reasons{};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace couchbase::error_context
|
|
@@ -26,6 +26,7 @@ template<typename Request>
|
|
|
26
26
|
struct http_command : public std::enable_shared_from_this<http_command<Request>> {
|
|
27
27
|
using encoded_request_type = typename Request::encoded_request_type;
|
|
28
28
|
using encoded_response_type = typename Request::encoded_response_type;
|
|
29
|
+
using error_context_type = typename Request::error_context_type;
|
|
29
30
|
asio::steady_timer deadline;
|
|
30
31
|
asio::steady_timer retry_backoff;
|
|
31
32
|
Request request;
|
|
@@ -44,7 +45,10 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
44
45
|
encoded.type = request.type;
|
|
45
46
|
auto encoding_ec = request.encode_to(encoded, session->http_context());
|
|
46
47
|
if (encoding_ec) {
|
|
47
|
-
|
|
48
|
+
error_context_type ctx{};
|
|
49
|
+
ctx.ec = encoding_ec;
|
|
50
|
+
ctx.client_context_id = request.client_context_id;
|
|
51
|
+
return handler(make_response(std::move(ctx), request, {}));
|
|
48
52
|
}
|
|
49
53
|
encoded.headers["client-context-id"] = request.client_context_id;
|
|
50
54
|
auto log_prefix = session->log_prefix();
|
|
@@ -80,8 +84,17 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
|
80
84
|
resp.status_code,
|
|
81
85
|
spdlog::to_hex(resp.body));
|
|
82
86
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
error_context_type ctx{};
|
|
88
|
+
ctx.ec = ec;
|
|
89
|
+
ctx.client_context_id = self->request.client_context_id;
|
|
90
|
+
ctx.method = self->encoded.method;
|
|
91
|
+
ctx.path = self->encoded.path;
|
|
92
|
+
ctx.last_dispatched_from = session->local_address();
|
|
93
|
+
ctx.last_dispatched_to = session->remote_address();
|
|
94
|
+
ctx.http_status = msg.status_code;
|
|
95
|
+
ctx.http_body = msg.body;
|
|
96
|
+
handler(make_response(std::move(ctx), self->request, std::move(msg)));
|
|
97
|
+
} catch (priv::retry_http_request&) {
|
|
85
98
|
self->send_to(session, std::forward<Handler>(handler));
|
|
86
99
|
}
|
|
87
100
|
});
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
#pragma once
|
|
19
19
|
|
|
20
|
-
#include <utility>
|
|
21
20
|
#include <memory>
|
|
21
|
+
#include <utility>
|
|
22
22
|
|
|
23
23
|
#include <spdlog/spdlog.h>
|
|
24
24
|
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
#include <errors.hxx>
|
|
31
31
|
#include <version.hxx>
|
|
32
32
|
|
|
33
|
-
#include <io/http_parser.hxx>
|
|
34
|
-
#include <io/http_message.hxx>
|
|
35
33
|
#include <io/http_context.hxx>
|
|
34
|
+
#include <io/http_message.hxx>
|
|
35
|
+
#include <io/http_parser.hxx>
|
|
36
36
|
#include <platform/base64.h>
|
|
37
37
|
#include <timeout_defaults.hxx>
|
|
38
38
|
|
|
@@ -103,11 +103,17 @@ class http_session : public std::enable_shared_from_this<http_session>
|
|
|
103
103
|
|
|
104
104
|
std::string remote_address() const
|
|
105
105
|
{
|
|
106
|
+
if (endpoint_.protocol() == asio::ip::tcp::v6()) {
|
|
107
|
+
return fmt::format("[{}]:{}", endpoint_address_, endpoint_.port());
|
|
108
|
+
}
|
|
106
109
|
return fmt::format("{}:{}", endpoint_address_, endpoint_.port());
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
std::string local_address() const
|
|
110
113
|
{
|
|
114
|
+
if (endpoint_.protocol() == asio::ip::tcp::v6()) {
|
|
115
|
+
return fmt::format("[{}]:{}", local_endpoint_address_, local_endpoint_.port());
|
|
116
|
+
}
|
|
111
117
|
return fmt::format("{}:{}", local_endpoint_address_, local_endpoint_.port());
|
|
112
118
|
}
|
|
113
119
|
|
|
@@ -178,12 +184,12 @@ class http_session : public std::enable_shared_from_this<http_session>
|
|
|
178
184
|
state_ = diag::endpoint_state::disconnected;
|
|
179
185
|
}
|
|
180
186
|
|
|
181
|
-
bool keep_alive()
|
|
187
|
+
bool keep_alive() const
|
|
182
188
|
{
|
|
183
189
|
return keep_alive_;
|
|
184
190
|
}
|
|
185
191
|
|
|
186
|
-
bool is_stopped()
|
|
192
|
+
bool is_stopped() const
|
|
187
193
|
{
|
|
188
194
|
return stopped_;
|
|
189
195
|
}
|
|
@@ -215,7 +221,7 @@ class http_session : public std::enable_shared_from_this<http_session>
|
|
|
215
221
|
do_write();
|
|
216
222
|
}
|
|
217
223
|
|
|
218
|
-
void write_and_subscribe(io::http_request& request, std::function<void(std::error_code, io::http_response&&)
|
|
224
|
+
void write_and_subscribe(io::http_request& request, std::function<void(std::error_code, io::http_response&&)>&& handler)
|
|
219
225
|
{
|
|
220
226
|
if (stopped_) {
|
|
221
227
|
return;
|
|
@@ -117,30 +117,31 @@ class http_session_manager : public std::enable_shared_from_this<http_session_ma
|
|
|
117
117
|
operations::http_noop_request request{};
|
|
118
118
|
request.type = type;
|
|
119
119
|
auto cmd = std::make_shared<operations::http_command<operations::http_noop_request>>(ctx_, request);
|
|
120
|
-
cmd->send_to(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
120
|
+
cmd->send_to(
|
|
121
|
+
session,
|
|
122
|
+
[start = std::chrono::steady_clock::now(),
|
|
123
|
+
self = shared_from_this(),
|
|
124
|
+
type,
|
|
125
|
+
session,
|
|
126
|
+
handler = collector->build_reporter()](operations::http_noop_response&& resp) mutable {
|
|
127
|
+
diag::ping_state state = diag::ping_state::ok;
|
|
128
|
+
std::optional<std::string> error{};
|
|
129
|
+
if (resp.ctx.ec) {
|
|
130
|
+
state = diag::ping_state::error;
|
|
131
|
+
error.emplace(fmt::format(
|
|
132
|
+
"code={}, message={}, http_code={}", resp.ctx.ec.value(), resp.ctx.ec.message(), resp.ctx.http_status));
|
|
133
|
+
}
|
|
134
|
+
handler(diag::endpoint_ping_info{
|
|
135
|
+
type,
|
|
136
|
+
session->id(),
|
|
137
|
+
std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - start),
|
|
138
|
+
session->remote_address(),
|
|
139
|
+
session->local_address(),
|
|
140
|
+
state,
|
|
141
|
+
{},
|
|
142
|
+
error });
|
|
143
|
+
self->check_in(type, session);
|
|
144
|
+
});
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
}
|