Skip to content

Commit

Permalink
Rename ResolveType to ResolverType.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 64350527620c08bb192a18d951d5b3b5216f1162
  • Loading branch information
levlam committed Feb 4, 2019
1 parent da59ac4 commit fc8917a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion td/telegram/net/ConnectionCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 6 additions & 6 deletions tdnet/td/net/GetHostByNameActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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:
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions tdnet/td/net/GetHostByNameActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
12 changes: 6 additions & 6 deletions test/mtproto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit fc8917a

Please sign in to comment.