Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
pertsevds committed Mar 29, 2024
1 parent e65c7fe commit ad226ec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ jobs:
- os: ubuntu-22.04
elixir-version: 1.14
otp-version: 26
# - os: ubuntu-20.04
# elixir-version: 1.15
# otp-version: 24
# - os: ubuntu-20.04
# elixir-version: 1.15
# otp-version: 25
# - os: ubuntu-22.04
# elixir-version: 1.15
# otp-version: 26
# - os: ubuntu-20.04
# elixir-version: 1.16
# otp-version: 24
# - os: ubuntu-20.04
# elixir-version: 1.16
# otp-version: 25
# - os: ubuntu-18.04
# elixir-version: 1.16
# otp-version: 26
# - os: ubuntu-20.04
# elixir-version: 1.16
# otp-version: 26
# - os: ubuntu-22.04
# elixir-version: 1.16
# otp-version: 26
- os: ubuntu-20.04
elixir-version: 1.15
otp-version: 24
- os: ubuntu-20.04
elixir-version: 1.15
otp-version: 25
- os: ubuntu-22.04
elixir-version: 1.15
otp-version: 26
- os: ubuntu-20.04
elixir-version: 1.16
otp-version: 24
- os: ubuntu-20.04
elixir-version: 1.16
otp-version: 25
- os: ubuntu-18.04
elixir-version: 1.16
otp-version: 26
- os: ubuntu-20.04
elixir-version: 1.16
otp-version: 26
- os: ubuntu-22.04
elixir-version: 1.16
otp-version: 26
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ end
Add to your DNS zone your SRV record (https://en.wikipedia.org/wiki/SRV_record):

```sh
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node1.yourdomain.com.
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node2.yourdomain.com.
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node3.yourdomain.com.
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node4.yourdomain.com.
_app._tcp.yourdomain.com. 60 IN SRV 0 10 1234 node1.yourdomain.com.
_app._tcp.yourdomain.com. 60 IN SRV 0 10 1234 node2.yourdomain.com.
_app._tcp.yourdomain.com. 60 IN SRV 0 10 1234 node3.yourdomain.com.
_app._tcp.yourdomain.com. 60 IN SRV 0 10 1234 node4.yourdomain.com.
```

Add to your config files (`config/prod.exs`, `config/dev.exs`):
Expand Down
13 changes: 12 additions & 1 deletion lib/dns_srv_cluster/resolver.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
defmodule DNSSRVCluster.Resolver do
@moduledoc false
require Logger
require Record

Record.defrecord(:hostent, Record.extract(:hostent, from_lib: "kernel/include/inet.hrl"))

# Public

Expand All @@ -20,7 +24,14 @@ defmodule DNSSRVCluster.Resolver do
def list_connected_nodes, do: Node.list(:visible)

def lookup(query, type) when is_binary(query) and type in [:srv] do
:inet_res.lookup(~c"#{query}", :in, type)
case :inet_res.getbyname(~c"#{query}", type) do
{:ok, hostent(h_addr_list: addr_list)} ->
addr_list

{:error, _} ->
Logger.warning("inet_res.getbyname for query \"#{query}\" with type \"#{type}\"failed.")
[]
end
end

@spec my_node() :: atom()
Expand Down

0 comments on commit ad226ec

Please sign in to comment.