Thrift|Thrift安装初体验

官网下载Thrift:

http://mirrors.hust.edu.cn/apache/thrift/0.9.3/thrift-0.9.3.tar.gz

首先需要构架和安装Thrift的编译器

http://thrift.apache.org/docs/BuildingFromSource

在安装源码之前,需要做好一些准备:

http://thrift.apache.org/docs/install/os_x

安装Boost

https://sourceforge.net/projects/boost/files/boost/1.61.0/

https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download

执行

$ ./bootstrap.sh
$ sudo ./b2 threading=multi address-model=64 variant=release stage install 

安装libevent

http://libevent.org/

$ brew install libevent

我是通过brew安装的,prefix是/usr/local/Cellar.

安装Thrift

$ tar -zxvf thrift-0.9.3.tar.gz
$ cd thrift-0.9.3
$ ./configure --prefix=/data/thrift --with-boost=/data/thrift/boost_1_61_0 --with-libevent=/usr/local/Cellar

遇到报错,安装更高版本的bison

$ brew install homebrew/versions/bison27

安装成功

配置 .thrift 文件

安装完Thrift的编译器后,还需要完成一个配置文件。这个文件实际上是通过使用Thrift方式和服务来定义接口。定义好的配置文件即可被server以及其它任意的client使用。

从一个.thrift文件来生成source code,需要执行

thrift --gen <language> <Thrift filename>

可参考文件:

https://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=tree;f=tutorial

https://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=blob;f=tutorial/php/PhpClient.php;h=d262b8fe922719034731679347410a90d81df5a3;hb=HEAD

https://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=blob;f=tutorial/php/PhpServer.php;h=22ae43eb84d1a019a8622181a3eac3fc9468c147;hb=HEAD

RPC: http://baike.baidu.com/view/7287257.htm?fromtitle=RPC&fromid=609861&type=search

参考

  1. http://thrift.apache.org/

  2. http://thrift.apache.org/lib/php

  3. http://thrift.apache.org/static/files/thrift-20070401.pdf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值