-
-
Notifications
You must be signed in to change notification settings - Fork 387
Description
We should have something that's just a smidge higher level than trio.socket. This is something that could go into an external library, but:
- I'd like to do TLS at this layer (so it's not bound to socket objects specifically), and in 2017 it really feels like TLS should be an included battery
- Getting started with a simple echo server shouldn't require boilerplate or third-party extensions
- I'm feeling the need for a basic stream abstraction in downstream libraries, and there are interoperability benefits to defining that in
trioitself
The goal wouldn't be to compete with like, all of netty or twisted or something, but just to provide some minimal extensible abstractions for endpoints, connecting, listening. Maybe UDP too, though that can wait.
Things that should be easy:
- Connecting to a given hostname+port, with ipv4/ipv6 taken care of (ideally with happy-eyeballs)
- ...same as above, but with TLS enabled
- Making a simple server that listens on both ipv4 and ipv6
- Making a simple server that listens on a unix domain port
Maybe:
- Plugging in some code to handle systemd socket activation
- Plugging in some code to do something sensible with the haproxy PROXY protocol
A source of inspiration is twisted's "endpoints": tutorial, list of client endpoints, list of server endpoints, a much fancier server endpoint. I'm not a big fan of the plugins + string parsing thing, just because of the whole injecting-arbitrary-code-into-people's-processes thing that plugins do ... though I see the advantage when it comes to exposing this stuff as part of a public interface and wanting it to be extensible there.
We probably want:
-
A basic Stream API. There's a sketch in
trio._streams. This is useful in its own right; the idea would be to implement TLS as a stream wrapper e.g., and we can use aSendStreamandRecvStreamfor subprocess pipes, etc. -
Some sort of connect and listen factories for streams.
Lots more TBD; for now this is a placeholder to think more about.
Related: #9 (tls support), #13 (more ergonomic server quick-start), #14 (batched accept), #72 (socket option defaults – some might make more sense to set as part of the high-level interface)