Skip to content

Commit 6a51901

Browse files
committed
2 parents e62f401 + f8348b4 commit 6a51901

File tree

9 files changed

+233
-108
lines changed

9 files changed

+233
-108
lines changed

include/ylt/coro_io/server_acceptor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ struct tcp_server_acceptor : public server_acceptor_base {
136136
assert(acceptor_ != std::nullopt);
137137
auto executor = pool_->get_executor();
138138
asio::ip::tcp::socket socket(executor->get_asio_executor());
139-
ELOG_INFO << "start accepting from acceptor: " << address_ << ":" << port_;
139+
ELOG_TRACE << "start accepting from acceptor: " << address_ << ":" << port_;
140140
auto error = co_await coro_io::async_accept(*acceptor_, socket);
141-
ELOG_INFO << "get connection from acceptor: " << address_ << ":" << port_;
141+
ELOG_TRACE << "get connection from acceptor: " << address_ << ":" << port_;
142142
if (error) {
143143
ELOG_ERROR << "accept error: " << error.message();
144144
if (error == asio::error::operation_aborted ||

include/ylt/coro_rpc/impl/context.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <async_simple/coro/Lazy.h>
1919

2020
#include <any>
21+
#include <chrono>
2122
#include <cstdint>
2223
#include <functional>
2324
#include <memory>
@@ -41,6 +42,8 @@ template <typename return_msg_type, typename rpc_protocol>
4142
class context_base {
4243
protected:
4344
std::shared_ptr<context_info_t<rpc_protocol>> self_;
45+
std::chrono::steady_clock::time_point time_point_ =
46+
std::chrono::steady_clock::now();
4447
typename rpc_protocol::req_header &get_req_head() { return self_->req_head_; }
4548

4649
bool check_status() {
@@ -80,10 +83,12 @@ class context_base {
8083
if (!check_status())
8184
AS_UNLIKELY { return; };
8285
ELOGI << "rpc error in function:" << self_->get_rpc_function_name()
83-
<< ". error code:" << error_code.ec << ". message : " << error_msg;
86+
<< ". error code:" << error_code.ec << ". message : " << error_msg
87+
<< "conn id" << self_->conn_->get_connection_id()
88+
<< "request id:" << self_->get_request_id();
8489
self_->conn_->template response_error<rpc_protocol>(
85-
error_code, error_msg, self_->req_head_,
86-
std::move(self_->complete_handler_));
90+
time_point_, self_->get_request_id(), error_code, error_msg,
91+
self_->req_head_, std::move(self_->complete_handler_));
8792
}
8893
void response_error(coro_rpc::err_code error_code) {
8994
response_error(error_code, error_code.message());
@@ -108,6 +113,7 @@ class context_base {
108113
std::visit(
109114
[&]<typename serialize_proto>(const serialize_proto &) {
110115
self_->conn_->template response_msg<rpc_protocol>(
116+
time_point_, self_->get_request_id(),
111117
serialize_proto::serialize(),
112118
std::move(self_->resp_attachment_), self_->req_head_,
113119
std::move(self_->complete_handler_));
@@ -122,6 +128,7 @@ class context_base {
122128
std::visit(
123129
[&]<typename serialize_proto>(const serialize_proto &) {
124130
self_->conn_->template response_msg<rpc_protocol>(
131+
time_point_, self_->get_request_id(),
125132
serialize_proto::serialize(ret),
126133
std::move(self_->resp_attachment_), self_->req_head_,
127134
std::move(self_->complete_handler_));

include/ylt/coro_rpc/impl/coro_connection.hpp

Lines changed: 110 additions & 49 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)