Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brpc-thrift支持多参数 #467

Open
linux2014linux opened this issue Aug 28, 2018 · 4 comments
Open

brpc-thrift支持多参数 #467

linux2014linux opened this issue Aug 28, 2018 · 4 comments
Labels
enhancement improvements on existing features official created by brpc authors

Comments

@linux2014linux
Copy link

linux2014linux commented Aug 28, 2018

我的原始thrift接口如下:
service Test {
PostListResult BatchGetVideoFeedFromCacheByTime(1:i32 uid, 2:i32 timestamp, 3:i32 start 4:i32 count);
}
我用原生thrift接口参数填写为多个,可调用成功。

CallMethod支持有限参数,如下:
_stub->CallMethod("BatchGetVideoFeedFromCacheByTime", &controller, &request, &resp, NULL);
如何在不修改原始thrift接口的情况下,使用brpc-thrift用多参数的形式访问呢?请问这个目前有办法做吗?

@linux2014linux linux2014linux changed the title 关于brpc-thrift请求兼容问题 关于brpc-thrift请求CallMethod多参数问题 Aug 28, 2018
@jamesge
Copy link
Contributor

jamesge commented Aug 30, 2018

这是个已知问题,目前的thrift实现只支持一个请求,并且假定了请求的field number是1。多个的话要对代码做一些调整。

@linux2014linux
Copy link
Author

@jamesge 这个调整,brpc有计划何时合入吗?

@jamesge
Copy link
Contributor

jamesge commented Aug 30, 2018

这个调整还没有开发过,你有兴趣的话可以自己先看一下

@linux2014linux
Copy link
Author

linux2014linux commented Aug 30, 2018

@jamesge ge老师,我抓包看了下CallMethod单参数请求和thrift多参数的区别,我目前将src/brpc/policy/thrift_protocol.cpp中如下结构体序列化部分如下3行注释后,
void SerializeThriftRequest(butil::IOBuf* request_buf, Controller* cntl,
const google::protobuf::Message* req_base) {
...
// xfer += oprot.writeStructBegin(struct_begin_str);
// xfer += oprot.writeFieldBegin("request", ::apache::thrift::protocol::T_STRUCT,
THRIFT_REQUEST_FID);
...
xfer += oprot.writeFieldEnd();
xfer += oprot.writeFieldStop();
// xfer += oprot.writeStructEnd();
...
}
可以用CallMethod单参数的形式访问thrift多参数的方法,但是不知道有没有什么潜在问题,烦请老师指点。

@jamesge jamesge added the official created by brpc authors label Sep 27, 2018
@jamesge jamesge changed the title 关于brpc-thrift请求CallMethod多参数问题 brpc-thrift支持多参数 Sep 27, 2018
@jamesge jamesge added the enhancement improvements on existing features label Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvements on existing features official created by brpc authors
Projects
None yet
Development

No branches or pull requests

2 participants