Understanding service definitions
You define a service by specifying its methods with respective parameters and return types. These methods are exposed by the server, which can be called remotely. You defined the EmployeeService
definition in the previous sub-section, as shown in the next code block:
service EmployeeService { Â Â rpc Create(Employee) returns (EmployeeCreateResponse); }
Here, Create
is a method exposed by the EmployeeService
service definition. Messages used in the Create
service should also be defined as a part of the service definition. The Create
service method is a unary service method because the client sends a single request object and receives a single response object in return from the server.
Let's dig further into the types of service methods offered by gRPC:
- Unary: We have already discussed the unary service method in the previous example. It would have a one-way response for a single request.
- Server streaming: In these types...