SlideShare a Scribd company logo
1 of 17
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

What's hot

Professional Help for PowerShell Modules
Professional Help for PowerShell ModulesProfessional Help for PowerShell Modules
Professional Help for PowerShell ModulesJune Blender
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)iFour Technolab Pvt. Ltd.
 
Fluentd v0.14 Overview
Fluentd v0.14 OverviewFluentd v0.14 Overview
Fluentd v0.14 OverviewN Masahiro
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorialtutorialsruby
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIOliver Busse
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12N Masahiro
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldSATOSHI TAGOMORI
 
Fluentd at HKOScon
Fluentd at HKOSconFluentd at HKOScon
Fluentd at HKOSconN Masahiro
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsWinston Hsieh
 
Powershell Training
Powershell TrainingPowershell Training
Powershell TrainingFahad Noaman
 
OpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionOpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionPaul Withers
 
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)Ontico
 
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
[네이버오픈소스세미나] What’s new in Zipkin - Adrian ColeNAVER Engineering
 
What is new in Go 1.8
What is new in Go 1.8What is new in Go 1.8
What is new in Go 1.8John Hua
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in pythonJimmy Lai
 
Introduction To Windows Power Shell
Introduction To Windows Power ShellIntroduction To Windows Power Shell
Introduction To Windows Power ShellMicrosoft TechNet
 

What's hot (20)

Professional Help for PowerShell Modules
Professional Help for PowerShell ModulesProfessional Help for PowerShell Modules
Professional Help for PowerShell Modules
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
Fluentd v0.14 Overview
Fluentd v0.14 OverviewFluentd v0.14 Overview
Fluentd v0.14 Overview
 
Sql killedserver
Sql killedserverSql killedserver
Sql killedserver
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing World
 
Fluentd at HKOScon
Fluentd at HKOSconFluentd at HKOScon
Fluentd at HKOScon
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Powershell Training
Powershell TrainingPowershell Training
Powershell Training
 
OpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionOpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview Introduction
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
 
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
[네이버오픈소스세미나] What’s new in Zipkin - Adrian Cole
 
What is new in Go 1.8
What is new in Go 1.8What is new in Go 1.8
What is new in Go 1.8
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
 
Introduction To Windows Power Shell
Introduction To Windows Power ShellIntroduction To Windows Power Shell
Introduction To Windows Power Shell
 

Viewers also liked

G rpc lection1_theory_bkp2
G rpc lection1_theory_bkp2G rpc lection1_theory_bkp2
G rpc lection1_theory_bkp2eleksdev
 
Frontend basics
Frontend basicsFrontend basics
Frontend basicseleksdev
 
SDLC. QA Role
SDLC. QA RoleSDLC. QA Role
SDLC. QA Roleeleksdev
 
Advanced styles
Advanced stylesAdvanced styles
Advanced styleseleksdev
 
Windows service
Windows serviceWindows service
Windows serviceeleksdev
 
Web service lecture
Web service lectureWeb service lecture
Web service lectureeleksdev
 
Improving rpc bkp
Improving rpc bkpImproving rpc bkp
Improving rpc bkpeleksdev
 
SDLC. PM Role
SDLC. PM RoleSDLC. PM Role
SDLC. PM Roleeleksdev
 
Aspnet core
Aspnet coreAspnet core
Aspnet coreeleksdev
 
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...eleksdev
 
SDLC. BA Role
SDLC. BA RoleSDLC. BA Role
SDLC. BA Roleeleksdev
 
SDLC. UX Role
SDLC. UX RoleSDLC. UX Role
SDLC. UX Roleeleksdev
 
Angular. presentation
Angular. presentationAngular. presentation
Angular. presentationeleksdev
 
Css animation, html5 api
Css animation, html5 apiCss animation, html5 api
Css animation, html5 apieleksdev
 
SQL Grouping, Joins
SQL Grouping, JoinsSQL Grouping, Joins
SQL Grouping, Joinseleksdev
 
SQL: Indexes, Select operator
SQL: Indexes, Select operatorSQL: Indexes, Select operator
SQL: Indexes, Select operatoreleksdev
 
Sql 04n edited
Sql 04n editedSql 04n edited
Sql 04n editedeleksdev
 
Version control
Version controlVersion control
Version controleleksdev
 

Viewers also liked (20)

G rpc lection1_theory_bkp2
G rpc lection1_theory_bkp2G rpc lection1_theory_bkp2
G rpc lection1_theory_bkp2
 
Frontend basics
Frontend basicsFrontend basics
Frontend basics
 
Rpc
RpcRpc
Rpc
 
SDLC. QA Role
SDLC. QA RoleSDLC. QA Role
SDLC. QA Role
 
Advanced styles
Advanced stylesAdvanced styles
Advanced styles
 
Windows service
Windows serviceWindows service
Windows service
 
DAL
DALDAL
DAL
 
Web service lecture
Web service lectureWeb service lecture
Web service lecture
 
Improving rpc bkp
Improving rpc bkpImproving rpc bkp
Improving rpc bkp
 
SDLC. PM Role
SDLC. PM RoleSDLC. PM Role
SDLC. PM Role
 
Aspnet core
Aspnet coreAspnet core
Aspnet core
 
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
 
SDLC. BA Role
SDLC. BA RoleSDLC. BA Role
SDLC. BA Role
 
SDLC. UX Role
SDLC. UX RoleSDLC. UX Role
SDLC. UX Role
 
Angular. presentation
Angular. presentationAngular. presentation
Angular. presentation
 
Css animation, html5 api
Css animation, html5 apiCss animation, html5 api
Css animation, html5 api
 
SQL Grouping, Joins
SQL Grouping, JoinsSQL Grouping, Joins
SQL Grouping, Joins
 
SQL: Indexes, Select operator
SQL: Indexes, Select operatorSQL: Indexes, Select operator
SQL: Indexes, Select operator
 
Sql 04n edited
Sql 04n editedSql 04n edited
Sql 04n edited
 
Version control
Version controlVersion control
Version control
 

Similar to G rpc lection1

ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveJon Galloway
 
A New Chapter of Data Processing with CDK
A New Chapter of Data Processing with CDKA New Chapter of Data Processing with CDK
A New Chapter of Data Processing with CDKShu-Jeng Hsieh
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developerPaul Czarkowski
 
ConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello WorldConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello WorldMaarten Balliauw
 
Development Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesDevelopment Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesPantheon
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays
 
NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017Maarten Balliauw
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsMichael Lange
 
Native client
Native clientNative client
Native clientzyc901016
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsJulien Bataillé
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroMohammad Shaker
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 

Similar to G rpc lection1 (20)

ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep Dive
 
Jenkins' shared libraries in action
Jenkins' shared libraries in actionJenkins' shared libraries in action
Jenkins' shared libraries in action
 
A New Chapter of Data Processing with CDK
A New Chapter of Data Processing with CDKA New Chapter of Data Processing with CDK
A New Chapter of Data Processing with CDK
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developer
 
ConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello WorldConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello World
 
Development Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesDevelopment Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP Libraries
 
Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
 
NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
Native client
Native clientNative client
Native client
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL Endpoints
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - Intro
 
GradleFX
GradleFXGradleFX
GradleFX
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Gradle
GradleGradle
Gradle
 
Dynamic virtual evironments
Dynamic virtual evironmentsDynamic virtual evironments
Dynamic virtual evironments
 

More from eleksdev

Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practiceseleksdev
 
Communication in android
Communication in androidCommunication in android
Communication in androideleksdev
 
Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Android location and sensors API
Android location and sensors APIAndroid location and sensors API
Android location and sensors APIeleksdev
 
Lecture java basics
Lecture   java basicsLecture   java basics
Lecture java basicseleksdev
 
NoSQL basics
NoSQL basicsNoSQL basics
NoSQL basicseleksdev
 
sql introduction
sql introductionsql introduction
sql introductioneleksdev
 
If unit2 summary
If unit2 summaryIf unit2 summary
If unit2 summaryeleksdev
 

More from eleksdev (10)

Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
 
Communication in android
Communication in androidCommunication in android
Communication in android
 
Hello android world
Hello android worldHello android world
Hello android world
 
Android location and sensors API
Android location and sensors APIAndroid location and sensors API
Android location and sensors API
 
Lecture java basics
Lecture   java basicsLecture   java basics
Lecture java basics
 
NoSQL basics
NoSQL basicsNoSQL basics
NoSQL basics
 
tsql
tsqltsql
tsql
 
sql introduction
sql introductionsql introduction
sql introduction
 
If unit2 summary
If unit2 summaryIf unit2 summary
If unit2 summary
 
Uml
UmlUml
Uml
 

Recently uploaded

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

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, як в прокладі ) • Ця практична використовуватиметься як база для наступного практичного завдання