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

实现triple协议中支持curl访问的能力 #145

Closed
AdachiAndShimamura opened this issue Jul 21, 2023 · 3 comments
Closed

实现triple协议中支持curl访问的能力 #145

AdachiAndShimamura opened this issue Jul 21, 2023 · 3 comments

Comments

@AdachiAndShimamura
Copy link
Contributor

AdachiAndShimamura commented Jul 21, 2023

实现triple协议中支持curl访问的能力

 **基本思路:**  将接收到content-type为application/json的请求携带的数据转化为对应的grpc Message,再交给实际的handle进行处理,再将返回的grpc Message序列化为json数据,返回给客户端,以支持curl直接访问



 **实现方案:**
  • 使用prost-serde库,以支持prost生成的代码能与serde序列化工具能协同工作
  • 修改dubbo-build模块,在编译生成代码时为Message实现使用serde库进行序列化反序列化的能力,以支持将json数据转化为grpc消息,如下所示:
    #[derive(Serialize, Deserialize)]
    #[serde(crate = "::serde")]
    #[serde(rename_all = "snake_case")]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Clone, PartialEq, ::prost::Message)]
    ‘pub struct GreeterReply {
    #[prost(string, tag = "1")]
    pub message: ::prost::alloc::string::String,
    }`
  • 修改TripleServer部分代码,以支持根据不同的content-type采用不同的处理方式
  • 修改Decoding部分代码或者添加一个专用于解析json数据的Decoding,以支持对于application/json请求数据的接收和处理
  • 修改dubbo-build的构建规则,使prost生成的代码中加入对content-type的判断,以此分配不同的codec分别处理proto和json格式数据
@yang20150702
Copy link
Member

现在triple协议没有对外提供http server,不能通过curl来访问。你的设计看起来不能实现这个能力
建议通过grpccurl来访问 server。
如果你有进一步的想法,可以继续沟通。

@AdachiAndShimamura
Copy link
Contributor Author

AdachiAndShimamura commented Jul 23, 2023

现在triple协议没有对外提供http server,不能通过curl来访问。你的设计看起来不能实现这个能力 建议通过grpccurl来访问 server。 如果你有进一步的想法,可以继续沟通。

啊,我的意思是实现使用curl直接向unary服务发起通信,让server能够处理http1.1post请求的json数据,目前我改了一个初步版本,根据curl测试来看应该是可以实现这个能力

@AdachiAndShimamura
Copy link
Contributor Author

现在triple协议没有对外提供http server,不能通过curl来访问。你的设计看起来不能实现这个能力 建议通过grpccurl来访问 server。 如果你有进一步的想法,可以继续沟通。

钉钉加您了,麻烦同意一下

yang20150702 pushed a commit that referenced this issue Aug 18, 2023
* feat: 支持curl直接访问

将json消息转化为grpc消息,继而交给grpc handle进行处理,并以json格式返回数据

* fix(fix bug):

* refactor: 将生成Codec的逻辑转移到了TripleServer

* Feat: Added support for JSON encoding types(#145)

* fix: Fixed a bug related to compression(#145)

* perf: Improved code reuse-related logic(#145)

Optimized the logic of TripleServer and TripleClient, achieving code
reuse.
Merged encoding and encoding_json

* style: Formatted the code according to the cargo fmt standard(#145)

* perf: Resolved the warnings from cargo check(#145)

* perf: Optimized the code structure and removed redundant code(#145)

* perf: Optimized the configuration format as well as the configuration loading method.(#145)

* perf: Removed configuration using serialization methods.(#145)

The RPC client now exclusively uses protobuf for serialization.

---------

Co-authored-by: urara <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants