GRPC / Protobuf 3 syntax: what is the difference between rpc lines ending with a semicolon vs '{}'?

I saw two different ways to declare a gRPC service using Protobuf v3. In some code, there is an end to the rpc line with a semicolon (for example, the current proto3 documentation):

service SearchService { rpc Search (SearchRequest) returns (SearchResponse); } 

The other code has the end of the rpc line with {} :

 service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} } 

Both of these files are compiled with the protoc v3.0.0-alpha-2 compiler and produce the same (go) code.

What is the difference between the two syntaxes?

+6
source share
1 answer

Nothing, really; they are equivalent.

The syntax {} used when there are parameters. If you do not specify any parameters, the syntax will work (as in C!).

+5
source

Source: https://habr.com/ru/post/986766/


All Articles