zyearn commented on a change in pull request #1529: URL: https://github.com/apache/incubator-brpc/pull/1529#discussion_r697710081
########## File path: src/brpc/channel.cpp ########## @@ -332,6 +333,7 @@ int Channel::Init(const char* ns_url, NULL, &_options.mutable_ssl_options()->sni_name, NULL); } } + ParseHostname(ns_url); Review comment: 如果这里返回码不重要的话,原函数需要返回int吗 ########## File path: src/brpc/channel.cpp ########## @@ -568,4 +576,16 @@ int Channel::CheckHealth() { } } +int Channel::ParseHostname(const char* server_addr) { + std::string host; + if (ParseURL(server_addr, NULL, &host, NULL) == 0) { + butil::ip_t ip; + if (butil::hostname2ip(host.c_str(), &ip) == 0) { + _hostname.swap(host); + return 0; + } + } + return -1; +} Review comment: 这个函数能加几个单测吗,各种server_addr情况(空,ip:port, host:port等)能返回正确结果 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org