SlideShare a Scribd company logo
eleks.comeleks.com
Google RPC.
Creating Hello world sample for gRPC
Create Solution with class library for
stub code (named Greeter)
In a class library:
• Create Folder “protos” – for server interface and
types descripted files.
• Create Folder “gen” – for generated by grps tools
code.
• Add new item to project – “generate_protos.bat”
file
• Remove useless Class1 file
Add such gRPC nuget references:
• Grpc.Core (v 0.14.0)
• Grpc.Tools (v 0.14.0)
• Google.protobuf.custom (v 3.0.0 beta-2
Now project looks like this:
Create proto file
• In a “protos” folder create “helloworld.proto” file.
• Add Server interface and types code to proto file
(next slide)
Proto file content:
syntax = "proto3";
option java_multiple_files = true;
option java_package =
"io.grpc.examples.helloworld";
option java_outer_classname =
"HelloWorldProto";
option objc_class_prefix = "HLW";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns
(HelloReply) {}
}
// The request message containing the user's
name.
message HelloRequest {
string name = 1;
}
// The response message containing the
greetings
message HelloReply {
string message = 1;
}
Create bat file for generating
stub code from proto file
• Add to project file “generate_protos.bat” file
• This bat will run gRPC code generating tools with
argument proto file
Generate_protos.bat content
@rem Generate the C# code for .proto files
setlocal
@rem enter this directory
cd /d %~dp0
@rem set TOOLS_PATH=..packagesGrpc.Tools.0.14.0toolswindows_x86
set TOOLS_PATH=..packagesGrpc.Tools.0.14.0toolswindows_x86
%TOOLS_PATH%protoc.exe -I protos --csharp_out gen protos/helloworld.proto --grpc_out gen -
-plugin=protoc-gen-grpc=%TOOLS_PATH%grpc_csharp_plugin.exe
endlocal
Generating stub code:
• Run cmd, go to generate_protos.bat location
• Run generate_protos.bat
• Open “gen”, see newly generated files appeared
• Add new files to project
• Build Project in x86 configuration
Add Server project
• Add “GreeterServer” visual C# console application project.
• With nuget package add Grpc.Core (v 0.14.0) package.
• Reference “Greeter” project to GreeterServer project
• Add using Grpc.Core and Helloworld.
• Add GreeterImpl class to Server project code
class GreeterImpl : Greeter.IGreeter
{
// Server side handler of the SayHello RPC
public Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
}
}
Modify Program.cs
class Program
{
const int Port = 50051;
static void Main(string[] args)
{
Server server = new Server
{
Services = { Greeter.BindService(new GreeterImpl()) },
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
server.Start();
Console.WriteLine("Greeter server listening on port " + Port);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
}
}
Add Client project
• Add “GreeterClient” visual C# console application project.
• With nuget package add Grpc.Core (v 0.14.0) package.
• Reference “Greeter” project to GreeterServer project
• Add using Grpc.Core and Helloworld.
Modify Program.cs
class Program
{
static void Main(string[] args)
{
Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
var client = Greeter.NewClient(channel);
String user = "you";
var reply = client.SayHello(new HelloRequest { Name = user });
Console.WriteLine("Greeting: " + reply.Message);
channel.ShutdownAsync().Wait();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
Build and Run
• Build entire solution in x86 configuration, see it is
building without errors.
• Run GreetingServer and GreetingClient
• See GreetingClient receives response.
Result !
Практичне завдання:
• Базуючись на попередньому Helloworld прикладі
• Створити клієнт серверну програму, яка
використовуватиме gRPC для комунікації
• Вид аплікації – це система для офіціанта в кафе, де
він записує замовлення, клієнтів і т.д.
• Для gRPC методів можна використовувати прості
типи (тільки string, як в прокладі )
• Ця практична використовуватиметься як база для
наступного практичного завдання

More Related Content

PPTX
Kubernetes #4 volume &amp; stateful set
Terry Cho
 
PPT
RESTful API In Node Js using Express
Jeetendra singh
 
PDF
Jolokia - JMX on Capsaicin (Devoxx 2011)
roland.huss
 
PDF
The Parenscript Common Lisp to JavaScript compiler
Vladimir Sedach
 
PDF
Fluentd v1.0 in a nutshell
N Masahiro
 
PDF
Fluentd v0.14 Plugin API Details
SATOSHI TAGOMORI
 
PPTX
Powershell Demo Presentation
Avik Bhattacharyya
 
PDF
Common technique in Bypassing Stuff in Python.
Shahriman .
 
Kubernetes #4 volume &amp; stateful set
Terry Cho
 
RESTful API In Node Js using Express
Jeetendra singh
 
Jolokia - JMX on Capsaicin (Devoxx 2011)
roland.huss
 
The Parenscript Common Lisp to JavaScript compiler
Vladimir Sedach
 
Fluentd v1.0 in a nutshell
N Masahiro
 
Fluentd v0.14 Plugin API Details
SATOSHI TAGOMORI
 
Powershell Demo Presentation
Avik Bhattacharyya
 
Common technique in Bypassing Stuff in Python.
Shahriman .
 

What's hot (20)

PPTX
Professional Help for PowerShell Modules
June Blender
 
KEY
PyCon AU 2012 - Debugging Live Python Web Applications
Graham Dumpleton
 
PDF
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
PDF
Fluentd v0.14 Overview
N Masahiro
 
PPTX
Sql killedserver
ColdFusionConference
 
PDF
parenscript-tutorial
tutorialsruby
 
PPTX
Utilizing the OpenNTF Domino API
Oliver Busse
 
PDF
Dive into Fluentd plugin v0.12
N Masahiro
 
PDF
JRuby with Java Code in Data Processing World
SATOSHI TAGOMORI
 
PDF
Fluentd at HKOScon
N Masahiro
 
PPTX
Introduction to Node.js
Winston Hsieh
 
PDF
The basics of fluentd
Treasure Data, Inc.
 
PPTX
OpenNTF Domino API - Overview Introduction
Paul Withers
 
PDF
The basics of fluentd
Treasure Data, Inc.
 
PDF
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Ontico
 
PDF
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
NAVER Engineering
 
PDF
What is new in Go 1.8
John Hua
 
PDF
Software development practices in python
Jimmy Lai
 
PPTX
Introduction To Windows Power Shell
Microsoft TechNet
 
PDF
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Red Hat Developers
 
Professional Help for PowerShell Modules
June Blender
 
PyCon AU 2012 - Debugging Live Python Web Applications
Graham Dumpleton
 
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
Fluentd v0.14 Overview
N Masahiro
 
Sql killedserver
ColdFusionConference
 
parenscript-tutorial
tutorialsruby
 
Utilizing the OpenNTF Domino API
Oliver Busse
 
Dive into Fluentd plugin v0.12
N Masahiro
 
JRuby with Java Code in Data Processing World
SATOSHI TAGOMORI
 
Fluentd at HKOScon
N Masahiro
 
Introduction to Node.js
Winston Hsieh
 
The basics of fluentd
Treasure Data, Inc.
 
OpenNTF Domino API - Overview Introduction
Paul Withers
 
The basics of fluentd
Treasure Data, Inc.
 
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Ontico
 
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
NAVER Engineering
 
What is new in Go 1.8
John Hua
 
Software development practices in python
Jimmy Lai
 
Introduction To Windows Power Shell
Microsoft TechNet
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Red Hat Developers
 
Ad

Viewers also liked (20)

PPTX
G rpc lection1_theory_bkp2
eleksdev
 
PPTX
Frontend basics
eleksdev
 
PPTX
Rpc
eleksdev
 
PPTX
SDLC. QA Role
eleksdev
 
PPTX
Advanced styles
eleksdev
 
PPTX
Windows service
eleksdev
 
PPTX
DAL
eleksdev
 
PPTX
Web service lecture
eleksdev
 
PPTX
Improving rpc bkp
eleksdev
 
PPTX
SDLC. PM Role
eleksdev
 
PPTX
Aspnet core
eleksdev
 
PPTX
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
eleksdev
 
PPTX
SDLC. BA Role
eleksdev
 
PPTX
SDLC. UX Role
eleksdev
 
PPTX
Angular. presentation
eleksdev
 
PPTX
Css animation, html5 api
eleksdev
 
PPTX
SQL Grouping, Joins
eleksdev
 
PPTX
SQL: Indexes, Select operator
eleksdev
 
PPTX
Sql 04n edited
eleksdev
 
PPTX
Version control
eleksdev
 
G rpc lection1_theory_bkp2
eleksdev
 
Frontend basics
eleksdev
 
SDLC. QA Role
eleksdev
 
Advanced styles
eleksdev
 
Windows service
eleksdev
 
Web service lecture
eleksdev
 
Improving rpc bkp
eleksdev
 
SDLC. PM Role
eleksdev
 
Aspnet core
eleksdev
 
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
eleksdev
 
SDLC. BA Role
eleksdev
 
SDLC. UX Role
eleksdev
 
Angular. presentation
eleksdev
 
Css animation, html5 api
eleksdev
 
SQL Grouping, Joins
eleksdev
 
SQL: Indexes, Select operator
eleksdev
 
Sql 04n edited
eleksdev
 
Version control
eleksdev
 
Ad

Similar to G rpc lection1 (20)

PPTX
ASP.NET Core 3.0 Deep Dive
Jon Galloway
 
PPTX
Jenkins' shared libraries in action
Lohika_Odessa_TechTalks
 
PDF
A New Chapter of Data Processing with CDK
Shu-Jeng Hsieh
 
PDF
Kubernetes for the PHP developer
Paul Czarkowski
 
PPTX
ConFoo - NuGet beyond Hello World
Maarten Balliauw
 
PDF
Development Workflow Tools for Open-Source PHP Libraries
Pantheon
 
PDF
Excelian hyperledger walkthrough-feb17
Excelian | Luxoft Financial Services
 
PDF
Parse cloud code
維佋 唐
 
PDF
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays
 
PPTX
NuGet beyond Hello World - DotNext Piter 2017
Maarten Balliauw
 
PDF
.gradle 파일 정독해보기
경주 전
 
PDF
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
Michael Lange
 
PPTX
Native client
zyc901016
 
PPTX
Connecting the Dots: Kong for GraphQL Endpoints
Julien Bataillé
 
PDF
gRPC in Go
Almog Baku
 
PDF
C++ Windows Forms L01 - Intro
Mohammad Shaker
 
PPTX
GradleFX
Christophe Herreman
 
PDF
The Ring programming language version 1.8 book - Part 95 of 202
Mahmoud Samir Fayed
 
PPTX
Dynamic virtual evironments
Виталий Чащин
 
ASP.NET Core 3.0 Deep Dive
Jon Galloway
 
Jenkins' shared libraries in action
Lohika_Odessa_TechTalks
 
A New Chapter of Data Processing with CDK
Shu-Jeng Hsieh
 
Kubernetes for the PHP developer
Paul Czarkowski
 
ConFoo - NuGet beyond Hello World
Maarten Balliauw
 
Development Workflow Tools for Open-Source PHP Libraries
Pantheon
 
Excelian hyperledger walkthrough-feb17
Excelian | Luxoft Financial Services
 
Parse cloud code
維佋 唐
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays
 
NuGet beyond Hello World - DotNext Piter 2017
Maarten Balliauw
 
.gradle 파일 정독해보기
경주 전
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
Michael Lange
 
Native client
zyc901016
 
Connecting the Dots: Kong for GraphQL Endpoints
Julien Bataillé
 
gRPC in Go
Almog Baku
 
C++ Windows Forms L01 - Intro
Mohammad Shaker
 
The Ring programming language version 1.8 book - Part 95 of 202
Mahmoud Samir Fayed
 
Dynamic virtual evironments
Виталий Чащин
 

More from eleksdev (10)

PPTX
Lecture android best practices
eleksdev
 
PPTX
Communication in android
eleksdev
 
PPTX
Hello android world
eleksdev
 
PPTX
Android location and sensors API
eleksdev
 
PPTX
Lecture java basics
eleksdev
 
PPTX
NoSQL basics
eleksdev
 
PPTX
tsql
eleksdev
 
PPTX
sql introduction
eleksdev
 
PPTX
If unit2 summary
eleksdev
 
PPTX
Uml
eleksdev
 
Lecture android best practices
eleksdev
 
Communication in android
eleksdev
 
Hello android world
eleksdev
 
Android location and sensors API
eleksdev
 
Lecture java basics
eleksdev
 
NoSQL basics
eleksdev
 
tsql
eleksdev
 
sql introduction
eleksdev
 
If unit2 summary
eleksdev
 

Recently uploaded (20)

PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
The Future of Artificial Intelligence (AI)
Mukul
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 

G rpc lection1

  • 2. Create Solution with class library for stub code (named Greeter)
  • 3. In a class library: • Create Folder “protos” – for server interface and types descripted files. • Create Folder “gen” – for generated by grps tools code. • Add new item to project – “generate_protos.bat” file • Remove useless Class1 file
  • 4. Add such gRPC nuget references: • Grpc.Core (v 0.14.0) • Grpc.Tools (v 0.14.0) • Google.protobuf.custom (v 3.0.0 beta-2
  • 5. Now project looks like this:
  • 6. Create proto file • In a “protos” folder create “helloworld.proto” file. • Add Server interface and types code to proto file (next slide)
  • 7. Proto file content: syntax = "proto3"; option java_multiple_files = true; option java_package = "io.grpc.examples.helloworld"; option java_outer_classname = "HelloWorldProto"; option objc_class_prefix = "HLW"; package helloworld; // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; }
  • 8. Create bat file for generating stub code from proto file • Add to project file “generate_protos.bat” file • This bat will run gRPC code generating tools with argument proto file
  • 9. Generate_protos.bat content @rem Generate the C# code for .proto files setlocal @rem enter this directory cd /d %~dp0 @rem set TOOLS_PATH=..packagesGrpc.Tools.0.14.0toolswindows_x86 set TOOLS_PATH=..packagesGrpc.Tools.0.14.0toolswindows_x86 %TOOLS_PATH%protoc.exe -I protos --csharp_out gen protos/helloworld.proto --grpc_out gen - -plugin=protoc-gen-grpc=%TOOLS_PATH%grpc_csharp_plugin.exe endlocal
  • 10. Generating stub code: • Run cmd, go to generate_protos.bat location • Run generate_protos.bat • Open “gen”, see newly generated files appeared • Add new files to project • Build Project in x86 configuration
  • 11. Add Server project • Add “GreeterServer” visual C# console application project. • With nuget package add Grpc.Core (v 0.14.0) package. • Reference “Greeter” project to GreeterServer project • Add using Grpc.Core and Helloworld. • Add GreeterImpl class to Server project code class GreeterImpl : Greeter.IGreeter { // Server side handler of the SayHello RPC public Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context) { return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); } }
  • 12. Modify Program.cs class Program { const int Port = 50051; static void Main(string[] args) { Server server = new Server { Services = { Greeter.BindService(new GreeterImpl()) }, Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Greeter server listening on port " + Port); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); } }
  • 13. Add Client project • Add “GreeterClient” visual C# console application project. • With nuget package add Grpc.Core (v 0.14.0) package. • Reference “Greeter” project to GreeterServer project • Add using Grpc.Core and Helloworld.
  • 14. Modify Program.cs class Program { static void Main(string[] args) { Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure); var client = Greeter.NewClient(channel); String user = "you"; var reply = client.SayHello(new HelloRequest { Name = user }); Console.WriteLine("Greeting: " + reply.Message); channel.ShutdownAsync().Wait(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } }
  • 15. Build and Run • Build entire solution in x86 configuration, see it is building without errors. • Run GreetingServer and GreetingClient • See GreetingClient receives response.
  • 17. Практичне завдання: • Базуючись на попередньому Helloworld прикладі • Створити клієнт серверну програму, яка використовуватиме gRPC для комунікації • Вид аплікації – це система для офіціанта в кафе, де він записує замовлення, клієнтів і т.д. • Для gRPC методів можна використовувати прості типи (тільки string, як в прокладі ) • Ця практична використовуватиметься як база для наступного практичного завдання