I'm not opposed to a fresh syntax, but I do believe the current implementation can be used for composition. The parser for endpoint strings is simplistic, like Glyph points out, but there is nothing preventing it from having nested endpoint definitions. We used the existing syntax when writing the HAProxy endpoint wrapper: https://github.com/twisted/twisted/blob/trunk/src/twisted/protocols/haproxy/_parser.py.

Granted, this case doesn't come with any configuration options but it shows a potential path for adding wrapping functionality in the current implementation. I think are some downsides when it comes to args, kwargs management. To support them across multiple, arbitrary nested endpoints the kwargs would need to have non-colliding names and the wrapper would need to do some amount of introspection on args to determine if the leading values are for it or another endpoint. 

I don't think the developer experience would be a good one, but there _is_ a way to compose endpoints if you're set on doing so.

On Tue, Sep 6, 2016 at 6:08 PM Glyph Lefkowitz <glyph@twistedmatrix.com> wrote:

On Sep 6, 2016, at 11:55 AM, Tristan Seligmann <mithrandi@mithrandi.net> wrote:

Currently there is no way to explicitly compose Twisted endpoints, but several endpoint implementations have arisen that explicitly wrap another endpoint, and so have needed a way to do this. So far, this has been implementing by passing in an endpoint description, and then calling serverFromString/clientFromString internally in the endpoint to construct the wrapped endpoint. I've seen two different ways of encoding the "inner" endpoint:


Some other points to keep in mind for this discussion:

  1. We may want a syntax that supports composing multiple endpoints, not just 2.
  2. The existing syntax is kind of crummy; ":" as a separator has serious problems, considering its presence in both URLs and IPv6 literals.  I wouldn't say we should necessarily re-design the whole syntax to accommodate this, but just having a whole new syntax might not be a bad thing either.

-glyph
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python