Thrift学习

Thrift 中的基本数据类型:
    类型 描述
    bool true, false
    byte 8位的有符号整数
    i16 16位的有符号整数
    i32 32位的有符号整数
    i64 64位的有符号整数
    double 64位的浮点数
    string UTF-8编码的字符串
    binary 字符数组
    struct 结构体
    list 有序的元素列表,类似于STL的vector
    set 无序的不重复元素集,类似于STL的set
    map key-value型的映射,类似于STL的map
    exception 是一个继承于本地语言的exception基类
    service 服务。包含多个函数接口(纯虚函数)

user.thrift:

struct User {

1: i32 id,

2: string name,

}

service UserStorage {

void set_user(1: string name)

User get_user(1: i32 id)

}
 

运行:

thrift-0.8.0.exe -gen java user.thrift

猜你喜欢

转载自chenzheng8975.iteye.com/blog/1740434