Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/tesla/adapter/finch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ if Code.ensure_loaded?(Finch) do

task =
Task.async(fn ->
case Finch.stream(req, name, nil, fun, opts) do
{:ok, _acc} -> send(owner, {ref, :eof})
{:error, error} -> send(owner, {ref, {:error, error}})
end
req
|> Finch.stream(name, nil, fun, opts)
|> handle_stream_response(ref, owner)
end)

receive do
Expand All @@ -153,5 +152,19 @@ if Code.ensure_loaded?(Finch) do
{:error, :timeout}
end
end

defp handle_stream_response({:ok, _acc}, ref, owner) do
send(owner, {ref, :eof})
end

if Application.spec(:finch, :vsn) >= ~c"0.20.0" do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm late, but:

iex(2)> ~c"0.3.0" >= ~c"0.20.0"
true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice catch, and TIL about the Version module in the stdlib that seems ideal for this. I'll whip up a fix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 💜

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defp handle_stream_response({:error, error, _acc}, ref, owner) do
send(owner, {ref, {:error, error}})
end
else
defp handle_stream_response({:error, error}, ref, owner) do
send(owner, {ref, {:error, error}})
end
end
end
end
Loading