Use dedicated http client pool for MusicBrainz

This commit is contained in:
Claudio Ortolina
2024-11-07 21:06:23 +00:00
parent 64193858a6
commit d8b7efeebc
3 changed files with 19 additions and 3 deletions
+2 -2
View File
@@ -249,7 +249,7 @@ defmodule MusicBrainz.APIImpl do
Logger.debug("Fetching data from #{url}")
case Finch.request(req, MusicLibrary.Finch) do
case Finch.request(req, MusicBrainz.Finch) do
{:ok, response} when response.status == 200 ->
{:ok, Jason.decode!(response.body)}
@@ -268,7 +268,7 @@ defmodule MusicBrainz.APIImpl do
Logger.debug("Fetching data from #{url}")
case Finch.request(req, MusicLibrary.Finch) do
case Finch.request(req, MusicBrainz.Finch) do
{:ok, response} when response.status == 200 ->
{:ok, response.body}
+16
View File
@@ -0,0 +1,16 @@
defmodule MusicBrainz.Supervisor do
use Supervisor
def start_link(config) do
Supervisor.start_link(__MODULE__, config, name: __MODULE__)
end
@impl true
def init(_config) do
children = [
{Finch, name: MusicBrainz.Finch}
]
Supervisor.init(children, strategy: :one_for_one)
end
end
+1 -1
View File
@@ -10,11 +10,11 @@ defmodule MusicLibrary.Application do
children = [
MusicLibraryWeb.Telemetry,
MusicLibrary.Repo,
{Finch, name: MusicLibrary.Finch},
{Ecto.Migrator,
repos: Application.fetch_env!(:music_library, :ecto_repos), skip: skip_migrations?()},
{DNSCluster, query: Application.get_env(:music_library, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: MusicLibrary.PubSub},
MusicBrainz.Supervisor,
{LastFm.Supervisor, last_fm_config()},
# Start a worker by calling: MusicLibrary.Worker.start_link(arg)
# {MusicLibrary.Worker, arg},