Fix Cluster.Supervisor child spec configuration
This commit is contained in:
parent
67e293c77c
commit
da589402af
1 changed files with 4 additions and 25 deletions
|
|
@ -1,13 +1,12 @@
|
||||||
defmodule Aprsme.Cluster.Topology do
|
defmodule Aprsme.Cluster.Topology do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Cluster topology configuration for different environments.
|
Wrapper for Cluster.Supervisor that only starts when clustering is enabled.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def child_spec(opts) do
|
def child_spec(opts) do
|
||||||
cluster_config = config()
|
if Application.get_env(:aprsme, :cluster_enabled, false) do
|
||||||
|
topologies = Application.get_env(:libcluster, :topologies, [])
|
||||||
if cluster_config do
|
{Cluster.Supervisor, [topologies, [name: Aprsme.ClusterSupervisor] ++ opts]}
|
||||||
{Cluster.Supervisor, [cluster_config, opts]}
|
|
||||||
else
|
else
|
||||||
# Return a no-op spec when clustering is disabled
|
# Return a no-op spec when clustering is disabled
|
||||||
%{
|
%{
|
||||||
|
|
@ -19,24 +18,4 @@ defmodule Aprsme.Cluster.Topology do
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_link(_opts), do: :ignore
|
def start_link(_opts), do: :ignore
|
||||||
|
|
||||||
defp config do
|
|
||||||
if Application.get_env(:aprsme, :cluster_enabled, false) do
|
|
||||||
kubernetes_config()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp kubernetes_config do
|
|
||||||
[
|
|
||||||
kubernetes: [
|
|
||||||
strategy: Cluster.Strategy.Kubernetes.DNS,
|
|
||||||
config: [
|
|
||||||
service: "aprs-headless",
|
|
||||||
application_name: "aprs",
|
|
||||||
namespace: "aprs",
|
|
||||||
polling_interval: 10_000
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue