drplww2505 2018-06-29 07:35
浏览 910

在Go lang中理解和实现gRPC异步操作

I am still suffering from this problem: I know that with Go lang we can implement high-performance network service easily. I picked gRPC protocol and I had better implement asynchronous operation because it is more powerful than synchronous:

  • Can you tell me more details about the benefits of using asynchronous operation over the synchronous operation?
  • Can you guide me how to implement Go lang or Python asynchronous services, or give me its sample code, I have read this article https://grpc.io/docs/tutorials/async/helloasync-cpp.html but those kinds of code are beyond my knowledge

Thank you so much!

  • 写回答

1条回答 默认 最新

  • dqzg62440 2018-06-29 21:59
    关注

    I think it's important for you to do some more research and study, and clear up some of these concepts you're dealing with.

    In terms of sync and async services, I did a little Googling and randomly selected this page which seems to give a good definition of the terms:

    If an API call is synchronous, it means that code execution will block (or wait) for the API call to return before continuing.

    Asynchronous calls do not block (or wait) for the API call to return from the server. Execution continues on in your program, and when the call returns from the server, a "callback" function is executed.

    Your statement that "asynchronous operation is more powerful than synchronous" seems misguided. They each have different applications that are appropriate in different scenarios. If you have a specific scenario you care about, that would help narrow down the question.

    Here is the definition of gRPC:

    gRPC is a modern open source high performance RPC framework that can run in any environment.

    The key point here is RPC, or "Remote Procedure Call". In gRPC a call is synchronous, even if it is streaming: the connection is opened, the request is sent/streamed, the response is sent/streamed, and the connection is closed. Developing an "asynchronous service" implies a second call in the reverse direction, something which is not covered in the sphere of gRPC itself. I guess you could use gRPC to do this sort of thing but I don't think that is normal.

    Otherwise I would suggest you read the gRPC Basics guide, and there is sample code as well. It is available in Python as well if you check the gRPC site.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!