PhutilChannel, a stream/pipe I/O wrapper
Summary:
I'm in the process of implementing a Mercurial daemon which uses "hg serve --cmdserver" to improve the performance of Mercurial operations.
The rough design of this server is a proxy server that speaks the cmdserver protocol, opens an hg server on one end (via normal pipes), and listens to multiple clients on the other end (a unix domain socket).
We don't have many PHP servers right now, so we're a little weak on abstractions. This is probably a bit over-engineered, but this server has two different components which speak the same protocol but have different underlying transports:
- The client speaks to a (proxied) cmdserver over a unix domain socket.
- The server speaks to a (real) cmdserver over a pipe.
So separating "how to speak to a cmdserver" from "how to do I/O" seemed to make sense.
Test Plan: Implemented an actual server on top of this, see next diff.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2663