Services
The services implemented in gRPC are defined as RPCs (Remote Procedure Calls) in the .proto
file.
RPC was designed for developers to be able to execute a procedure in their source code, without caring about its execution. You can focus your efforts on coding the procedure, without worrying about serialization, communication, or security.
A service example can be defined as follows:
syntax
=
"proto2"
;
service
Starwars
{
rpc
GetFilm
(
GetFilmRequest
)
returns
(
GetFilmResponse
);
}
Thanks to this definition, the protocol buffer compiler will generate the service interface code and stubs (client and server side) suiting the chosen language. You can create your own RPC system, or you can use gRPC.
Importing other proto files
As mentioned earlier in the Nested Messages section, you can create messages that may be used inside other messages.
A flatter form of doing the same thing to avoid nesting to the infinity would be creating every single message on the root level...