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

Wrap asynchronous responses with Stream #5

Open
secretworry opened this issue Jul 30, 2016 · 1 comment
Open

Wrap asynchronous responses with Stream #5

secretworry opened this issue Jul 30, 2016 · 1 comment

Comments

@secretworry
Copy link
Collaborator

Here's the talk on using Stream to wrap the async response.

For now, the async response is assembled by the maxwell to form a whole block before actually respond to the user. While the async interfaces of underlying adapters are suppose to be used for the streaming scenarios.

So naturally, we are suppose to wrap the response with a Stream.

@bitwalker bitwalker changed the title Use elixir Stream to wrap the async response Wrap asynchronous responses with Stream Jan 16, 2017
@bitwalker
Copy link
Collaborator

This should be fairly easy to implement, but I think there are some associated changes involved as well. Namely deprecating get_resp_body/2, as it won't work with this change, and I believe it is error-prone anyway, not to mention the fact that users can trivially implement what it does, and more correctly for their use case, in their own code. get_resp_body/1 can then ensure that a binary is always returned (or whatever datastructure it was decoded into by one of the middlewares). If it's a Stream when get_resp_body/1 is called, it can evaluate the stream and return the binary, otherwise it can return a binary or other datastructure as it does today. Likewise, we should update the JSON middlewares to evaluate the Stream and parse it (I believe Poison already supports streamed parsing, so it may be a simple change), but there's the question of custom parsing functions to think about.

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

2 participants