From e393a716d8742a987a36df555defb2ca90bb94d4 Mon Sep 17 00:00:00 2001 From: dentiny Date: Tue, 12 Nov 2024 19:54:34 -0800 Subject: [PATCH] [core] Minor improvement for session (#48711) Some minor improvements for session implementation. Signed-off-by: dentiny --- src/ray/raylet/runtime_env_agent_client.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ray/raylet/runtime_env_agent_client.cc b/src/ray/raylet/runtime_env_agent_client.cc index 82a2d5a4c6a6..029b426565d5 100644 --- a/src/ray/raylet/runtime_env_agent_client.cc +++ b/src/ray/raylet/runtime_env_agent_client.cc @@ -91,7 +91,7 @@ class Session : public std::enable_shared_from_this { // // This method should only be called once. void run(FinishedCallback finished_callback) { - finished_callback_ = finished_callback; + finished_callback_ = std::move(finished_callback); // Starts the state machine by looking up the domain name. resolver_.async_resolve( host_, @@ -151,7 +151,7 @@ class Session : public std::enable_shared_from_this { void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { if (ec) { - Failed(ray::Status::NotFound("on_connect " + ec.message())); + Failed(ray::Status::NotFound(absl::StrCat("on_connect ", ec.message()))); return; } @@ -163,9 +163,8 @@ class Session : public std::enable_shared_from_this { void on_write(beast::error_code ec, std::size_t bytes_transferred) { if (ec) { - Failed(ray::Status::Disconnected("on_write " + ec.message() + - ", bytes_transferred " + - std::to_string(bytes_transferred))); + Failed(ray::Status::Disconnected(absl::StrCat( + "on_write ", ec.message(), ", bytes_transferred ", bytes_transferred))); return; } stream_.expires_never(); @@ -178,9 +177,8 @@ class Session : public std::enable_shared_from_this { void on_read(beast::error_code ec, std::size_t bytes_transferred) { if (ec) { - Failed(ray::Status::Disconnected("on_read " + ec.message() + - ", bytes_transferred " + - std::to_string(bytes_transferred))); + Failed(ray::Status::Disconnected(absl::StrCat( + "on_read ", ec.message(), ", bytes_transferred ", bytes_transferred))); return; } @@ -276,7 +274,7 @@ class HttpRuntimeEnvAgentClient : public RuntimeEnvAgentClient { : io_context_(io_context), session_pool_(session_pool_size), address_(address), - port_str_(std::to_string(port)), + port_str_(absl::StrFormat("%d", port)), delay_executor_(delay_executor), shutdown_raylet_gracefully_(shutdown_raylet_gracefully), agent_register_timeout_ms_(agent_register_timeout_ms),