可以在Go中调用C ++ GRPC吗?(Can C++ GRPC be called in Go?)

系统教程 行业动态 更新时间:2024-06-14 16:59:47
可以在Go中调用C ++ GRPC吗?(Can C++ GRPC be called in Go?)

我已经完成了一个Client / Server实现,并用C ++编写了一个项目。

我正在Go开始一个新的项目制作一个Web应用程序,我希望它与我在C ++中所做的服务器实现交互。 有没有办法可以重新使用C ++客户端实现并从我的Go代码中调用它,或者我只需要在Go中重写客户端代码?

I have a Client/Server implementation already done and written in C++ for one project.

I'm starting a new project in Go making a web app and I want it to interact with the server implementation that I did in C++. Is there a way I can re use the C++ client implementation and call that from my Go code or will I just have to rewrite the client code in Go?

最满意答案

实现此目的的一种好方法是将客户端变为本地运行的服务器。 为此,您可以创建一个包装器proto文件,它将为C ++和Go生成代码。 在C ++中实现存根作为实际函数的包装,然后从gRPC Go客户端调用存根。 实际上,您正在链接呼叫。

A good way to implement this is by turning your client into a locally running server. To do this, you can make a wrapper proto file, that will generate code for both C++ and Go. Implement the stubs in C++ as wrappers to the real function, and then call the stubs from your gRPC Go client. In effect, you are chaining the calls.

更多推荐

本文发布于:2023-04-17 09:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/5f932b25910187c1e6c524129ab8842e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GRPC   called

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!