Thrift is an interface definition language and binary communication protocol that is used to define and create services for numerous languages. It is used as a remote procedure call (RPC) framework and was developed at Facebook for “scalable cross-language services development”.

Facebook re-open sourced the thrift with various enhancements. It includes a new code generator and framework for c++ called cpp2. The cpp2 framework looks great but there is almost no documentation on how to use the cpp2. At the time of writing this article, I could not even get any documentation on how to use the thrift compiler to generate cpp2 style code. The thrift compiler(thrift1) does not even recognize -gen cpp2 compiler option. After googling a little bit I found that the python version of the compiler can be used to generate cpp2 style code.
To know more about the cpp2, follow this link.

About this tutorial

This tutorial will help you to understand and use the fbthrift cpp2 framework. This tutorial is an incomplete guide because:

I came up with the content of this tutorial by mostly reading the thrift source code. At the time of writing this tutorial the thrift version is 15.0. The content may go outdated in future if the thrift design changes.


Installing thrift

Get the code from Github and follow the instructions in README file


Do you collaborate using whiteboard? Please try Lekh Board - An Intelligent Collaborate Whiteboard App