fbthrift

Facebook's branch of Apache Thrift, including a new C++ server.

  • 所有者: facebook/fbthrift
  • 平台:
  • 許可證: Apache License 2.0
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Facebook Thrift Build Status

Thrift is a serialization and RPC framework for service communication. Thrift enables these features in all major languages, and there is strong support for C++, Python, Hack, and Java. Most services at Facebook are written using Thrift for RPC, and some storage systems use Thrift for serializing records on disk.

Facebook Thrift is not a distribution of Apache Thrift. This is an evolved internal branch of Thrift that Facebook re-released to open source community in February 2014. Facebook Thrift was originally released closely tracking Apache Thrift but is now evolving in new directions. In particular, the compiler was rewritten from scratch and the new implementation features a fully asynchronous Thrift server. Read more about these improvements in the ThriftServer documentation.

You can also learn more about this project in the original Facebook Code blog post.

Table of Contents (ToC):

About Thrift

At a high level, Thrift is three major things:

A Code Generator

Thrift has a code generator which generates data structures that can be serialized using Thrift, and client and server stubs for RPC, in different languages.

A Serialization Framework

Thrift has a set of protocols for serialization that may be used in different languages to serialize the generated structures created from the code generator.

An RPC Framework

Thrift has a framework to frame messages to send between clients and servers, and to call application-defined functions when receiving messages in different languages.

There are several key goals for these components:

  • Ease of use:
    Thrift takes care of the boilerplate of serialization and RPC, and enables the developer to focus on the schema of the system's serializable types and on the interfaces of system's RPC services.

  • Cross language support:
    Thrift enables intercommunication between different languages. For example, a Python client communicating with a C++ server.

  • Performance:
    Thrift structures and services enable fast serialization and deserialization, and its RPC protocol and frameworks are designed with performance as a feature.

  • Backwards compatibility:
    Thrift allows fields to be added to and removed from serializable types in a manner that preserves backward and forward compatibility.


Building

Dependencies

Please install the following dependencies before building Facebook Thrift:

System:
Bison 3.1 or later,
Boost,
CMake,
Flex,
OpenSSLv1.0.2g,
PThreads,
Zlib

External:
{fmt},
GFlags,
GLog,
rsocket-cpp

Facebook:
Fizz,
Folly,
Wangle,
Zstd

Build

git clone https://github.com/facebook/fbthrift
cd build
cmake .. # Add -DOPENSSL_ROOT_DIR for macOS. Usually in /usr/local/ssl
make # or cmake --build .

This will create:

  • thrift/bin/thrift1: The Thrift compiler binary to generate client and
    server code.
  • thrift/lib/libthriftcpp2.so: Runtime library for clients and servers.

Thrift Files

When using thrift and the CMake build system, include: ThriftLibrary.cmake in
your project. This includes the following macro to help building Thrift files:

thrift_library(
  #file_name
  #services
  #language
  #options
  #file_path
  #output_path
)

This generates a library called file_name-<language>. That is, for
Test.thrift compiled as cpp2, it will generate the library Test-cpp2.
This should be added as a dependency to any source or header file that contains
an include to generated code.


C++ Static Reflection

Information regarding C++ Static Reflection support can be found under the static reflection library directory, in the corresponding README file.


主要指標

概覽
名稱與所有者facebook/fbthrift
主編程語言C++
編程語言C++ (語言數: 15)
平台
許可證Apache License 2.0
所有者活动
創建於2013-07-02 18:15:51
推送於2025-06-17 00:56:59
最后一次提交
發布數446
最新版本名稱v2025.06.16.00 (發布於 )
第一版名稱0.19.0 (發布於 )
用户参与
星數2.6k
關注者數185
派生數617
提交數29.7k
已啟用問題?
問題數375
打開的問題數34
拉請求數18
打開的拉請求數7
關閉的拉請求數233
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?