chore: Update hackney pool size: add new fetchers accounting (#9941)

mf-only-health-webapp
nikitosing 6 months ago committed by GitHub
parent 5bbf68e756
commit 64b55faea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 36
      apps/indexer/lib/indexer/application.ex

@ -29,9 +29,21 @@ defmodule Indexer.Application do
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]
token_instance_fetcher_pool_size(
Indexer.Fetcher.TokenInstance.Realtime,
Indexer.Fetcher.TokenInstance.Realtime.Supervisor
) +
token_instance_fetcher_pool_size(
Indexer.Fetcher.TokenInstance.Retry,
Indexer.Fetcher.TokenInstance.Retry.Supervisor
) +
token_instance_fetcher_pool_size(
Indexer.Fetcher.TokenInstance.Sanitize,
Indexer.Fetcher.TokenInstance.Sanitize.Supervisor
) +
token_instance_fetcher_pool_size(Indexer.Fetcher.TokenInstance.LegacySanitize, nil) +
token_instance_fetcher_pool_size(Indexer.Fetcher.TokenInstance.SanitizeERC1155, nil) +
token_instance_fetcher_pool_size(Indexer.Fetcher.TokenInstance.SanitizeERC721, nil)
base_children = [
:hackney_pool.child_spec(:token_instance_fetcher, max_connections: pool_size),
@ -57,4 +69,22 @@ defmodule Indexer.Application do
Supervisor.start_link(children, opts)
end
defp token_instance_fetcher_pool_size(fetcher, nil) do
envs = Application.get_env(:indexer, fetcher)
if envs[:enabled] do
envs[:concurrency]
else
0
end
end
defp token_instance_fetcher_pool_size(fetcher, supervisor) do
if Application.get_env(:indexer, supervisor)[:disabled?] do
0
else
Application.get_env(:indexer, fetcher)[:concurrency]
end
end
end

Loading…
Cancel
Save