View Source partisan_peer_discovery_dns (partisan v5.0.0-rc.16)

An implementation of the partisan_peer_discovery_agent behaviour that uses DNS for service discovery.

It is enabled by using the following options in the sys.conf file

     bash
  {partisan, [
      {peer_discovery, [
           {type, partisan_peer_discovery_dns},
           {config, #{
               record_type => fqdns,
               query => "foo.local",
               node_basename => "foo"
           }}
      ]}
  ]}

Checking if a DNS query

If you are experiencing an issue with Partisan not finding the peers using DNS you might want to check the configuration is correct.

One way of doing that is by doing the following on your Erlang shell:

  1> Config = #{
       record_type => fqdns,
       query => "foo.local",
       node_basename => "foo"
  }.
  2> {ok, State} = partisan_peer_discovery_dns:init(Config).
  3> partisan_peer_discovery_dns:lookup(Config, 1000).

The last line should return the result

Summary

Types

config/0

-type config() ::
          #{record_type := record_type(),
            query := binary() | string(),
            node_basename := binary() | string(),
            options => options()}.

deprecated_config/0

-type deprecated_config() ::
          #{record_type := record_type(),
            name := binary() | string(),
            nodename := binary() | string(),
            options => options()}.

nameserver/0

-type nameserver() ::
          {string_or_type(inet:ip_address()), string_or_type(1..65535)} | binary() | string().

options/0

-type options() ::
          #{alt_nameservers => [nameserver()],
            nameservers => [nameserver()],
            inet6 => string_or_type(boolean())}.

record_type/0

-type record_type() :: string_or_type(a | aaaa | srv | fqdns).

string_or_type/1

-type string_or_type(T) :: T | binary() | string().

Functions

init(Opts)

-spec init(Opts :: config() | deprecated_config()) -> {ok, State :: any()} | {error, Reason :: any()}.

lookup(State, Timeout)

-spec lookup(State :: any(), timeout()) ->
                {ok, [partisan:node_spec()], NewState :: any()} |
                {error, Reason :: any(), NewState :: any()}.