SaltDns.Proxy.Answer (Salt v1.0.0)

Which addresses a name is answered with. Pure.

Input: the nodes of a group, each with its effective health (:in, :out, :drained, see SaltDns.Proxy.Health.effective/1) and its addresses. Output: the A and AAAA sets.

The rule is one address per node that is in. Three safeguards keep an answer from being empty, because an empty answer is certain failure and a possibly wrong one is not:

  • If the rule would leave a family (A or AAAA) with no address although a node that is not drained has addresses of that family, the addresses of all not-drained nodes of that family are kept instead (kept_all).
  • If every node that has addresses is drained, nothing is computed: the answer is :keep_last, whatever is published stays, and the caller shows a warning (all_drained).

A drained node never contributes, not even to the fallback: the operator took it out on purpose.

Summary

Functions

The record sets ("A" and "AAAA", each possibly empty) to publish.

The record type an address belongs to, "A" or "AAAA", or nil for text that is no address.

Types

health()

@type health() :: :in | :out | :drained

node_input()

@type node_input() :: %{health: health(), addresses: [String.t()]}

result()

@type result() ::
  {:publish, %{required(String.t()) => [String.t()]},
   %{kept_all: boolean(), all_drained: false}}
  | {:keep_last, %{kept_all: false, all_drained: true}}
  | {:none, %{kept_all: false, all_drained: false}}

Functions

select(nodes)

@spec select([node_input()]) :: result()

The record sets ("A" and "AAAA", each possibly empty) to publish.

type_of(address)

@spec type_of(String.t()) :: String.t() | nil

The record type an address belongs to, "A" or "AAAA", or nil for text that is no address.