Services
Finally, the last concept we are going to see is service
. service
is designed for Protobuf interaction with RPC frameworks, such as gRPC. They define a type-safe contract that the server should implement and that the client can call:
EBNF – Service syntax
rpc = "rpc" ident "(" [ "stream" ] messageType ")" "returns" "(" [ "stream" ] messageType ")" (( "{" option "}" ) | ";") service = "service" ident "{" { option | rpc } "}"
For example, we could have the following service
:
service BookService { rpc ListBooks(ListBooksRequest) returns (ListBooksResponse); rpc GetBook(GetBookRequest) returns (Book); rpc CreateBook(CreateBookRequest) returns (Book); rpc UpdateBook(UpdateBookRequest) returns (Book); rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty...