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

feat: override adapter at OTP app level #640

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

c4710n
Copy link

@c4710n c4710n commented Dec 19, 2023

Thanks for all your hard works, Tesla already has great support on choosing adapter at different levels.

But, it still have one case that tesla doesn't support - override adapter at OTP app level.

This PR adds that feature, which is useful when we want to use different adapter for different OTP apps.


An example - I installed two packages from Hex:

  • foo, whose OTP app name is :foo, the underlying HTTP client is Tesla
  • bar, whose OTP app name is :bar, the underlying HTTP client is Tesla, too.

I want to use :finch as the adapter for them all, but due to some reason, I have to set HTTP proxy for bar. But, :finch doesn't support proxy, for now. So I have to use :hackney, which supports proxy.

With this PR, I can do something like:

config :telsa, :adapter, {Tesla.Adapter.Finch, name: MyFinch}
config :tesla, :bar, adapter: Tesla.Adapter.Hackney # override adapter for :bar in an easy way.

Feel free to comment. I can make any modifications necessary to ensure this PR is mergeable. ;)

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

Successfully merging this pull request may close these issues.

None yet

1 participant