|
1 | | -# TChannel |
| 1 | +# TChannel [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] |
2 | 2 |
|
3 | | -[](https://godoc.org/github.com/uber/tchannel-go) |
4 | | -[](https://travis-ci.org/uber/tchannel-go) |
| 3 | +[TChannel][tchan-spec] is a multiplexing and framing protocol for RPC calls. |
| 4 | +tchannel-go is a Go implementation of the protocol, including client libraries |
| 5 | +for [Hyperbahn][hyperbahn]. |
5 | 6 |
|
6 | | -[TChannel](https://github.com/uber/tchannel/blob/master/docs/protocol.md) is a multiplexing and framing protocol for RPC calls. |
7 | | - |
8 | | -tchannel-go is a Go implementation of the TChannel protocol, and includes client libraries for [Hyperbahn](https://github.com/uber/hyperbahn). |
9 | | - |
10 | | -## Stability: experimental |
11 | | - |
12 | | -NOTE: `master:golang` is **not yet stable** |
13 | | - |
14 | | -## Thrift + TChannel Integration |
15 | | - |
16 | | -If you want to use Thrift+TChannel, you will want to read [this guide](guide/Thrift_Hyperbahn.md). |
17 | | - |
18 | | -## Getting Started |
19 | | - |
20 | | -Get Go from your package manager of choice or follow the [official installation instructions](https://golang.org/doc/install). |
21 | | - |
22 | | -```bash |
23 | | -brew install go |
24 | | - |
25 | | -# This will be your GOPATH where all Go code will live. |
26 | | -mkdir -p ~/gocode/src |
27 | | -``` |
28 | | - |
29 | | -Set up your environment for your shell of choice. |
30 | | - |
31 | | -```bash |
32 | | -export GOPATH="${HOME}/gocode" |
33 | | -export PATH="${PATH}":"${GOPATH}/bin" |
34 | | -``` |
35 | | - |
36 | | -TChannel uses [godep](https://github.com/tools/godep) to manage dependencies. To get started: |
37 | | - |
38 | | -```bash |
39 | | -go get github.com/uber/tchannel-go |
40 | | -go get github.com/tools/godep |
41 | | -cd $GOPATH/src/github.com/uber/tchannel-go |
42 | | -godep restore |
43 | | -make |
44 | | -``` |
45 | | -### Examples |
46 | | - |
47 | | -Simple examples are included which demonstrate the TChannel API and features. |
48 | | - |
49 | | - |
50 | | -#### PingPong |
51 | | -```bash |
52 | | -./build/examples/ping/pong |
53 | | -``` |
54 | | - |
55 | | -This example creates a client and server channel. The server channel registers a PingService |
56 | | -with a ping method, which takes request Headers and a Ping body and returns the |
57 | | -same Headers along with a Pong body. The client sends a ping request to the server |
58 | | - |
59 | | -Note that every instance is bidirectional, so the same channel can be used for both sending |
60 | | -and receiving requests to peers. New connections are initiated on demand. |
61 | | - |
62 | | - |
63 | | -#### KeyValue |
64 | | -```bash |
65 | | -./build/examples/keyvalue/server |
66 | | -./build/examples/keyvalue/client |
67 | | -``` |
68 | | - |
69 | | -This example exposes a simple keyvalue service over TChannel using the Thrift protocol. |
70 | | -The client has an interactive CLI that can be used to make calls to the server. |
| 7 | +If you'd like to start by writing a small Thrift and TChannel service, check |
| 8 | +out [this guide](guide/Thrift_Hyperbahn.md). For a less opinionated setup, see |
| 9 | +the [contribution guidelines](CONTRIBUTING.md). |
71 | 10 |
|
72 | 11 | ## Overview |
73 | 12 |
|
74 | | -TChannel is a network protocol with the following goals: |
| 13 | +TChannel is a network protocol that supports: |
75 | 14 |
|
76 | | - * request / response model |
77 | | - * multiple requests multiplexed across the same TCP socket |
78 | | - * out of order responses |
79 | | - * streaming request and responses |
80 | | - * all frames checksummed |
81 | | - * transport arbitrary payloads |
82 | | - * easy to implement in multiple languages |
83 | | - * near-redis performance |
| 15 | + * A request/response model, |
| 16 | + * Multiplexing multiple requests across the same TCP socket, |
| 17 | + * Out-of-order responses, |
| 18 | + * Streaming requests and responses, |
| 19 | + * Checksummed frames, |
| 20 | + * Transport of arbitrary payloads, |
| 21 | + * Easy implementation in many languages, and |
| 22 | + * Redis-like performance. |
84 | 23 |
|
85 | | -This protocol is intended to run on datacenter networks for inter-process communication. |
| 24 | +This protocol is intended to run on datacenter networks for inter-process |
| 25 | +communication. |
86 | 26 |
|
87 | 27 | ## Protocol |
88 | 28 |
|
89 | | -TChannel frames have a fixed length header and 3 variable length fields. The underlying protocol |
90 | | -does not assign meaning to these fields, but the included client/server implementation uses |
91 | | -the first field to represent a unique endpoint or function name in an RPC model. |
92 | | -The next two fields can be used for arbitrary data. Some suggested way to use the 3 fields are: |
| 29 | +TChannel frames have a fixed-length header and 3 variable-length fields. The |
| 30 | +underlying protocol does not assign meaning to these fields, but the included |
| 31 | +client/server implementation uses the first field to represent a unique |
| 32 | +endpoint or function name in an RPC model. The next two fields can be used for |
| 33 | +arbitrary data. Some suggested way to use the 3 fields are: |
93 | 34 |
|
94 | | -* URI path, HTTP method and headers as JSON, body |
95 | | -* function name, headers, thrift / protobuf |
| 35 | +* URI path + HTTP method and headers as JSON + body, or |
| 36 | +* Function name + headers + thrift/protobuf. |
96 | 37 |
|
97 | | -Note however that the only encoding supported by TChannel is UTF-8. If you want JSON, you'll need |
98 | | -to stringify and parse outside of TChannel. |
| 38 | +Note, however, that the only encoding supported by TChannel is UTF-8. If you |
| 39 | +want JSON, you'll need to stringify and parse outside of TChannel. |
99 | 40 |
|
100 | | -This design supports efficient routing and forwarding of data where the routing information needs |
101 | | -to parse only the first or second field, but the 3rd field is forwarded without parsing. |
| 41 | +This design supports efficient routing and forwarding: routers need to parse |
| 42 | +the first or second field, but can forward the third field without parsing. |
102 | 43 |
|
103 | | -There is no notion of client and server in this system. Every TChannel instance is capable of |
104 | | -making or receiving requests, and thus requires a unique port on which to listen. This requirement may |
105 | | -change in the future. |
| 44 | +There is no notion of client and server in this system. Every TChannel instance |
| 45 | +is capable of making and receiving requests, and thus requires a unique port on |
| 46 | +which to listen. This requirement may change in the future. |
106 | 47 |
|
107 | | - - See [protocol.md](https://github.com/uber/tchannel/blob/master/docs/protocol.md) for more details |
| 48 | +See the [protocol specification][tchan-proto-spec] for more details. |
108 | 49 |
|
109 | | -## Further examples |
| 50 | +## Examples |
110 | 51 |
|
111 | | - - [ping](examples/ping/main.go): A simple ping/pong example using raw TChannel. |
| 52 | + - [ping](examples/ping): A simple ping/pong example using raw TChannel. |
112 | 53 | - [thrift](examples/thrift): A Thrift server/client example. |
113 | 54 | - [keyvalue](examples/keyvalue): A keyvalue Thrift service with separate server and client binaries. |
114 | 55 |
|
115 | | -## Tests |
116 | | - |
117 | | -`make test` or `make cover` |
118 | | - |
119 | | -## Contributors |
120 | | - |
121 | | - - mmihic |
122 | | - - prashantv |
123 | | - |
124 | | -## MIT Licenced |
| 56 | +<hr> |
| 57 | +This project is released under the [MIT License](LICENSE.md). |
| 58 | + |
| 59 | +[doc-img]: https://godoc.org/github.com/uber/tchannel-go?status.svg |
| 60 | +[doc]: https://godoc.org/github.com/uber/tchannel-go |
| 61 | +[ci-img]: https://travis-ci.org/uber/tchannel-go.svg?branch=master |
| 62 | +[ci]: https://travis-ci.org/uber/tchannel-go |
| 63 | +[cov-img]: https://coveralls.io/repos/uber/tchannel-go/badge.svg?branch=master&service=github |
| 64 | +[cov]: https://coveralls.io/github/uber/tchannel-go?branch=master |
| 65 | +[tchan-spec]: http://tchannel.readthedocs.org/en/latest/ |
| 66 | +[tchan-proto-spec]: http://tchannel.readthedocs.org/en/latest/protocol/ |
| 67 | +[hyperbahn]: https://github.com/uber/hyperbahn |
0 commit comments