-
Notifications
You must be signed in to change notification settings - Fork 350
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
Introduce Tesla.client/1 & Tesla.client/2 #244
Conversation
Codecov Report
@@ Coverage Diff @@
## master #244 +/- ##
==========================================
- Coverage 95.46% 95.22% -0.24%
==========================================
Files 23 23
Lines 463 461 -2
==========================================
- Hits 442 439 -3
- Misses 21 22 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👌
lib/tesla.ex
Outdated
@@ -64,13 +64,18 @@ defmodule Tesla.Env do | |||
end | |||
|
|||
defmodule Tesla.Client do | |||
@type adapter :: atom | {atom, Tesla.Env.opts()} | |||
@type middleware :: atom | {atom, Tesla.Env.opts()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe module
(instead of atom
) is more descriptive here.
lib/tesla/builder.ex
Outdated
@@ -169,7 +169,9 @@ defmodule Tesla.Builder do | |||
end | |||
end | |||
|
|||
def client(pre, post), do: %Tesla.Client{pre: runtime(pre), post: runtime(post)} | |||
def client(pre, post, adapter \\ nil) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change it to something like:
def client(pre, post) do
%Tesla.Client{pre: runtime(pre), post: runtime(post)}
end
def client(pre, post, adapter) do
%Tesla.Client{pre: runtime(pre), post: runtime(post), adapter: runtime(adapter)}
end
and remove this line: https://github.com/teamon/tesla/pull/244/files#diff-a2c274aba9c954a50446941dc12ebd88R207
Otherwise nil
will be allowed as the list of middlewares.
lib/tesla.ex
Outdated
|
||
# configure adapter in runtime | ||
client = Tesla.client([], Tesla.Adapter.Hackney) | ||
client = Tesla.client([], {Tesla.Adapter.Hackney, pool: :my_pool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing }
Codecov Report
@@ Coverage Diff @@
## master #244 +/- ##
==========================================
+ Coverage 95.46% 95.48% +0.01%
==========================================
Files 23 23
Lines 463 465 +2
==========================================
+ Hits 442 444 +2
Misses 21 21
Continue to review full report at Codecov.
|
This is first part of #240
Tesla.client/1
&Tesla.client/2
to configure client in runtimeTesla.build_client
&Tesla.build_adapter