You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feign was designed for control plane apis, which often don't benefit by streaming upwards. Streaming downwards is supported, though.
I've no concern with being more efficient with regards to how buffering works (ex. alternative to byte array). Just bear in mind that most of feign's design revolves around templating forms (json or xml) and reusing these as much as possible (ex. on retransmit, buffered + fixed length is easy and predictable).
I think I'd be most happy about a "streaming" design if it were coupled to the http client. IOTW, a subtype that addresses streaming in a way that makes sense in the transport. For example, InputStream for regular java, OkIo buffer for OkHttp, Netty ByteBuff for Netty, etc.
FWIW, what I'm thinking is that the body param would address streaming somehow.
Ex. when okhttp is installed, simply passing an okio buffer as a parameter would magically work.
The tricky part is implicitly getting a correct length or determining chunking. This is where things get complex, and an area I've hoped to avoid as dealing with control apis is complicated enough :)
from an extension POV, a feign Client could register the types it handles natively. These would override the encoder types and skip processing somehow.
@adriancole thanks for the response. I've ended up pushing feign beyond control plane apis :-) I like the idea of customizing the Client. Maybe the Type mapped to some kind of Handler to actually the processing.
yeah that might work. It could also be the case that we parameterize Client and Request with whatever the ideal string body is. This helps avoid the byte array dumping which was only there to support binary payloads. IOTW when we can handle binary parts (buffered or streaming), we can go back and fix the base case of just addressing strings.
Also, there will be a known set of profiles that work together as they all share types. We could try out making ideally integrated stacks. It would likely be less complex in the long run than a lot of extension points.
okhttp (http) + okio (buffers) + moshi (json)
rxnetty (http + buffer) + ?? (json that works well w/ByteBuff)
I think there are various requests coming in for aspects around buffering, non-blocking, streaming, and asynchronous invocation, but a solution that addresses them all needs to be chosen.
For example, RxNetty could, and choosing one stack to try this with reduces the work involved, plus risk of premature or over abstraction.
@jared2501 would RxNetty work for you? If not, what would?
@adriancole I came upon this thread looking to upload 5 GB+ files using Spring Cloud Feign. You mentioned okio.BufferedSource in a comment above, but it seems to be exact opposite of what I need. I don't want to buffer anything, just stream the InputStream to the destination. Looking at the source code of RequestTemplate, looks like the body has to be a byte[]. Any suggestions?
IMO, mixing up streaming support with async IO is delaying a solution; instead of gaining support for blocking but streaming upload, we have nothing even after 2 years 3 months now.
BufferedSource doesn't imply buffering the entire message. As
documented, it allows for read-ahead and other means to be more
efficient when putting things on the wire.
https://github.com/square/okio/blob/master/okio/src/main/java/okio/BufferedSource.java
At the moment, there's no workaround as the api wasn't designed for
large uploads. This means none of the plugins would work for that out
of the box. Progressing this would imply choosing a model to support
things. InputStream is one option, but in reality it is more likely a
callback to an outputstream or similar is what would be needed on the
output side.
I've re-titled the issue. Please refrain from arguing about things that don't impact this issue. Remember there are a couple hundred watchers on this repo and this type of conversation spams them.
Activity
codefromthecrypt commentedon Apr 13, 2015
pasting what I said on SO:
Feign was designed for control plane apis, which often don't benefit by streaming upwards. Streaming downwards is supported, though.
I've no concern with being more efficient with regards to how buffering works (ex. alternative to byte array). Just bear in mind that most of feign's design revolves around templating forms (json or xml) and reusing these as much as possible (ex. on retransmit, buffered + fixed length is easy and predictable).
I think I'd be most happy about a "streaming" design if it were coupled to the http client. IOTW, a subtype that addresses streaming in a way that makes sense in the transport. For example, InputStream for regular java, OkIo buffer for OkHttp, Netty ByteBuff for Netty, etc.
codefromthecrypt commentedon Apr 13, 2015
ps thanks.. I wasn't watching the
netflix-feigntag on SO!codefromthecrypt commentedon Apr 13, 2015
FWIW, what I'm thinking is that the body param would address streaming somehow.
Ex. when okhttp is installed, simply passing an okio buffer as a parameter would magically work.
The tricky part is implicitly getting a correct length or determining chunking. This is where things get complex, and an area I've hoped to avoid as dealing with control apis is complicated enough :)
codefromthecrypt commentedon Apr 13, 2015
from an extension POV, a feign Client could register the types it handles natively. These would override the encoder types and skip processing somehow.
ex.
Client.Defaultmight returnbyte[],InputStream.OkHttpClientmight returncom.squareup.okhttp.Request,okio.Buffer,okio.ByteStringetc.just thoughts..
spencergibb commentedon Apr 13, 2015
@adriancole thanks for the response. I've ended up pushing feign beyond control plane apis :-) I like the idea of customizing the Client. Maybe the
Typemapped to some kind ofHandlerto actually the processing.codefromthecrypt commentedon Apr 13, 2015
yeah that might work. It could also be the case that we parameterize Client and Request with whatever the ideal string body is. This helps avoid the byte array dumping which was only there to support binary payloads. IOTW when we can handle binary parts (buffered or streaming), we can go back and fix the base case of just addressing strings.
codefromthecrypt commentedon Apr 13, 2015
Also, there will be a known set of profiles that work together as they all share types. We could try out making ideally integrated stacks. It would likely be less complex in the long run than a lot of extension points.
okhttp (http) + okio (buffers) + moshi (json)
rxnetty (http + buffer) + ?? (json that works well w/ByteBuff)
wdyt? cc @NiteshKant @jdamick
spencergibb commentedon Apr 13, 2015
I like the integrated stacks idea as that is what I would want for spring.
jdamick commentedon Apr 14, 2015
yeah stacks would be good, i'm doing something similar to support multipart encoding or not, but it's not all that elegant at the moment.
jared2501 commentedon Mar 17, 2016
Any movement on this issue? Need this for a project I'm working on. Would be happy to look at contributing.
codefromthecrypt commentedon Mar 17, 2016
I think there are various requests coming in for aspects around buffering, non-blocking, streaming, and asynchronous invocation, but a solution that addresses them all needs to be chosen.
For example, RxNetty could, and choosing one stack to try this with reduces the work involved, plus risk of premature or over abstraction.
@jared2501 would RxNetty work for you? If not, what would?
jared2501 commentedon Mar 17, 2016
Hmm, I think @uschi2000 / @markelliot might have better opinions here than me on our use case.
ivansopin commentedon Mar 9, 2017
@adriancole, you said that
Can you provide an example? How does one currently enable streamed output, especially under JAXRSConstract?
codefromthecrypt commentedon Mar 9, 2017
asarkar commentedon Jul 20, 2017
@adriancole I came upon this thread looking to upload 5 GB+ files using Spring Cloud Feign. You mentioned
okio.BufferedSourcein a comment above, but it seems to be exact opposite of what I need. I don't want to buffer anything, just stream theInputStreamto the destination. Looking at the source code ofRequestTemplate, looks like the body has to be abyte[]. Any suggestions?IMO, mixing up streaming support with async IO is delaying a solution; instead of gaining support for blocking but streaming upload, we have nothing even after 2 years 3 months now.
codefromthecrypt commentedon Jul 21, 2017
phymbert commentedon Aug 21, 2017
Hello,
I submitted a new feature to support java8 streams in #586.
Please vote if it solves your issue.
asarkar commentedon Aug 21, 2017
@phymbert Java 8 stream and streaming upload are completely different things :(
phymbert commentedon Aug 21, 2017
@asarkar For sure, this is about streaming response as the original issue description, isn't
[-]Streaming support[/-][+]Support streaming uploads[/+]codefromthecrypt commentedon Aug 22, 2017
I've re-titled the issue. Please refrain from arguing about things that don't impact this issue. Remember there are a couple hundred watchers on this repo and this type of conversation spams them.