Understanding and implementation of gRPC asynchronous operation in Go lang

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:

Thank you so much!

Upvotes: 0

Views: 2279

Answers (1)

Matt Mc
Matt Mc

Reputation: 9297

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.

Upvotes: 1

Related Questions