enum class for ResolveType.

GitOrigin-RevId: 3cb46ab9c1c6913364748136722d2e8485cc6008
This commit is contained in:
levlam 2019-01-24 20:21:00 +03:00
parent 12ffc22483
commit 311cd72feb
2 changed files with 8 additions and 7 deletions

View File

@ -100,7 +100,8 @@ class DnsResolver : public Actor {
Promise<IPAddress> promise_;
ActorOwn<> query_;
size_t pos_ = 0;
GetHostByNameActor::ResolveType types[2] = {GetHostByNameActor::Google, GetHostByNameActor::Native};
GetHostByNameActor::ResolveType types[2] = {GetHostByNameActor::ResolveType::Google,
GetHostByNameActor::ResolveType::Native};
void loop() override {
if (!query_.empty()) {
@ -133,13 +134,13 @@ GetHostByNameActor::Options::Options() = default;
ActorOwn<> GetHostByNameActor::resolve(std::string host, ResolveOptions options, Promise<IPAddress> promise) {
switch (options.type) {
case Native:
case ResolveType::Native:
return ActorOwn<>(create_actor_on_scheduler<detail::NativeDnsResolver>(
"NativeDnsResolver", options.scheduler_id, std::move(host), options, std::move(promise)));
case Google:
case ResolveType::Google:
return ActorOwn<>(create_actor_on_scheduler<detail::GoogleDnsResolver>(
"GoogleDnsResolver", options.scheduler_id, std::move(host), options, std::move(promise)));
case All:
case ResolveType::All:
return ActorOwn<>(create_actor_on_scheduler<detail::DnsResolver>("DnsResolver", options.scheduler_id,
std::move(host), options, std::move(promise)));
default:

View File

@ -18,10 +18,10 @@ namespace td {
class GetHostByNameActor final : public Actor {
public:
enum ResolveType { Native, Google, All };
enum class ResolveType { Native, Google, All };
struct Options {
Options();
ResolveType type{Native};
ResolveType type{ResolveType::Native};
int scheduler_id{-1};
int32 ok_timeout{CACHE_TIME};
int32 error_timeout{ERROR_CACHE_TIME};
@ -30,7 +30,7 @@ class GetHostByNameActor final : public Actor {
void run(std::string host, int port, bool prefer_ipv6, Promise<IPAddress> promise);
struct ResolveOptions {
ResolveType type{Native};
ResolveType type{ResolveType::Native};
bool prefer_ipv6{false};
int scheduler_id{-1};
};