Getting Started with gRPC in .NET 8 | protobuf service

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's get start Demo First of grpc in net 8 so here I just build one uh sample application of grpc in net 8 and it is just uh getting started so here uh I just created you know the postman collections over here we can just get uh the send the request and get the response so this is my first uh service over here which is a hello world right and it is expecting in know one parameter so I'm just giving this you know some example over here this is a getting started in net8 right and once I invoke so I'm getting that response right so if you see this is that project look like so everything will will explain like what is that grpc in net how we can build it and what is the benefits and what are right why we have to require this things so everything we will discuss over here uh of the starting point right and once we'll complete the definitely we will create another session where we will complete uh the complex one in real world example as well right so uh let start to implementation so before start implementation I'm especially recommend if you visit first time my channel so this is my channel net example and you can go through my you know all other session which like that you know if you don't know as a Blazer so complete that Blazer session and then if you don't know about that you know uh net core web API clean architectures and deployment in Azor you know multicontainer you know if you want to know about the docker and all right so you can just learn in know as a net buack developer you can learn all the stuff from here right so yeah once you uh go through that's fine but yeah we have moving to that start implementation so first what I need to do let me open a visual studio quickly and I will just create a new project and I already actually installed visual 2022 so make sure just installed and uh select that you know workload whatever that workload over there right for. net so once you select it so definitely you will get the template grpc so you just look for the grpc and this is that you know grpc right sp. net code grpc service and why we required what is that don't worry we'll explain once I create that so let me create that and here we can just set that name so what would be my project name this could be you know grpc uh getting started and then simply just adding this right as the locations and select next and then nothing we have to choose over here this is a default setting so create so now uh the default template has been created uh this is a looks like some project fer structure right and don't worry we'll explain everything what are there right so first we have to know about that what is actually grpc right so that is important so grpc is the high performance remote procedure call RPC framework developed by Google it's allow allow you to define a service interface in a Proto file and generate client and service code for this multiple language including cop Java Python and many others right so like that uh don't worry uh as of now this is just other file also which we have to implement right so this is called actually a Proto file and declaration file and implementation file and other other things if I talk about like for example in net grpc provide a simple and efficient way to build the scalable scalable and secure apis it's use http2 as the transport protocol which is allow for the multiplexing com uh multi uh multiplexing multiple request over a single connection reduce overhead and improving the performance right so this is that overall over here and now I'm moving to over here actually why uh we do why do we need right so before that I just explaining actually what are the project structure and all right so if you see this is a simple project structure right so it have that Proto uh property file this is a Proto Proto folder right so this is actually we have used that service which actually we have to Declaration on right so that we have to keep it over here and this is a Services where we can actually whatever Services we have to declaration that we have to implementation in this service and this is a normal our structure like application. Json file and this is our sta files right so this is a folder structure right and then if I talk about little bit about that know files like for example that grid dot uh Proto right so what is that actually so what actually they do this file Define the service interface using protocol buers as a know Proto and it specific specify the method and message for example see it just declare the method and then whatever request type and the response type right so those are things we have to Define over here as a uh make up to our service right and also if I talk about this so This is actually just as a syntax we have to Define uh what is that our uh prototype version right so that we have to set it over here so this is a defining and also we can just import whatever name space so like that we can name space and also this is a package so whatever package we requir so we can it is and this is just a service name so this is our service name which will once I create it it will automatically generate a service right so that I will show you in later but yeah this is that one uh that grit and Proto service right then if I talk about this guy right so greater do service so this file contain the implementation of the service right so if I let me open this guy and it's provide the logic for that service method defined in the Prototype file so whatever this prototype file right so this is our prototype file and we have to just you know uh they will just inherit over here and whatever that method the Declaration right we have to just implementation like that right so see we just actually override that method if you see I'll show you for example if I just try to override and once you see you will get that method like say hello world but already is there that's why it's not showing but yeah uh let me comment it as of now and once I comment let override and then say hello see I just got this method and once I Implement so they will give that default implementation right so like that actually whatever the Declarations we can get it over here and we can start our implementation so let me UNC commmand that so this is all rest of things will be same there's nothing uh important but yeah if you go to that program. CS file all that other you know that is fine but yeah only just here they using that you know extension method of add grpc right and then yeah then also whatever service we have to just create it we can just use this app. map grpc we have to register like that right for that request pipeline and finally whatever running uh you know that running uh application will be get returning so this will be returning actually right so default message will be returning so let me quickly run and show you my service is running over here and if I go click that guy open a browser so see once I open a browser it is just returning whatever that you know I map endpoint we have and uh set it right so they actually returning like that right this simply but if I want to call this guy so actually we have to use this is actually server right so we have to required as a client so we have to add a reference of this service and then we can use it so for example I have a console application or our our other application for example web application so we have to consume this service so as like uh previously we use on WCF service right so like that simply we have to just consum in our client right and we can use it as a service but yeah as of now what I will show you I'll show you in a postman how we can get it that uh get that send that request and get the response right so let me open a postman and here let me create new and it is not over will it will not send over that sttp uh request okay so this will be used you know this one the grp service which will available in Postman so once you click this guy so here two things right so see they asking that whatever your url right so whatever our URL endpoint so my URL endpoint this guy right so don't use that HTTP because we it will not work on the sttp so only just Define with this local host and then whatever Port right so you have to Define that and then if you first time so if it will ask okay whatever your protuct of file right so there is a three way actually they can use use as a Proto bull API or and a Proto file and use the server reflection right so as of now I will use this in a Proto file right so let me click that and then where is your project right so go to that project location go to here and my project location is this guy right uh grpc service getting service which I just created go to that here you have to go to that know Proto folder go to that Proto folder this is actually our Proto file so choose this guy once I choose if you once I choose if you see this is just selected over here and just simply import so once I import this file now once I click that over here you will able to see whatever service over there you will get it right so let me quickly select this guy and go to this message as of now I will just use message but yeah later on we'll use authentication authorization as well like authentication tab but yeah uh and what is that message so if you go back over here this prot file so the message is expecting know hello request right so here see this is that request right also I missed that part I guess so yeah uh we can Define as a suppose I declare as a service uh the say hello and it is expecting request and response right so whatever request this is a request and this is response it is a very clear right and then I just Define okay this is the request and this is the response and if you think about okay what what is that you know that property as a field is fine but why this Define this one right what is that so this is nothing if you think about let me explain something for example I have another field right or another field right and here uh J decide decide this order so whatever the order you want to proceed that property so that actually we have to decide okay this is one this is two and this is three so like that we have to decide also as a request what is that order form right so that's why we have to Define one and similar the response also you can just Define this guy so this is request and response so as I see as as I as we see over here we requir the request right so what is the request request is simple as a name right which we pass as a Json format and response also will get as a Json format as a message right so let me pass it that me uh request for example we have to to decorate that as a and what is my field name this is my field name and then just pass it to okay uh getting started with grpc in.net 8 and then invoke once you invoke now I'm getting that you know uh the response over here correct and then also if I want to debug so let me quickly debug as well I'll show you so I will put the debugger Point inside that implementation over here so let me put the debugger point and let me quickly hit one more time H enter so once you enter see enter you will get that deing over here and then proceed and then continue and it is just see it is automatically go to that you know uh that file autogenerated file see this is that autogenerated file right and it is inside this you know Proto and generated and it will go to over here and it will it will actually deize and get back the response see so it is returning and then finally you get back that get back that response right so like that actually it is working and one more thing actually I miss actually why do we need actually that grpc because we as like I know we we can see okay this is we can handle also in our uh API things right so why do we need need so why do we need actually there's a many many actually there's a many reason so there's a could be know high performance this is actually allowed to the high performance scalability security interoperability strongly type efficiency realtime data processing microservice architecture Cloud native and future proofing so those are actually the point the keys actually that's why we have to use I know that's why we have we need to use actually that grpc so if I talk about you know few of that you know details for example high performance so grpc provide a high performance RPC framework that can handle a large number of requests and response efficiently this is practically important in the scenario where real time data is being transfer or process so this is the one of the thing and also scalability also you know why the scalability happen and and the main things actually I will would like to describe over here that real data time processing so grpc is a well situated for realtime data processing and streaming which is particularly important in the scenario where data needs to be the process in the real time right so those are actually important part right that's why we have to use the grpc so that's a good service we will uh we have to do many many things in upcoming session as well like how we can use that you know the complete how we can add know that another service and integrate that you know card operations right and how we can integrate in this in a clean architecture how we can use that other like EF core and all everything right so that we will do in upcoming session so till now thank you have a nice day and don't forget to like subscribe and share for this more motivations
Info
Channel: DotNet Real world example
Views: 247
Rating: undefined out of 5
Keywords: grpc in net 8, getting started with grpc, protobuf service, grpc tutorial, net 8 grpc, grpc net 8 tutorial, protobuf net 8, grpc service, net 8 grpc service, grpc protobuf, net 8 protobuf, istio grpc, grpc api gateway, grpc Kubernetes, grpc microservice, grpc api testing, grpc, What is gRPC and How to Use it in .NET Development, How to Implement gRPC in .NET Core for Better Performance, Why to Use gRPC for Building High-Performance .NET Applications
Id: _RqHAh7dhTs
Channel Id: undefined
Length: 15min 26sec (926 seconds)
Published: Sun May 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.