OSDN Git Service

delete miner
[bytom/vapor.git] / vendor / github.com / go-kit / kit / transport / thrift / README.md
1 # Thrift
2
3 [Thrift](https://thrift.apache.org/) is a large IDL and transport package from Apache, popularized by Facebook.
4 Thrift is well-supported in Go kit, for organizations that already have significant Thrift investment.
5 And using Thrift with Go kit is very simple.
6
7 First, define your service in the Thrift IDL.
8 The [Thrift IDL documentation](https://thrift.apache.org/docs/idl) provides more details.
9 See [add.thrift](https://github.com/go-kit/kit/blob/ec8b02591ee873433565a1ae9d317353412d1d27/examples/addsvc/_thrift/add.thrift) for an example.
10 Make sure the Thrift definition matches your service's Go kit (interface) definition.
11
12 Next, [download Thrift](https://thrift.apache.org/download) and [install the compiler](https://thrift.apache.org/docs/install/).
13 On a Mac, you may be able to `brew install thrift`.
14
15 Then, compile your service definition, from .thrift to .go.
16 You'll probably want to specify the package_prefix option to the --gen go flag.
17 See [THRIFT-3021](https://issues.apache.org/jira/browse/THRIFT-3021) for more details.
18
19 ```
20 thrift -r --gen go:package_prefix=github.com/my-org/my-repo/thrift/gen-go/ add.thrift
21 ```
22
23 Finally, write a tiny binding from your service definition to the Thrift definition.
24 It's a straightforward conversion from one domain to the other.
25 See [thrift_binding.go](https://github.com/go-kit/kit/blob/ec8b02591ee873433565a1ae9d317353412d1d27/examples/addsvc/thrift_binding.go) for an example.
26
27 That's it!
28 The Thrift binding can be bound to a listener and serve normal Thrift requests.
29 And within your service, you can use standard Go kit components and idioms.
30 Unfortunately, setting up a Thrift listener is rather laborious and nonidiomatic in Go.
31 Fortunately, [addsvc](https://github.com/go-kit/kit/tree/master/examples/addsvc) is a complete working example with Thrift support.
32 And remember: Go kit services can support multiple transports simultaneously.