| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

Thrift 的 Python 版本:ThriftPy

ThriftPy 是 Apache Thrift 的一个纯 Python 语言实现。Apache Thrift 是跨语言服务访问的框架。最早由非死book 开发,贡献给了Apache。通过接口定义语言(IDL),定义和创建服务,Thrift生成特定语言的可供server和client 访问的代码。
Thrfit 有着非常优秀的效率,无论是内存还是 传输效率上。

特性

  • Supports python2.7 to python3.4 and pypy.

  • Compatible with Apache Thirft. You can use ThriftPy together with the official implemention servers and clients, such as a upstream server with a thriftpy client or the opposite.

    (Currently only binary protocol & buffered transport were implemented.)

  • Can directly load thrift file as module, the sdk code will be generated on the fly.

    For example, pingpong = thriftpy.load("pingpong.thrift") will load 'pingpong.thrift' as 'pingpong' module.

    Or, when import hook enabled, directly use import pingpong_thrift to import the 'pingpong.thrift' file as module.

  • Pure python, standalone implemention. No longer need to compile & install the 'thrift' package. All you need is python and thrift file.

  • Easy RPC server/client setup.

服务器端示例代码:

import thriftpy  from thriftpy.rpc import make_server    pingpong = thriftpy.load("pingpong.thrift")    class Dispatcher(object):      def ping(self):          return "pong"    server = make_server(pingpong.PingPong, Dispatcher(), '127.0.0.1', 6000)  server.serve()

客户端:

import thriftpy  from thrift.rpc import make_client    pingpong = thriftpy.load("pingpong.thrift")    client = make_client(pingpong.PingPong, '127.0.0.1', 6000)  client.ping()

项目主页:http://www.open-open.com/lib/view/home/1403444273265

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1403444273265.html
ThriftPy WEB服务/RPC/SOA