Skip to content

Commit

Permalink
Merge pull request #1 from Userpilot/adaptors-testing
Browse files Browse the repository at this point in the history
Support Finch adaptor
  • Loading branch information
MajdSehwail authored Sep 5, 2023
2 parents ca17670 + 3496e6c commit 02881ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/firestore/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ defmodule Firestore.Connection do
Tesla.client(middleware, http_adapter)
end

defp build_http_adapter(%{otp_app: _, tesla_adapter: :finch,name: name}),
do: {@http_adapters[:finch], [name: name]}

defp build_http_adapter(%{otp_app: _, tesla_adapter: adapter, pool_size: nil}),
do: {@http_adapters[adapter], []}

Expand All @@ -45,6 +48,7 @@ defmodule Firestore.Connection do
defp build_http_adapter(%{otp_app: _, tesla_adapter: :ibrowse, pool_size: pool_size}),
do: {@http_adapters[:ibrowse], [max_sessions: pool_size, max_pipeline_size: 1]}


defp build_http_adapter(%{tesla_adapter: adapter} = config) do
Logger.warning("Ignoring pool_size option as #{adapter} does not support it")

Expand Down
4 changes: 3 additions & 1 deletion lib/firestore/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ defmodule Firestore.Repo do
@tesla_adapter opts[:tesla_adapter]
@pool_size opts[:pool_size]
@read_only opts[:read_only]
#Used for Finch tesla adapter
@name opts[:name]

def config() do
@otp_app
|> Application.get_env(__MODULE__, [])
|> Keyword.merge(otp_app: @otp_app, tesla_adapter: @tesla_adapter, pool_size: @pool_size)
|> Keyword.merge(otp_app: @otp_app, tesla_adapter: @tesla_adapter, pool_size: @pool_size, name: @name)
|> Map.new()
end

Expand Down

0 comments on commit 02881ae

Please sign in to comment.