Skip to content

Commit

Permalink
[coro_rpc] fix context<T>::get_connection_id
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Mar 14, 2024
1 parent 244c92a commit a528fff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/ylt/coro_rpc/impl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class context_base {
* Get the unique connection ID
* @return connection id
*/
uint64_t get_connection_id() { return self_->conn_->conn_id_; }
uint64_t get_connection_id() const noexcept { return self_->conn_->get_connection_id(); }

/*!
* Set the response_attachment
Expand Down
4 changes: 2 additions & 2 deletions include/ylt/coro_rpc/impl/coro_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
});
}

void close_coro() {}

using QuitCallback = std::function<void(const uint64_t &conn_id)>;
void set_quit_callback(QuitCallback callback, uint64_t conn_id) {
quit_callback_ = std::move(callback);
conn_id_ = conn_id;
}

uint64_t get_connection_id() const noexcept { return conn_id_; }

std::any &tag() { return tag_; }
const std::any &tag() const { return tag_; }

Expand Down
1 change: 1 addition & 0 deletions src/coro_rpc/tests/rpc_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int long_run_func(int val) {
}

void echo_with_attachment(coro_rpc::context<void> conn) {
ELOGFMT(INFO, "conn ID", conn.get_connection_id());
auto str = conn.release_request_attachment();
conn.set_response_attachment(std::move(str));
conn.response_msg();
Expand Down

0 comments on commit a528fff

Please sign in to comment.