use of org.webpieces.router.impl.routeinvoker.RequestStreamWriter2 in project webpieces by deanhiller.
the class RequestResponseStream method openStream.
@Override
public RouterStreamRef openStream(MethodMeta meta, ProxyStreamHandle handle) {
boolean endOfStream = meta.getCtx().getRequest().originalRequest.isEndOfStream();
if (endOfStream) {
// If there is no body, just invoke to process OR IN CASE of InternalError or NotFound, there is NO need
// to wait for the request body and we can respond early, which stops wasting CPU of reading in their body
meta.getCtx().getRequest().body = DataWrapperGeneratorFactory.EMPTY;
XFuture<StreamWriter> invokeSvc = invoker.invokeSvc(meta, i18nBundleName, service, processor, handle).thenApply(voidd -> new NullWriter());
return new RouterStreamRef("reqRespStreamProxy", invokeSvc, null);
}
// At this point, we don't have the end of the stream so return a request writer that calls invoke when complete
RequestStreamWriter2 writer = new RequestStreamWriter2(requestBodyParsers, meta, (newInfo) -> invoker.invokeSvc(newInfo, i18nBundleName, service, processor, handle));
XFuture<StreamWriter> w = XFuture.completedFuture(writer);
return new RouterStreamRef("requestRespStream", w, null);
}
Aggregations