feat: GrpcSource for ETL ng (#1745)

For #1596 and #1597
This commit is contained in:
Alex Kremer
2024-11-21 17:03:37 +00:00
committed by GitHub
parent 9dc322fc7b
commit 6af86367fd
13 changed files with 922 additions and 19 deletions

View File

@@ -37,12 +37,16 @@ template <typename T>
concept SomeResolver = requires(T t) {
std::is_default_constructible_v<T>;
{ t.resolve(std::string_view{}, std::string_view{}) } -> std::same_as<std::vector<std::string>>;
{ t.resolve(std::string_view{}) } -> std::same_as<std::vector<std::string>>;
};
/**
* @brief Simple hostnames to IP addresses resolver.
*/
class Resolver {
boost::asio::io_context ioContext_;
boost::asio::ip::tcp::resolver resolver_{ioContext_};
public:
/**
* @brief Resolve hostname to IP addresses.
@@ -50,15 +54,26 @@ public:
* @throw This method throws an exception when the hostname cannot be resolved.
*
* @param hostname Hostname to resolve
* @param service Service to resolve (could be empty or port number or http)
* @return IP addresses of the hostname
*/
std::vector<std::string>
resolve(std::string_view hostname, std::string_view service = "");
resolve(std::string_view hostname);
/**
* @brief Resolve to IP addresses with port.
*
* @throw This method throws an exception when the hostname cannot be resolved.
*
* @param hostname Hostname to resolve
* @param service Service to resolve
* @return IP addresses of the hostname
*/
std::vector<std::string>
resolve(std::string_view hostname, std::string_view service);
private:
boost::asio::io_context ioContext_;
boost::asio::ip::tcp::resolver resolver_{ioContext_};
std::vector<boost::asio::ip::tcp::endpoint>
doResolve(std::string_view hostname, std::string_view service);
};
} // namespace web