Repository navigation
Conversation
| butil::IOBuf* request_buf, | ||
| Controller* cntl, | ||
| const google::protobuf::Message* request); | ||
| const void* request_obj); |
There was a problem hiding this comment.
这个改动影响太大了,我认为是不可接受的。不仅是brpc代码库中的所有protocol实现需要修改,而且其他用户自己实现的protocol也要修改(即不兼容升级)
我提一个思路你参考一下:你可以让brpc::flatbuffers::Message继承brpc::NonreflectableMessage,这样这个message就自动继承了google::protobuf::Message,这样就可以在不修改brpc框架接口的前提下扩展出flatbuffer协议。你可以参考brpc Redis/Memcached等协议的实现,这些协议实际上并不用到protobuf,但也保持了google::protobuf::Message的接口形式。
| namespace brpc { | ||
| namespace policy { | ||
|
|
||
| struct FBRpcRequestMeta { |
There was a problem hiding this comment.
有没有考虑过这个Meta也用flatbuffers格式呢?这样以后新增字段不会破坏兼容性
There was a problem hiding this comment.
不太好实现。因为改用fbs定义meta部分后,需要通过FlatBufferBuilder构建meta,赋值时需要走flatbuffers的接口,这会有额外的处理开销。出于性能考虑,当前Meta字段与rpc message被放在了连续的内存中,使用FlatBufferBuilder创建meta时就无法使用该优化了。
也无法直接使用flatc生成的meta struct,因为flatc会将成员变量属性设置为private,且只能通过特定接口访问成员变量。
There was a problem hiding this comment.
至少在协议中要加上meta的长度,这样以后能增加字段吧。
Key components:
- Protocol Implementation
* Added flatbuffers_protocol.cpp/h for parsing, serialization and
request/response handling.
* Registered "fb_rpc" protocol in global.cpp
- Core Infrastructure Updates
* Channel: Added FBCallMethod and CallMethodInternal<bool is_pb>
template for dual pb/fb support.
* Controller: Added _fb_method, _fb_response fields and
is_use_flatbuffer() method for flatbuffers state tracking.
* Server: Added FlatBuffersMethodProperty/ServiceProperty structures
and AddService() overloads for flatbuffers::Service registration.
- Protocol Handler Refactoring
* Updated all protocol handlers (baidu_rpc, http, http2, redis, etc.)
to use generic void* pointers instead of google::protobuf types,
enabling protocol-agnostic message handling.

What problem does this PR solve?
Issue Number: #3062 #3196
Problem Summary:
Hi, 本提交添加了对flatbuffers协议的完整支持。我增加了与“baidu_std”并列的协议,暂时命名为“fb_rpc”,主要实现在文件flatbuffers_protocol.cpp/h中。我认为以下2点值得关注:
由于该提交依赖于#3196,且编译机器上未安装flatbuffers,所以本pr暂时无法直接编译。我计划根据评审老师的意见再进行修改并添加单测等完整实现。
Check List: