fix: Add EmptyClusterStrategy for test mode

This commit is contained in:
Robert Prehn 2021-05-18 16:50:20 -05:00
parent 19cf61c84a
commit 850c764b7a
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,24 @@
defmodule Legendary.Core.Cluster.EmptyClusterStrategy do
@moduledoc """
A libcluster nil strategy that always returns no nodes.
"""
use GenServer
use Cluster.Strategy
alias Cluster.Strategy.State
def start_link([%State{} = state]) do
new_state = %State{state | :meta => []}
GenServer.start_link(__MODULE__, [new_state])
end
@impl true
def init([state]) do
{:ok, state, :infinity}
end
@impl true
def handle_info(_, state) do
{:noreply, state, :infinity}
end
end

View file

@ -41,3 +41,10 @@ config :core, Legendary.CoreMailer, adapter: Bamboo.TestAdapter
config :content, Oban, crontab: false, queues: false, plugins: false
config :logger, level: :warn
config :libcluster,
topologies: [
erlang_hosts: [
strategy: Legendary.Core.Cluster.EmptyClusterStrategy
]
]