Description
I propose collaborating on reactive, stream oriented Java APIs for common network protocols. It would primarily consist of interfaces, not concrete implementations, but could have some abstract/concrete classes such as HttpResponse
, Cookie
, StatusCode
and other such utilities common to a protocol.
I am interested in network APIs for both client and server for TCP, UDP, HTTP/1, HTTP/2, WebSockets, SSE, etc as well as Reactive Streams IO (RS.io) when it exists. I and colleagues like @NiteshKant have been exploring these APIs at Netflix and interacting with others such as @jbrisbin and @smaldini to see if these APIs make sense standardized or not. We can obviously create them on our own, but they feel so similar to what each of us keep defining, I'm curious as to whether there is value in have standardized RS Network APIs (RS.net).
The proposed value would be that different underlying transport implementations could expose the same RS Network APIs that different RS implementations could all consume.
For example, with HTTP/1, we all need to model these things:
- request headers and body
- response headers and body
- mime/content types
- status codes
- etc
Using Reactive Streams, an HTTP/1 response is most like something like this:
Publisher<HttpResponse<T>> response = submitGet(...);
The HttpResponse
then would have the status codes, headers, etc and expose the body as another Publisher
, something perhaps like this:
Publisher<T> content = httpResponse.getContent();
There are only so many ways that these various network protocols can be combined with RS since RS is defined, and the protocols are defined.
If these RS.net interfaces existed, then a networking library like Akka.io, Spray, Netty, etc could implement the transport layer however it deems best and expose the various protocols using RS.net interfaces.
Then consumers could use existing bindings for Akka Streams, RxJava, Reactor etc for consuming, transforming and composing the IO.
I see value in this layer of abstraction between transport implementations and stream implementations and will end up building it for my needs. Before I do it on my own I want to find out if others see value in this and would like to participate.