Documented below:

  1. Go to Apache website. Depending on where you are, use this site or Tsinghua mirror

  2. Decompress: tar -xvf thrift-0.11.0.tar.gz

  3. cd thrift-0.11.0

  4. install, compile:

    • ./configure
    • make
    • sudo make install
  5. thrift -version or thrift to ensure successful installation.

writing a thrift file

To generate the source from a thrift file run

1
thrift --gen <language> <Thrift filename>

e.g. vim demo.thrift:

1
2
3
4
5
6
7
8
# namespace  LAN  PACKAGE_NAME
namespace java com.lei.thrift.demo
namespace py thrift.demo

# interface
service DemoService {
void sayHello(1:string name);
}

thrift --gen java demo.thrift; or thrift --gen py demo.thrift