fix: Add EmptyClusterStrategy for test mode
This commit is contained in:
parent
19cf61c84a
commit
850c764b7a
2 changed files with 31 additions and 0 deletions
24
apps/core/test/support/empty_cluster_strategy.ex
Normal file
24
apps/core/test/support/empty_cluster_strategy.ex
Normal 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
|
|
@ -41,3 +41,10 @@ config :core, Legendary.CoreMailer, adapter: Bamboo.TestAdapter
|
||||||
config :content, Oban, crontab: false, queues: false, plugins: false
|
config :content, Oban, crontab: false, queues: false, plugins: false
|
||||||
|
|
||||||
config :logger, level: :warn
|
config :logger, level: :warn
|
||||||
|
|
||||||
|
config :libcluster,
|
||||||
|
topologies: [
|
||||||
|
erlang_hosts: [
|
||||||
|
strategy: Legendary.Core.Cluster.EmptyClusterStrategy
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in a new issue