Use config to determine sending to the streamer registry instead of MIX_ENV compile time function definition
This commit is contained in:
parent
653b14e1c7
commit
6df93e61c4
|
@ -20,7 +20,6 @@ defmodule Pleroma.Web.Streamer do
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
alias Pleroma.Web.StreamerView
|
alias Pleroma.Web.StreamerView
|
||||||
|
|
||||||
@mix_env Mix.env()
|
|
||||||
@registry Pleroma.Web.StreamerRegistry
|
@registry Pleroma.Web.StreamerRegistry
|
||||||
|
|
||||||
def registry, do: @registry
|
def registry, do: @registry
|
||||||
|
@ -396,12 +395,13 @@ def close_streams_by_oauth_token(oauth_token) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# In test environment, only return true if the registry is started.
|
# In dev/prod the streamer registry is expected to be started, so return true
|
||||||
# In benchmark environment, returns false.
|
# In test it is possible to have the registry started for a test so it will check
|
||||||
# In any other environment, always returns true.
|
# In benchmark it will never find the process alive and return false
|
||||||
cond do
|
|
||||||
@mix_env == :test ->
|
|
||||||
def should_env_send? do
|
def should_env_send? do
|
||||||
|
if Application.get_env(:pleroma, Pleroma.Application)[:streamer_registry] do
|
||||||
|
true
|
||||||
|
else
|
||||||
case Process.whereis(@registry) do
|
case Process.whereis(@registry) do
|
||||||
nil ->
|
nil ->
|
||||||
false
|
false
|
||||||
|
@ -410,11 +410,5 @@ def should_env_send? do
|
||||||
Process.alive?(pid)
|
Process.alive?(pid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@mix_env == :benchmark ->
|
|
||||||
def should_env_send?, do: false
|
|
||||||
|
|
||||||
true ->
|
|
||||||
def should_env_send?, do: true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue