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

Introduce Tesla.client/1 & Tesla.client/2 #244

Merged
merged 5 commits into from
Sep 7, 2018
Merged

Introduce Tesla.client/1 & Tesla.client/2 #244

merged 5 commits into from
Sep 7, 2018

Conversation

teamon
Copy link
Member

@teamon teamon commented Sep 7, 2018

This is first part of #240

  • Introduced Tesla.client/1 & Tesla.client/2 to configure client in runtime
  • Deprecate Tesla.build_client & Tesla.build_adapter

@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #244 into master will decrease coverage by 0.23%.
The diff coverage is 80%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/tesla/builder.ex 100% <100%> (ø) ⬆️
lib/tesla.ex 85.1% <75%> (-2.4%) ⬇️
lib/tesla/middleware/timeout.ex 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f060f04...f65cdd9. Read the comment docs.

@teamon teamon requested a review from amatalai September 7, 2018 13:01
@teamon teamon added this to the 1.2 milestone Sep 7, 2018
@teamon teamon mentioned this pull request Sep 7, 2018
Copy link

@jcabotc jcabotc left a 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()}
Copy link

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.

@@ -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
Copy link

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.

@elixir-tesla elixir-tesla deleted a comment from codecov bot Sep 7, 2018
lib/tesla.ex Outdated

# configure adapter in runtime
client = Tesla.client([], Tesla.Adapter.Hackney)
client = Tesla.client([], {Tesla.Adapter.Hackney, pool: :my_pool)
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing }

@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #244 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/tesla/middleware/digest_auth.ex 100% <ø> (ø) ⬆️
lib/tesla/middleware/basic_auth.ex 100% <ø> (ø) ⬆️
lib/tesla/migration.ex 95.65% <ø> (ø) ⬆️
lib/tesla.ex 87.5% <100%> (ø) ⬆️
lib/tesla/builder.ex 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f060f04...2ae56f8. Read the comment docs.

@teamon teamon merged commit 6e74309 into master Sep 7, 2018
@teamon teamon deleted the tesla-client branch September 7, 2018 14:34
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.

3 participants