{{ message }}
Repository navigation
Add support for streaming request and response bodies - #2750
Closed
trumpetinc wants to merge 12 commits into
Closed
trumpetinc wants to merge 12 commits into
trumpetinc wants to merge 12 commits into
Conversation
Collaborator
Author
Collaborator
Author
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.

Reference issue: #2734
This is an initial update that changes request and response handling to use streams instead of in-memory byte arrays. Streams are retriable (up to some amount of reading).
IMPORTANT: This is a breaking change for Feign encoders/decoders/clients, so the impact could be high on 3rd parties. These changes should be completely transparent to regular users of Feign.
The general approach is to factor request and response bodies into a single interface (HttpBody) that supports resettable streaming (within some buffered limit if the data source is not inherently seekable). We also now tracking encoding information in the HttpBody itself, which has dramatically reduced the non-deprecated API footprint.
To demonstrate this streaming functionality, I have added encoders and decoders for handling typical stream-oriented body types (see /core/src/main/java/feign/stream/InputStreamAndFileEncoder.java and /core/src/main/java/feign/stream/InputStreamAndReaderDecoder.java I suspect that eventually these encoders/decoders will be broken out of the core library.
Some notes on the sate of this branch's code:
There are many methods that I have marked as @deprecated - there is a lot of cruft related to request and response bodies now, and it would be good to clean that out at some point - but this could result in more breaking changes.
All of the Feign core unit tests are working. I have not attempted to propagate changes into the other Feign modules as I want to make sure that the approach and design are accepted first. There are many areas of the code base that have pending to-do items (//TODO: KD - xxxxxxx) and I expect there be some discussion about those - but for now, I'd like to focus on the overall approach.
At this point, things are "working" - but I would benefit from a discussion about whether the approach is sound, and if it is, I will start a discussion about some of the bigger TODO items that I have tagged.