Rename ResolveType to ResolverType.

GitOrigin-RevId: 64350527620c08bb192a18d951d5b3b5216f1162
This commit is contained in:
levlam 2019-02-04 04:36:13 +03:00
parent da59ac47ea
commit fc8917a4ed
4 changed files with 15 additions and 15 deletions

View File

@ -1243,7 +1243,7 @@ void ConnectionCreator::start_up() {
GetHostByNameActor::Options options;
options.scheduler_id = G()->get_gc_scheduler_id();
options.types = {GetHostByNameActor::ResolveType::Google, GetHostByNameActor::ResolveType::Native};
options.resolver_types = {GetHostByNameActor::ResolverType::Google, GetHostByNameActor::ResolverType::Native};
options.ok_timeout = 5 * 60 - 1;
options.error_timeout = 0;
get_host_by_name_actor_ = create_actor<GetHostByNameActor>("GetHostByNameActor", std::move(options));

View File

@ -104,7 +104,7 @@ class NativeDnsResolver : public Actor {
} // namespace detail
GetHostByNameActor::GetHostByNameActor(Options options) : options_(std::move(options)) {
CHECK(!options_.types.empty());
CHECK(!options_.resolver_types.empty());
}
void GetHostByNameActor::run(string host, int port, bool prefer_ipv6, Promise<IPAddress> promise) {
@ -128,14 +128,14 @@ void GetHostByNameActor::run_query(std::string host, bool prefer_ipv6, Query &qu
});
CHECK(query.query.empty());
CHECK(query.pos < options_.types.size());
auto resolver_type = options_.types[query.pos++];
CHECK(query.pos < options_.resolver_types.size());
auto resolver_type = options_.resolver_types[query.pos++];
query.query = [&] {
switch (resolver_type) {
case ResolveType::Native:
case ResolverType::Native:
return ActorOwn<>(create_actor_on_scheduler<detail::NativeDnsResolver>(
"NativeDnsResolver", options_.scheduler_id, std::move(host), prefer_ipv6, std::move(promise)));
case ResolveType::Google:
case ResolverType::Google:
return ActorOwn<>(create_actor_on_scheduler<detail::GoogleDnsResolver>(
"GoogleDnsResolver", options_.scheduler_id, std::move(host), prefer_ipv6, std::move(promise)));
default:
@ -152,7 +152,7 @@ void GetHostByNameActor::on_query_result(std::string host, bool prefer_ipv6, Res
CHECK(!query.promises.empty());
CHECK(!query.query.empty());
if (res.is_error() && query.pos < options_.types.size()) {
if (res.is_error() && query.pos < options_.resolver_types.size()) {
query.query.reset();
return run_query(std::move(host), prefer_ipv6, query);
}

View File

@ -18,13 +18,13 @@ namespace td {
class GetHostByNameActor final : public Actor {
public:
enum class ResolveType { Native, Google };
enum class ResolverType { Native, Google };
struct Options {
static constexpr int32 DEFAULT_CACHE_TIME = 60 * 29; // 29 minutes
static constexpr int32 DEFAULT_ERROR_CACHE_TIME = 60 * 5; // 5 minutes
vector<ResolveType> types{ResolveType::Native};
vector<ResolverType> resolver_types{ResolverType::Native};
int32 scheduler_id{-1};
int32 ok_timeout{DEFAULT_CACHE_TIME};
int32 error_timeout{DEFAULT_ERROR_CACHE_TIME};

View File

@ -62,13 +62,13 @@ TEST(Mtproto, GetHostByNameActor) {
std::vector<std::string> hosts = {
"127.0.0.2", "1.1.1.1", "localhost", "web.telegram.org", "web.telegram.org", "москва.рф", "", "%", " ", "a"};
for (auto types : {vector<GetHostByNameActor::ResolveType>{GetHostByNameActor::ResolveType::Native},
vector<GetHostByNameActor::ResolveType>{GetHostByNameActor::ResolveType::Google},
vector<GetHostByNameActor::ResolveType>{GetHostByNameActor::ResolveType::Google,
GetHostByNameActor::ResolveType::Google,
GetHostByNameActor::ResolveType::Native}}) {
for (auto types : {vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Native},
vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Google},
vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Google,
GetHostByNameActor::ResolverType::Google,
GetHostByNameActor::ResolverType::Native}}) {
GetHostByNameActor::Options options;
options.types = types;
options.resolver_types = types;
options.scheduler_id = threads_n;
auto actor = create_actor<GetHostByNameActor>("GetHostByNameActor", std::move(options));