PhiAccrualUdp.Sender
(phi_accrual_udp v0.1.0)
View Source
Periodic UDP heartbeat sender.
Opens a UDP socket and periodically transmits a phi_accrual_udp
heartbeat packet to each configured target. Fire-and-forget — UDP
delivery failure is the receiver's problem to detect (which is
exactly what phi_accrual is for).
Targets
Each target is a {host, port} tuple. Host can be an IP tuple, a
charlist, or an atom; port is an integer. Resolution happens on
every send so DNS changes are picked up without restart, at the
cost of a lookup per tick.
Sender.start_link(
targets: [
{{10, 0, 0, 2}, 4370},
{~c"peer-c.internal", 4370}
],
interval_ms: 1_000
)Timestamp source
By default the sender stamps packets with
:erlang.system_time(:millisecond) (wall clock, NTP-corrected on
most systems). Pass :timestamp_fn to override — for example, to
use monotonic time if you don't trust the wall clock.
Telemetry
[:phi_accrual_udp, :sender, :started]
measurements: %{}
metadata: %{interval_ms, target_count}
[:phi_accrual_udp, :sender, :tick]
measurements: %{sent, errors}
metadata: %{}
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
@type opts() :: [ targets: [target()], interval_ms: pos_integer(), timestamp_fn: (-> non_neg_integer()), name: GenServer.name() ]
@type target() :: {:inet.ip_address() | charlist() | atom(), :inet.port_number()}
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(opts()) :: GenServer.on_start()