Switched the GitHub API to use a simple Gateway module#1138
Merged
Switched the GitHub API to use a simple Gateway module#1138
Conversation
joshsmith
previously approved these changes
Oct 30, 2017
| |> Enum.map(&marshall_response/1) | ||
| |> Enum.map(&Tuple.to_list/1) | ||
| |> Enum.map(&List.last/1) | ||
| |> List.flatten |
Contributor
There was a problem hiding this comment.
I just read (oddly in benchee's README) that Enum.map |> List.flatten is 1.83x slower than Enum.flat_map. Wonder if we should use that instead here?
| end | ||
| end | ||
| defp marshall_response({:ok, 404, _headers, body}) do | ||
| defp marshall_response({:ok, %Response{body: body, status_code: 404}}) do |
| end | ||
| defp marshall_response({:error, %Error{reason: reason}}) do | ||
| {:error, HTTPClientError.new(reason: reason)} | ||
| end |
| last = '<two-pages/?page=2>; rel="last"' | ||
|
|
||
| headers = [{"Link", [next, last] |> Enum.join(", ")}] | ||
| {:ok, %HTTPoison.Response{headers: headers, status_code: 200}} |
Contributor
Replaced API.EagerAPI with decoupled set of helper functions to be used from within API
205fc69 to
8b6d5a4
Compare
joshsmith
approved these changes
Oct 30, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1131,
Progress on #1132
This PR
API.Gatewaymodule from out ofGitHub.APIAPI.EagerAPIintoAPI.Pagination, which is a module containing a set of utility functions to be used fromAPI, soGatewayis only ever called fromAPIAPI.get_allso it uses a:headrequest first, to further consolidate and decouple