Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finch adapter #381

Closed
teamon opened this issue May 18, 2020 · 4 comments
Closed

Finch adapter #381

teamon opened this issue May 18, 2020 · 4 comments

Comments

@teamon
Copy link
Member

teamon commented May 18, 2020

A tiny adapter for https://github.com/keathley/finch - a HTTP client with built-in pooling.
Instead of building own mint+pooling adapter we could nicely integrate with Finch.

Something like this:

defmodule Tesla.Adapter.Finch do
  @behaviour Tesla.Adapter

  def call(env, opts) do
    opts = Tesla.Adapter.opts(env, opts)    
    case Finch.request(name, env.method, env.url, env.headers, env.body, opts) do
      {:ok, ...} ->  # convert finch's response to %Tesla.Env{}
      {:error, ...} -> # ensure proper error handling
    end
  end
end
@chulkilee
Copy link
Contributor

Note

Pools will be started for each configured {scheme, host, port} when Finch is started. For any unconfigured {scheme, host, port}, the pool will be started the first time it is requested. Note pools are not automatically terminated if they are unused, so Finch is best suited when you are requesting a known list of static hosts.

So I believe we need a way to trigger pruning unused pools (or a way to do it) from the library.

@c-manakov
Copy link

Hey. I'm trying my hand at implementing this adapter and I'm not sure what to do with multipart and streaming. Finch's API doesn't seem to support it even though Mint does.

@keathley
Copy link
Contributor

keathley commented Jun 5, 2020

@Monyk015 There is an open issue on finch to support a streaming API: https://github.com/keathley/finch/issues/58

@keathley
Copy link
Contributor

keathley commented Jun 9, 2020

@Monyk015 streaming support has been added to finch: https://github.com/keathley/finch/pull/59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants