What does it mean?
| |
---|
g | gRPC |
R | Remote |
P | Procedure |
C | Calls |
| |
What is it used for?
- Client ⇔ Server Communication
- Server ⇔ Server Communication
- X ⇔ Y Communication
Transport channel ¯\(ツ)/¯
gRPC is agnostic about the transport channel.
For client server communication in a web application we use gRPC over HTTP.
Why use it rather than [X] ?
- Efficient serialization → Small message size
- Interface definition can easily be shared (.protobuf files)
- Support for both server-side code generation and client generation for many languages
- Integrating systems in different languages
Programming Model
A client application calls a method on a server application on a different machine as if it were a local object.
Multiple Different Clients
By default gRPC uses Protocol Buffers
Adding gRPC and Protobuf to a .NET Solution
You need three projects.
- Install NuGet Packages in Shared project:
- Add folder
Grpc
in Shared project
- Add reward.proto file in that folder
Add code in Shared .csproj file
- Install NuGet Packages in Client project:
- Install NuGet Packages in Server project:
- Implement a service by deriving from generated classes in Shared project (next slide)