Skip to content

Commit 834c6e8

Browse files
authored
[coro_rpc] move acceptors from coro_rpc::config_t to make it copyable. (#1145)
1 parent a8a251d commit 834c6e8

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

include/ylt/coro_rpc/impl/coro_rpc_server.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ class coro_rpc_server_base {
106106
std::make_unique<coro_io::tcp_server_acceptor>(address));
107107
}
108108

109-
coro_rpc_server_base(const server_config &config)
109+
coro_rpc_server_base(
110+
const server_config &config,
111+
std::vector<std::unique_ptr<coro_io::server_acceptor_base>> acceptors =
112+
{})
110113
: pool_(config.thread_num),
111114
conn_timeout_duration_(config.conn_timeout_duration),
112115
flag_{stat::init},
@@ -130,8 +133,8 @@ class coro_rpc_server_base {
130133
init_ibv(config.ibv_config.value(), std::move(config.ibv_dev_lists));
131134
}
132135
#endif
133-
if (!config.acceptors.empty()) {
134-
acceptors_ = std::move(config.acceptors);
136+
if (!acceptors.empty()) {
137+
acceptors_ = std::move(acceptors);
135138
}
136139
else {
137140
acceptors_.push_back(std::make_unique<coro_io::tcp_server_acceptor>(

include/ylt/coro_rpc/impl/default_config/coro_rpc_config.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct config_t {
3939
std::chrono::steady_clock::duration conn_timeout_duration =
4040
std::chrono::seconds{0};
4141
std::string address = "0.0.0.0";
42-
mutable std::vector<std::unique_ptr<coro_io::server_acceptor_base>> acceptors;
4342
#ifdef YLT_ENABLE_SSL
4443
std::optional<ssl_configure> ssl_config = std::nullopt;
4544
#ifdef YLT_ENABLE_NTLS

src/coro_rpc/tests/test_acceptor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ TEST_CASE("test server acceptor") {
5050
std::make_unique<coro_io::tcp_server_acceptor>("0.0.0.0", 8824));
5151
acceptors.emplace_back(
5252
std::make_unique<coro_io::tcp_server_acceptor>("localhost", 8825));
53-
coro_rpc_server server(
54-
coro_rpc::config_t{.acceptors = std::move(acceptors)});
53+
coro_rpc_server server(coro_rpc::config_t{}, std::move(acceptors));
5554
server.register_handler<hello>();
5655

5756
auto res = server.async_start();

0 commit comments

Comments
 (0)