reactive-streams / reactive-streams-net-jvm

Reactive Network APIs for the JVM
Other
7 stars 3 forks source link

TCP client API #2

Open NiteshKant opened 9 years ago

NiteshKant commented 9 years ago

This issue is for discussing API for a TCP client.

Intention

To define how TCP must be modeled from a client point of view, using reactive-streams-jvm SPI.

What it is?

An abstraction over:

In general it should not try to arbitrate different standards across different networking libraries. A few examples of that being:

Although, this API does not intend to arbitrate different standards across different networking libraries, we should not impede the implementations from implementing them effectively. So, as a part of this exercise, it will be good to identify various higher level requirements from such a client and see that our design is not impeding those implementations. A few things that may be of value to consider are:

It would be good to discuss how an implementation could be using this API?

If we happen to model our TCPClient as:

public interface TcpClient<R, W> {

    Publisher<TcpConnection<R, W>> connect(SocketAddress remoteAddress);

}

would a Netty implementation look like:

public class NettyTcpClient<R, W> implements TcpClient<R, W> {

    Publisher<TcpConnection<R, W>> connect(SocketAddress remoteAddress);

}

or would this be hidden around another interface like:

public interface NettyTcpClient<R, W>  extends TcpClient<R, W> {

    // Other methods

}

Furthermore, how would an implementation of reactive streams like RxJava layer on top of it?

Would it be like:

public interface RxJavaTcpClient<R, W>  {

    Observable<TcpConnection<R, W>> connect(SocketAddress remoteAddress);

}

or

         RxTcpClient.from(TcpClient<R, W> client);

which gives an adapter over any TcpClient implementation.

The intention of these questions is to be aware of usage of this API.

viktorklang commented 9 years ago

Would it make more sense to start from the protocol level rather than the programmer API level? How does multiplexing work, how does connection close event get detected, how are RSTs dealt with etc. Thoughts @toddlmontgomery?