Re: [PATCH] client-side redesign pt1 - Comm::TcpReceiver

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Fri, 24 Jan 2014 11:13:26 -0700

On 01/23/2014 02:34 AM, Amos Jeffries wrote:
> On 22/01/2014 10:32 p.m., Henrik Nordström wrote:
>> Any design that tries to make application level code (i.e. http/ftp
>> protocol handlers etc) needing to be aware of TcpReceiver/Sender is
>> plain wrong imho.

> Yes. I was loosely thinking of completing this TcpAgent then working on
> TlsAgent, etc. with the same interface methods. COAPS and UDP I/O
> streams are also on the wishlist as other *Agent types.

Based on Squid and Polygraph experience, TcpAgent, TlsAgent, and
UdpAgent is the wrong approach here. What you need is an Agent that is
given the right ConnLayer, Transport, or Stream object (we do not have a
name for that transport layering object yet; I am using Transport below):

Agent: Common base for Client and Server agents. Uses Transport.
Client: Common base for HttpClient, FtpClient, IcapClient, etc.
Server: Common base for HttpServer, FtpServer, etc.
HttpClient: Sends HTTP requests. Receives HTTP responses.
FtpServer: Receives FTP commands. Sends FTP replies.
...

TransportLayer: Common base for TcpLayer, SslLayer, and other layers.
TcpLayer: A final TransportLayer using a TCP socket Comm APIs for I/O.
SslLayer: A TransportLayer using another TransportLayer for I/O.
...

Transport: Contains one or more ConnLayers. Handles I/O multi-layering.

Connection: A socket with a peer address. We have that already.

> With Alex proposal to merge the Comm::Write API into these fully I think
> we have a good design to go forward with that can be spread across all
> those transport types relatively easily.

I have not proposed merging Comm::Write with anything AFAIK. In my
proposal, the TcpAgent class manages both reading and writing using
existing Comm APIs.

To address Henrik's concerns on top of that, you get an Agent class that
does both reading and writing using Transport. Transport objects may
have several layers, with final layers doing I/O using existing Comm APIs.

HTH,

Alex.
Received on Fri Jan 24 2014 - 18:13:44 MST

This archive was generated by hypermail 2.2.0 : Sat Jan 25 2014 - 12:00:13 MST