Apache Thrift
2012-11-20 02:12
162 查看
Apache Thrift
The following example is a simple service to store user objects for a web front end.
Thrift Definition File
Python Client
C++ Server
Example
Apache Thrift allows you to define data types and service interfaces in a simple definition file. Taking that file as input, the compiler generates code to be used to easily build RPC clients and servers that communicate seamlessly across programming languages. Instead of writing a load of boilerplate code to serialize and transport your objects and invoke remote methods, you can get right down to business.The following example is a simple service to store user objects for a web front end.
Thrift Definition File
Python Client
C++ Server
struct UserProfile { 1: i32 uid, 2: string name, 3: string blurb } service UserStorage { void store(1: UserProfile user), UserProfile retrieve(1: i32 uid) }
# Make an object up = UserProfile(uid=1, name="Test User", blurb="Thrift is great") # Talk to a server via TCP sockets, using a binary protocol transport = TSocket.TSocket("localhost", 9090) transport.open() protocol = TBinaryProtocol.TBinaryProtocol(transport) # Use the service we already defined service = UserStorage.Client(protocol) service.store(up) # Retrieve something as well up2 = service.retrieve(2)
相关文章推荐
- Apache Thrift-可伸缩的跨语言服务开发框架
- 架构设计:系统间通信(11)——RPC实例Apache Thrift 上篇
- Apache Thrift
- Apache Thrift - 可伸缩的跨语言服务开发框架
- Apache Thrift - 可伸缩的跨语言服务开发框架
- RPC的应用:Apache thrift的ubuntu 14.04的安装与应用
- Apache Thrift - 可伸缩的跨语言服务开发框架
- Thinking in Apache Thrift One
- Apache Thrift - 可伸缩的跨语言服务开发框架
- Linux下配置RPC框架Apache Thrift
- Apache Thrift - 可伸缩的跨语言服务开发框架
- 运行apache thrift的错误解决
- RPC实例Apache Thrift 中篇
- Apache Thrift - java开发详解
- Apache Thrift 在Windows下的安装与开发
- apache thrift介绍与实例
- golang高性能RPC:Apache Thrift安装使用完全攻略
- java.lang.NoClassDefFoundError: org/apache/hive/service/cli/thrift/TCLIService$Iface
- Apache Thrift入门学习
- Apache Thrift之java入门例子