aprs.me/lib/aprsme/is/packet_stats.ex
Graham McIntire 5ef97adaf7
refactor: promote hot-path GenServer state maps to structs
Converts the inline state maps in Is, PacketConsumer, LeaderElection, and
CircuitBreaker into structs with @type t specs. Enforced keys catch typos
on state updates and give dialyzer a concrete type to check against
instead of map() in every handle_* clause.

Is' nested login_params and packet_stats are extracted to their own
modules (Aprsme.Is.LoginParams, Aprsme.Is.PacketStats) rather than
defined inline, per the project's no-nested-modules rule.
2026-04-21 10:26:20 -05:00

16 lines
494 B
Elixir

defmodule Aprsme.Is.PacketStats do
@moduledoc false
defstruct total_packets: 0,
last_packet_at: nil,
packets_per_second: 0,
last_second_count: 0,
last_second_timestamp: 0
@type t :: %__MODULE__{
total_packets: non_neg_integer(),
last_packet_at: DateTime.t() | nil,
packets_per_second: non_neg_integer(),
last_second_count: non_neg_integer(),
last_second_timestamp: integer()
}
end