Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml.
Thrift是一个可扩展、跨语言的服务开发框架。它使用代码生成引擎,形成了一个可以高效和无缝连接Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml等语言的开发栈。
Thrift使用IDL描述语言来定义软件服务,并经过它的编译器将IDL服务翻译成骨架文件以及通信协议代码。它通常被当作一个远程过程调用(RPC)框架来使用,是由Facebook为“大规模跨语言服务开发”而开发的。主要特性如下:
- interface description language - Everything is specified in an IDL file from which bindings for many languages can be generated.
- language bindings - Thrift is supported in many languages and environments
- namespaces - Each Thrift file is in its own namespace allowing you to use the same identifier in multiple Thrift files
- language namespaces - Per Thrift file you can specify which namespace should be used for each programming language
- base types - Thrift has a small set of base types. See Thrift Types
- constants and enumerations - Constant values can be assigned logical names
- structs - Use structs to group related data. Structs can have fields of any type. See Thrift Types
- sparse structs - Optional base fields that have not been set and reference fields that are null will not be sent across the wire
- struct evolution - The addition and removal of fields is handled without breaking existing clients by using integer identifiers for fields
- containers - You can use sets, lists and maps of any type: base types, structs and other containers. See Thrift Types
- type definitions - Any type can be given a name that better describes it
- services - A service is a group of functions
- service inheritance - Subservices implement all functions of their base services and can have additional functions
- asynchronous invocations - Functions that do not return a result can be invoked asynchronously so the client is not blocked until the server has finished processing the request. The server may execute asynchronous * invocations of the same client in parallel/out of order
- exceptions - If an error occurs a function can throw a standard or user-defined exception. See Thrift Types
- cyclic structs - Starting with version 0.9.2, Thrift supports structs that contain themselves, or other structs to be declared later.
参考图书
书名 | ISBN | 作者 | 出版社 | 出版日期 | 备注 |
---|---|---|---|---|---|
Learning Apache Thrift | 9781785882746 | Krzysztof Rakowski | Packt Publishing | 2015-12-01 | P |
Programmer’s Guide to Apache Thrift | 9781617296161 | Randy Abernethy | Manning Publications | 2018-12-01 | P |
- 白皮书
https://thrift.apache.org/static/files/thrift-20070401.pdf
To learn more about Apache Thrift Read the Whitepaper。
- Thrift: The Missing Guide
https://diwakergupta.github.io/thrift-missing-guide/
https://diwakergupta.github.io/thrift-missing-guide/thrift.pdf
- Programmer’s Guide to Apache Thrift
https://github.com/RandyAbernethy/ThriftBook
参考网站
- 官网
地址 说明 https://thrift.apache.org Apache Thrift官方网站,包括代码下载、开发资料以及最新资讯等 https://github.com/apache/thrift Apache Thrift Git https://thrift.apache.org/download 最新版本下载 https://archive.apache.org/dist/thrift 历史版本下载 https://thrift.apache.org/docs 官方资料 https://thrift.apache.org/docs/Languages.html Apache Thrift支持的开发语言以及特性矩阵 https://thrift.apache.org/docs/features.html Apache Thrift特性