Q1ngbo opened a new pull request, #3196:
URL: https://github.com/apache/brpc/pull/3196
### What problem does this PR solve?
Issue Number: resolve #2354 #978
Problem Summary:
Hi, 我基于先前的commit #3062
完成了flatbuffers协议对brpc的适配,准备将完整实现提交至社区。在brpc中增加flatbuffers(fb)支持可分为fb
message构造与fb协议处理两部分。前者解决的问题是如何使用flatbuffers库提供的接口去创建一个message,以及应用接收到message后如何从中读取出数据;后者解决的是brpc如何处理"fb"协议。因此,我将相关实现拆分为了两个提交。本提交重点在于message构造。
我之所以将message构造提交至brpc仓库中而不是像grpc一样在google/flatbuffers中实现,主要出于两点考虑:首先,为了与IOBuf兼容,创建message使用的底层数据结构为之前已经提交的SingleIOBuf,在flatbuffers中使用该数据结构会导致循环依赖;其次,flatbuffers提供了完善的接口,只需要在brpc里定义好内存分配器,即可调用相关接口来构造消息,实现上很方便。
特别说明:
1. 本次提交主要是为了征求各位评审老师的意见,暂未添加单测。
2. 对于google/flatbuffers的修改需要与brpc中部分实现保持一致,所以针对flatbuffers仓库的修改暂未提交。
3. 为了便于大家理解,我在example中增加了示例程序bechmark_fb,后续正式入库前将移除它,该目录下的test_generated.h,
test.brpc.fb.h与test.brpc.fb.cpp正式由flatbuffers的编译工具flatc基于test.fbs自动生成的。基于该程序,在我们的测试环境下,flatbuffers协议相较于"baidu_std"协议在32~8KB大小的消息上QPS有20%+的提升。
---
### Check List:
- Please make sure your changes are compilable.
- When providing us with a new feature, it is best to add related tests.
- Please follow [Contributor Covenant Code of
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]