haxetink / tink_tcp

TCP everywhere!
MIT License
13 stars 6 forks source link

API overhaul. #5

Open back2dos opened 8 years ago

back2dos commented 8 years ago

I would like to overhaul the API to be more like tink_http, where the core interfaces are really just interfaces (i.e. Client and Container).

So basically something like this:

interface Client {
  function connect(to:Endpoint):Surprise<Connection, Error>;
}

interface OpenPort {
  var connected(get, null):Signal<Connection>;
  function close():Surprise<Noise, Error>;
}

It's generally nicer for mocking and such. It also feels more consistent with tink_http. Technically, one could even build really crazy things, like a tcp multiplexer, that you connect your client to, with a single connection, that will then open a port for you and multiplex all inbound connections onto the one between your client and your server, thus allowing you to run the actual server logic down on your client (may be a silly idea to start with, but I kind of like silly ideas).

This doesn't have very high priority, but my hope is to get tink_http and all of its dependencies to 1.0.0 by the end of august or so, in which case I'd like this API to be stable (the implementation is a whole different story).

benmerckx commented 7 years ago

Is this still planned? I've added php implementations for connection and server (not entirely useful, but I wanted to try). Doing so I think the connection and server files should be split up, like tink_http clients need to be. But it doesn't seem so useful if the api will change anyway.

back2dos commented 7 years ago

Ah, yes, never mind my ramblings. This is still planned but should not stand in your way. To the contrary: each implementation is a great lesson on how to design the API :D