- def init(args) do
- Process.send(self(), :run_update, [])
- {:ok, args}
- end
-
- def handle_call(:force_update, _from, _state) do
- new_stats = get_stat_data()
- {:reply, new_stats, new_stats}
- end
-
- def handle_call(:get_state, _from, state) do
- {:reply, state, state}
- end
-
- def handle_info(:run_update, _state) do
- new_stats = get_stat_data()
-
- Process.send_after(self(), :run_update, @interval)
- {:noreply, new_stats}
- end
-
- defp initial_data do
- %{peers: [], stats: %{}}
- end
-
- def get_stat_data do
+ @spec calculate_stat_data() :: %{
+ peers: list(),
+ stats: %{
+ domain_count: non_neg_integer(),
+ status_count: non_neg_integer(),
+ user_count: non_neg_integer()
+ }
+ }
+ def calculate_stat_data do