szaszm commented on code in PR #1412:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1412#discussion_r972175243


##########
extensions/standard-processors/processors/PutUDP.cpp:
##########
@@ -107,48 +98,48 @@ void PutUDP::onTrigger(core::ProcessContext* context, 
core::ProcessSession* cons
     return;
   }
 
-  const auto nonthrowing_sockaddr_ntop = [](const sockaddr* const sa) -> 
std::string {
-    return utils::try_expression([sa] { return utils::net::sockaddr_ntop(sa); 
}).value_or("(n/a)");
+  asio::io_context io_context;
+
+  const auto resolve_hostname = [&io_context, &hostname, &port]() -> 
nonstd::expected<udp::resolver::results_type, std::error_code> {
+    udp::resolver resolver(io_context);
+    std::error_code error_code;
+    auto resolved_query = resolver.resolve(udp::v4(), hostname, port, 
error_code);
+    if (error_code)
+      return nonstd::make_unexpected(error_code);
+    return resolved_query;
+  };
+
+  const auto debug_log_resolved_endpoint = [&hostname, &logger = 
this->logger_](const udp::resolver::results_type& resolved_query) -> 
udp::endpoint {
+    if (logger->should_log(core::logging::LOG_LEVEL::debug))
+      core::logging::LOG_DEBUG(logger) << "resolved " << hostname << " to: " 
<< resolved_query->endpoint();
+    return resolved_query->endpoint();

Review Comment:
   How does this select the best endpoint from the list of returned matches? 
The old code iterated over the list until it could open a socket.
   
   I thought this was the best we can do with a connectionless protocol, but 
now that I think about it, iterating until it's able to send would be even 
better. Consider doing it if it's easy, but I'm not asking you to extend the 
scope with this if it's a difficult change.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to