Add debugging and validation for cluster topologies

This commit is contained in:
Graham McIntire 2025-07-25 10:59:37 -05:00
parent 17f5a162aa
commit 35224327c0
No known key found for this signature in database

View file

@ -2,12 +2,28 @@ defmodule Aprsme.Cluster.Topology do
@moduledoc """
Wrapper for Cluster.Supervisor that only starts when clustering is enabled.
"""
require Logger
def child_spec(opts) do
if Application.get_env(:aprsme, :cluster_enabled, false) do
topologies = Application.get_env(:libcluster, :topologies, [])
supervisor_opts = Keyword.merge([name: Aprsme.ClusterSupervisor], opts)
{Cluster.Supervisor, [topologies, supervisor_opts]}
# Log the configuration for debugging
Logger.info("Cluster.Topology starting with topologies: #{inspect(topologies)}")
# Ensure we have valid topologies
if topologies == [] or topologies == nil do
Logger.warning("No libcluster topologies configured, clustering will not work")
# Return a no-op spec
%{
id: __MODULE__,
start: {__MODULE__, :start_link, [opts]},
type: :worker
}
else
supervisor_opts = Keyword.merge([name: Aprsme.ClusterSupervisor], opts)
{Cluster.Supervisor, [topologies, supervisor_opts]}
end
else
# Return a no-op spec when clustering is disabled
%{