Definitions
Main-Source
# gRPC
# What does it mean?
g | gRPC |
---|
R | Remote |
P | Procedure |
C | Calls |
g = Google | |
# 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
ClientServerDoSomething()responseDataClientServer
A client application calls a method on a server application on a different machine as if it were a local object.
# Multiple Different Clients
MethodCall()ResponseMethodCall()ResponseClient AC#Client BC++ServerC#
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:
If you have a seperate Client-Server architecture - add the following line:
- Install NuGet Packages in Server project:
- Implement a service by deriving from generated classes in Shared project (next slide)