Use dedicated http client pool for MusicBrainz
This commit is contained in:
@@ -249,7 +249,7 @@ defmodule MusicBrainz.APIImpl do
|
|||||||
|
|
||||||
Logger.debug("Fetching data from #{url}")
|
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} when response.status == 200 ->
|
||||||
{:ok, Jason.decode!(response.body)}
|
{:ok, Jason.decode!(response.body)}
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ defmodule MusicBrainz.APIImpl do
|
|||||||
|
|
||||||
Logger.debug("Fetching data from #{url}")
|
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} when response.status == 200 ->
|
||||||
{:ok, response.body}
|
{:ok, response.body}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -10,11 +10,11 @@ defmodule MusicLibrary.Application do
|
|||||||
children = [
|
children = [
|
||||||
MusicLibraryWeb.Telemetry,
|
MusicLibraryWeb.Telemetry,
|
||||||
MusicLibrary.Repo,
|
MusicLibrary.Repo,
|
||||||
{Finch, name: MusicLibrary.Finch},
|
|
||||||
{Ecto.Migrator,
|
{Ecto.Migrator,
|
||||||
repos: Application.fetch_env!(:music_library, :ecto_repos), skip: skip_migrations?()},
|
repos: Application.fetch_env!(:music_library, :ecto_repos), skip: skip_migrations?()},
|
||||||
{DNSCluster, query: Application.get_env(:music_library, :dns_cluster_query) || :ignore},
|
{DNSCluster, query: Application.get_env(:music_library, :dns_cluster_query) || :ignore},
|
||||||
{Phoenix.PubSub, name: MusicLibrary.PubSub},
|
{Phoenix.PubSub, name: MusicLibrary.PubSub},
|
||||||
|
MusicBrainz.Supervisor,
|
||||||
{LastFm.Supervisor, last_fm_config()},
|
{LastFm.Supervisor, last_fm_config()},
|
||||||
# Start a worker by calling: MusicLibrary.Worker.start_link(arg)
|
# Start a worker by calling: MusicLibrary.Worker.start_link(arg)
|
||||||
# {MusicLibrary.Worker, arg},
|
# {MusicLibrary.Worker, arg},
|
||||||
|
|||||||
Reference in New Issue
Block a user