我已经完成了一个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.
更多推荐
发布评论