Giter Site home page Giter Site logo

terrelln / fbthrift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebook/fbthrift

0.0 0.0 0.0 162.62 MB

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

License: Apache License 2.0

Shell 0.03% JavaScript 0.21% Ruby 0.03% C++ 53.93% Python 7.97% C 0.07% Emacs Lisp 0.05% Java 10.32% Go 2.23% Rust 1.70% CSS 0.02% Hack 1.42% Thrift 11.41% CMake 0.66% Cython 1.69% Vim Script 0.01% Mustache 6.58% MDX 1.68%

fbthrift's Introduction

Facebook Thrift

Support Ukraine Linux Build Status macOS Build Status Windows Build Status Facebook Thrift Logo

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

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 the 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

On Linux or MacOS (with Homebrew installed) you can install system dependencies to avoid building them:

# Clone the repo
git clone https://github.com/facebook/fbthrift
# Install dependencies
cd fbthrift
./build/fbcode_builder/getdeps.py install-system-deps --recursive fbthrift

On other platforms or if on Linux and without system dependencies getdeps.py will mostly download and build them for you during the build step.

Some of the dependencies getdeps.py uses and installs are:

System: Boost, CMake, OpenSSLv1.0.2g, PThreads, Python, and Zlib

External: {fmt}, GFlags, GLog, and GTest and GMock

Facebook: Fizz, Folly, Wangle, and Zstd

The Thrift compiler only depends on Boost, CMake and {fmt}.

Build

# Clone the repo
git clone https://github.com/facebook/fbthrift
cd fbthrift
# Build, using system dependencies if available
./build/fbcode_builder/getdeps.py --allow-system-packages build fbthrift

getdeps.py will invoke cmake etc and put output in its scratch area (you can see in logs, and can override with --scratch-path):

  • installed/fbthrift/bin/thrift1: The Thrift compiler binary to generate client and server code.
  • installed/fbthrift/lib/libthriftcpp2.a: Library for clients and servers.

If you want to invoke cmake again to iterate, there is an helpful run_cmake.py output in the scratch build/fbthrift directory.

CMake options:

  • THRIFT_COMPILER_ONLY: specifies whether to build only the Thrift compiler (OFF by default)
  • enable_tests: specifies whether to enable tests

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.

C++ Server Metrics

To collect runtime stats from a Thrift server, e.g. the number of active requests/connections, the C++ Thrift server supports an observer API that installs callbacks at a set of specific execution points in the server.

To expose collected metrics out of the server process, one way is to use fb303 interfaces, see fb303 Github repo.

fbthrift's People

Contributors

ahilger avatar ahornby avatar alandau avatar ami7o avatar andriigrynenko avatar avalonalex avatar chadaustin avatar clairezhang-fb avatar ddrcoder avatar dusty-phillips avatar echistyakov avatar eduardo-elizondo avatar filip-f avatar fried avatar iahs avatar jmswen avatar junzh0u avatar mizuchi avatar mshneer avatar orvid avatar praihan avatar rmakheja avatar simpkins avatar spalamarchuk avatar stevegury avatar thedavekwon avatar vitaut avatar wez avatar yfeldblum avatar zhxchen17 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.