haskell-distributed / network-transport-tcp

TCP Realisation of Network.Transport
http://haskell-distributed.github.com
BSD 3-Clause "New" or "Revised" License
30 stars 27 forks source link

General, parametric queueing/buffering for an EndPoint #47

Closed avieth closed 7 years ago

avieth commented 7 years ago

This is related to #46 but is a bit of a departure because it introduces features that don't exactly fit the model of network-transport. It gives a parametric QDisc t, which takes in network-transport Events and yields some values of type t. It can be specialized to Event, as in simpleUnboundedQDisc :: QDisc Event, to give the typical network-transport EndPoint. But it can also be used to give a different kind of EndPoint: a TCPEndPoint t which uses the QDisc t to get a t when you call tcpReceive :: TCPEndPoint t -> IO t.

Included is an example of how it might be used. network-transport Events are converted into EndPointEvents which differ mainly in the fact that there are no Received or ConnectionClosed events. Instead, the PeerOpenedConnection event includes a buffer for the input on that connection. This QDisc EndPointEvent is parametrized on bounds for its buffers. A thread can be spawned to clear this buffer and do whatever it is the application must do. Input from the peer at the other end of that connection is controlled by how fast the thread can clear the buffer. If the buffer fills up faster than the handler can clear it then eventually the peer will feel the latency as we stop reading from its socket.

dcoutts commented 7 years ago

@avieth we can close this issue right? We're most likely going with the simpler approach (and can re-open if we change our minds).

avieth commented 7 years ago

@avieth we can close this issue right? We're most likely going with the simpler approach (and can re-open if we change our minds).

Yes indeed