Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/apps/indexer/lib/indexer/application.ex

55 lines
1.9 KiB

defmodule Indexer.Application do
@moduledoc """
This is the `Application` module for `Indexer`.
"""
use Application
alias Indexer.Fetcher.{CoinBalanceOnDemand, FirstTraceOnDemand, TokenTotalSupplyOnDemand}
alias Indexer.Memory
alias Indexer.Prometheus.PendingBlockOperationsCollector
alias Prometheus.Registry
@impl Application
def start(_type, _args) do
Registry.register_collector(PendingBlockOperationsCollector)
memory_monitor_options =
case Application.get_env(:indexer, :memory_limit) do
nil -> %{}
integer when is_integer(integer) -> %{limit: integer}
end
memory_monitor_name = Memory.Monitor
json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments)
pool_size =
Application.get_env(:indexer, Indexer.Fetcher.TokenInstance.Retry)[:concurrency] +
Application.get_env(:indexer, Indexer.Fetcher.TokenInstance.Realtime)[:concurrency] +
Application.get_env(:indexer, Indexer.Fetcher.TokenInstance.Sanitize)[:concurrency]
base_children = [
:hackney_pool.child_spec(:token_instance_fetcher, max_connections: pool_size),
{Memory.Monitor, [memory_monitor_options, [name: memory_monitor_name]]},
{CoinBalanceOnDemand.Supervisor, [json_rpc_named_arguments]},
{TokenTotalSupplyOnDemand.Supervisor, []},
{FirstTraceOnDemand.Supervisor, [json_rpc_named_arguments]}
]
children =
if Application.get_env(:indexer, Indexer.Supervisor)[:enabled] do
Enum.reverse([{Indexer.Supervisor, [%{memory_monitor: memory_monitor_name}]} | base_children])
else
base_children
end
opts = [
# If the `Memory.Monitor` dies, it needs all the `Shrinkable`s to re-register, so restart them.
strategy: :rest_for_one,
name: Indexer.Application
]
Supervisor.start_link(children, opts)
end
end