Current section

Files

Jump to
mdns_client_lib priv mdns_client.schema
Raw

priv/mdns_client.schema

%% -*- erlang -*-
%% @doc Domain this listener is listening to.
{mapping, "mdns.client.domain", "mdns_client_lib.domain",
[{default, ".local"},
{datatype, string}]}.
%% @doc The IP of the interface mdns traffic is received.
%% a ip of 0.0.0.0 means the first found interface. The default is 5453
{mapping, "mdns.client.interface", "mdns_client_lib.interface",
[{default, "0.0.0.0"}]}. % this should be IP but IP requires a port.
{translation,
"mdns_client_lib.interface",
fun(Conf) ->
IP = cuttlefish:conf_get("mdns.client.interface", Conf),
[A, B, C, D] = [list_to_integer(O) ||
O <- re:split(IP, "\\.", [{return, list}])],
{A, B, C, D}
end
}.
%% @doc The multicast group the MDNS service is running on.
{mapping, "mdns.client.multicast_group", "mdns_client_lib.multicast_group",
[{default, {"224.0.0.251", 5353}},
{datatype, ip}]}.
{translation,
"mdns_client_lib.address",
fun(Conf) ->
{IP, _Port} = cuttlefish:conf_get("mdns.client.multicast_group", Conf),
[A, B, C, D] = [list_to_integer(O) ||
O <- re:split(IP, "\\.", [{return, list}])],
{A, B, C, D}
end
}.
{translation,
"mdns_client_lib.port",
fun(Conf) ->
{_IP, Port} = cuttlefish:conf_get("mdns.client.multicast_group", Conf),
Port
end
}.
%% @doc The service to listen to, it will be prepended to the domain.
{mapping, "mdns.client.service", "mdns_client_lib.service",
[{default, "generic"},
{level, advanced},
{datatype, string}]}.
%% @doc the time that the mdns client iwll wait for a reply from a counterpart
%% before it claims a timeout.
{mapping, "mdns.client.timeout", "mdns_client_lib.recv_timeout",
[{default, 1500},
{datatype, {duration, ms}}]}.
%% @doc Number of tiems a given request will try to find a responding host
%% before it gives up.
{mapping, "mdns.client.retries", "mdns_client_lib.max_retries",
[{default, 4},
{datatype, integer}]}.
%% @doc Deley between retries to ensure minimal hickups don't blow up the
%% system.
{mapping, "mdns.client.retrie_delay", "mdns_client_lib.retry_delay",
[{default, 150},
{datatype, {duration, ms}}]}.
%% @doc Number of downvotes a endpoint needs to be taken offline for this round.
%% before it gives up.
{mapping, "mdns.client.max_downvotes", "mdns_client_lib.max_downvotes",
[{default, 5},
{datatype, integer}]}.
%% @doc Initial/idle size of a connection pool.
{mapping, "mdns.client.pool.initial", "mdns_client_lib.pool_initial",
[{default, 5},
{datatype, integer}]}.
%% @doc Maximum size of the connector pools, ther is one pool per endpoint per
%% service.
{mapping, "mdns.client.pool.max", "mdns_client_lib.pool_max",
[{default, 5},
{datatype, integer}]}.
{mapping, "mdns.service.$service", "mdns_client_lib.static_servers",
[{datatype, ip}]}.
{translation,
"mdns_client_lib.static_servers",
fun(Conf) ->
Services = cuttlefish_variable:filter_by_prefix("mdns.service", Conf),
[{lists:last(S), IP} || {S, IP} <- Services]
end
}.