Resolve warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead lib/indexer/memory/monitor.ex:17: Indexer.Memory.Monitor

pull/7890/head
Viktor Baranov 1 year ago
parent 0d37b8d8a5
commit 7a67a98fa6
  1. 1
      CHANGELOG.md
  2. 13
      apps/indexer/lib/indexer/memory/monitor.ex

@ -25,6 +25,7 @@
### Chore
- [#7901](https://github.com/blockscout/blockscout/pull/7901) - Fix Docker image build
- [#7890](https://github.com/blockscout/blockscout/pull/7890) - Resolve warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
- [#7863](https://github.com/blockscout/blockscout/pull/7863) - Add max_age for account sessions
- [#7841](https://github.com/blockscout/blockscout/pull/7841) - CORS setup for docker-compose config with new frontend
- [#7832](https://github.com/blockscout/blockscout/pull/7832), [#7891](https://github.com/blockscout/blockscout/pull/7891) - API v2: Add block_number, block_hash to logs

@ -14,8 +14,7 @@ defmodule Indexer.Memory.Monitor do
alias Indexer.Memory.Shrinkable
defstruct limit: Application.get_env(:indexer, :memory_limit),
timer_interval: :timer.minutes(1),
defstruct timer_interval: :timer.minutes(1),
timer_reference: nil,
shrinkable_set: MapSet.new()
@ -62,11 +61,11 @@ defmodule Indexer.Memory.Monitor do
end
@impl GenServer
def handle_info(:check, %__MODULE__{limit: limit} = state) do
def handle_info(:check, state) do
total = :erlang.memory(:total)
if limit < total do
log_memory(%{limit: limit, total: total})
if memory_limit() < total do
log_memory(%{limit: memory_limit(), total: total})
shrink_or_log(state)
end
@ -169,4 +168,8 @@ defmodule Indexer.Memory.Monitor do
|> Enum.map(fn pid -> {pid, memory(pid)} end)
|> Enum.sort_by(&elem(&1, 1), &>=/2)
end
defp memory_limit do
Application.get_env(:indexer, :memory_limit)
end
end

Loading…
Cancel
Save