Config: use runtime deps instead of module attributes
Speeds up recompilation time by breaking compile-time cycles
This commit is contained in:
parent
b221d77a6d
commit
32d263cb90
2 changed files with 35 additions and 31 deletions
|
@ -3,7 +3,8 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Config.Loader do
|
defmodule Pleroma.Config.Loader do
|
||||||
@reject_keys [
|
defp reject_keys,
|
||||||
|
do: [
|
||||||
Pleroma.Repo,
|
Pleroma.Repo,
|
||||||
Pleroma.Web.Endpoint,
|
Pleroma.Web.Endpoint,
|
||||||
:env,
|
:env,
|
||||||
|
@ -12,7 +13,8 @@ defmodule Pleroma.Config.Loader do
|
||||||
:swarm
|
:swarm
|
||||||
]
|
]
|
||||||
|
|
||||||
@reject_groups [
|
defp reject_groups,
|
||||||
|
do: [
|
||||||
:postgrex,
|
:postgrex,
|
||||||
:tesla
|
:tesla
|
||||||
]
|
]
|
||||||
|
@ -52,7 +54,7 @@ defp filter(configs) do
|
||||||
@spec filter_group(atom(), keyword()) :: keyword()
|
@spec filter_group(atom(), keyword()) :: keyword()
|
||||||
def filter_group(group, configs) do
|
def filter_group(group, configs) do
|
||||||
Enum.reject(configs[group], fn {key, _v} ->
|
Enum.reject(configs[group], fn {key, _v} ->
|
||||||
key in @reject_keys or group in @reject_groups or
|
key in reject_keys() or group in reject_groups() or
|
||||||
(group == :phoenix and key == :serve_endpoints)
|
(group == :phoenix and key == :serve_endpoints)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,8 @@ defmodule Pleroma.Config.TransferTask do
|
||||||
|
|
||||||
@type env() :: :test | :benchmark | :dev | :prod
|
@type env() :: :test | :benchmark | :dev | :prod
|
||||||
|
|
||||||
@reboot_time_keys [
|
defp reboot_time_keys,
|
||||||
|
do: [
|
||||||
{:pleroma, :hackney_pools},
|
{:pleroma, :hackney_pools},
|
||||||
{:pleroma, :chat},
|
{:pleroma, :chat},
|
||||||
{:pleroma, Oban},
|
{:pleroma, Oban},
|
||||||
|
@ -24,7 +25,8 @@ defmodule Pleroma.Config.TransferTask do
|
||||||
{:pleroma, :connections_pool}
|
{:pleroma, :connections_pool}
|
||||||
]
|
]
|
||||||
|
|
||||||
@reboot_time_subkeys [
|
defp reboot_time_subkeys,
|
||||||
|
do: [
|
||||||
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
||||||
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
||||||
{:pleroma, :instance, [:upload_limit]},
|
{:pleroma, :instance, [:upload_limit]},
|
||||||
|
@ -165,12 +167,12 @@ def pleroma_need_restart?(group, key, value) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp group_and_key_need_reboot?(group, key) do
|
defp group_and_key_need_reboot?(group, key) do
|
||||||
Enum.any?(@reboot_time_keys, fn {g, k} -> g == group and k == key end)
|
Enum.any?(reboot_time_keys(), fn {g, k} -> g == group and k == key end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp group_and_subkey_need_reboot?(group, key, value) do
|
defp group_and_subkey_need_reboot?(group, key, value) do
|
||||||
Keyword.keyword?(value) and
|
Keyword.keyword?(value) and
|
||||||
Enum.any?(@reboot_time_subkeys, fn {g, k, subkeys} ->
|
Enum.any?(reboot_time_subkeys(), fn {g, k, subkeys} ->
|
||||||
g == group and k == key and
|
g == group and k == key and
|
||||||
Enum.any?(Keyword.keys(value), &(&1 in subkeys))
|
Enum.any?(Keyword.keys(value), &(&1 in subkeys))
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue