【文件属性】:
文件名称:thrift文件生成工具thrift-generator.zip
文件大小:34KB
文件格式:ZIP
更新时间:2022-08-07 21:54:38
开源项目
thrift-generator 是通过 Java 的接口生成 thrift 文件的工具。例子:public interface ICommonUserService {
public User login(int id, String name);
public User getUserById(long id);
public boolean saveUser(User user);
public List getUserIds(long id);
public Map getUserByIds(List ids);
public Map> getUsersByName(List names);
public Map> getGroupUsers(List names, List userList, List lns, long ll);
public List testCase1(Map num1, List num2, List num3, long num4, String num5);
}
public class ThriftStructBuilderTest {
private ThriftFileBuilder fileBuilder = new ThriftFileBuilder();
@Test
public void toOutputstream() throws Exception {
this.fileBuilder.buildToOutputStream(ICommonUserService.class, System.out);
}
}执行代码:mvn test -Dtest=com.sohu.thrift.generator.builder.ThriftStructBuilderTest之后控制台输出如下:namespace java com.sohu.thrift.generator.test.thrift
enum Status {
NORMAL = 0,
BLOCKED = 1
}
struct Account {
1:i32 id,
2:string name
}
struct User {
1:i32 id,
2:string name,
3:bool sex,
4:Status status,
5:list ids,
6:Account account
}
service ICommonUserService {
User login(1:i32 arg0,2:string arg1),
map> getUsersByName(1:list arg0),
bool saveUser(1:User arg0),
map getUserByIds(1:list arg0),
list getUserIds(1:i64 arg0),
map> getGroupUsers(1:list arg0,2:list arg1,3:list arg2,4:i64 arg3),
User getUserById(1:i64 arg0),
list testCase1(1:map arg0,2:list arg1,3:list arg2,4:i64 arg3,5:string arg4)
}
标签:thrift