-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLATFORM-2274]: Investigate possible DNS caching issues on our rabbi…
…tmq libraries (#199) * Resolving IPs and connect to one of them * Reformat * Fix credo * Add open test with ip resolution mocked * Remove test that cannot work on CI
- Loading branch information
1 parent
fbb7020
commit 8325dbb
Showing
4 changed files
with
180 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
erlang 23.1 | ||
elixir 1.11.2-otp-23 | ||
erlang 25.3.2.8 | ||
elixir 1.13.4-otp-25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule Amqpx.DNS do | ||
@moduledoc """ | ||
Module to resolve a DNS record into an A record. | ||
""" | ||
|
||
@doc """ | ||
Resolves the IP addresses of a given hostname. If the hostname | ||
cannot be resolved, it returns the hostname itself. | ||
""" | ||
@spec resolve_ips(charlist) :: [charlist] | ||
def resolve_ips(host) do | ||
case :inet.gethostbyname(host) do | ||
{:ok, {:hostent, _, _, _, _, ips}} -> | ||
ips |> Enum.map(&:inet.ntoa/1) |> Enum.dedup() | ||
|
||
_ -> | ||
[host] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters