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

protobuf 增加从byte数组中读取指定数量field的函数 #42

Open
someview opened this issue Mar 26, 2024 · 3 comments
Open

protobuf 增加从byte数组中读取指定数量field的函数 #42

someview opened this issue Mar 26, 2024 · 3 comments

Comments

@someview
Copy link

protobuf的编解码属于属于位置不可移动类型. 如果能确定编码的时候,某几个字段在生成的字节数组,那么,对于转发或者代理之类的网关,就可以不需要解码整个消息,之需要解码前面几个字段。

生成器生成protobuf代码的时候, 固定写入字段的顺序(编码),这是可以固定的。另外一个是, 在需要代理转发的地方,根据二进制直接读取前面需要的字段. 目前,dynamicgo中有comsumefixed64这样的方法可以读取用一个字段,是否可以增加,连续读取几个字段的方法呢

@AsterDY
Copy link
Collaborator

AsterDY commented Mar 26, 2024

这个操作过于耦合业务逻辑,不太适合作为通用api。可以基于"github.com/cloudwego/dynamicgo/proto/binary"自己实现一个?

@someview
Copy link
Author

someview commented Apr 3, 2024

这个操作过于耦合业务逻辑,不太适合作为通用api。可以基于"github.com/cloudwego/dynamicgo/proto/binary"自己实现一个?
也不算耦合啊,binary都有从一个字节数组中解析一个字段的方法了,比如fixed64,那为啥不能有连续解析几个字段的办法呢

@AsterDY
Copy link
Collaborator

AsterDY commented Apr 5, 2024

欢迎提pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants