logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: f2b0d5f1d02e243a7a1a6f339b59e5abcb8e1bd8
parent 3474b42ce396150b21f26ed35bea46ad61f57d5f
Author: Mark Felder <feld@feld.me>
Date:   Sun, 26 May 2024 14:11:41 -0400

Make it easier to read the state for debugging purposes and expose functions for testing

Diffstat:

Mlib/pleroma/search/healthcheck.ex16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/pleroma/search/healthcheck.ex b/lib/pleroma/search/healthcheck.ex @@ -32,7 +32,7 @@ defmodule Pleroma.Search.Healthcheck do urls = Pleroma.Search.healthcheck_endpoints() new_state = - if healthy?(urls) do + if check(urls) do Oban.resume_queue(queue: @queue) Map.put(state, :healthy, true) else @@ -47,15 +47,15 @@ defmodule Pleroma.Search.Healthcheck do end @impl true - def handle_call(:check, _from, state) do - status = Map.get(state, :healthy) - - {:reply, status, state, :hibernate} + def handle_call(:state, _from, state) do + {:reply, state, state, :hibernate} end - defp healthy?([]), do: true + def state, do: GenServer.call(__MODULE__, :state) + + def check([]), do: true - defp healthy?(urls) when is_list(urls) do + def check(urls) when is_list(urls) do Enum.all?( urls, fn url -> @@ -67,7 +67,7 @@ defmodule Pleroma.Search.Healthcheck do ) end - defp healthy?(_), do: true + def check(_), do: true defp tick do Process.send_after(self(), :check, @tick)