What is Google Protocol Buffer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello people welcome back to my channel and let's see what is Google protocol buffer so you must have heard about this rest API term and then this graphql and in conjugation with all these terms you must have also heard about this Google protocol buffer and grpc servers so let's learn some details about the Google protocol buffer which Powers the grpc servers so it is developed by Google so this particular uh framework you can say or software or you can say a protocol was B basically developed by Google and the Google protocol buffer helps you to Define your structure so the most important thing that it uh helps you is to do the structure definition for your data like you have Json from Json you can Define your data there's XML from that also you can Define your data same way Google protocol buffer also helps you to define the structure of your data it helps to define the contract between the client and the server so whenever you design an application it is always is a client and server base there's a server and there's a client client calls the server and basically server responds to the API call or you can see the request so it helps to define a contract between client and the server so let's say there's a micros service it can be any learning management system it can be a payment system anything and this microservice exposes some API so there will be a API one request and API 1 response same way there will be API 2 request and then API 2 response what Google protocol buffer helps you to do is it helps you to define the contract like the API 1 request contract would be there and API one response contract will also be there and all the clients need to adhere to that contract so that everything works in a seamless manner so this is basically for defining the contract between the client and the server so let's take an example of user registration system so you are trying to create a application where you want to register some user so there's a user and there are some properties associated with that user so there can be a first name there can be a last name there can be a email password phone number age and then address so these are different fields that you want your user to have and you also want that whenever a client is calling you so these are the fields that need to provide every either everything can be mandatory or like few things can be mandatory so this Google protocol buffer will help you to Define this contract or the structure of your data so you will Define something like this the contract will be defined as a message the name of the contract that is create user request then the first name last name email password phone number age and address and you also Define the data type here I have kept it simple like for age also I'm taking it as a string but you can treat it as in32 or something else we'll see later like what are the different data types that are defined by Google protocol buffer and there's 1 2 3 4 five six namings or you can say positions given which has importance using serial and deserialization of the data we'll see that also so this is the message that we Define and it is a contract that the server and the client need to add here that okay there's a create user request so all these fields are necessary if you send any unwanted field then that will not be respected by the server and your request will be rejected or that field will not be consumed into your database or into your server so Google protocol buffer is language neutral what does that mean is you define the contract once in the Google protocol buffer file and the extension is do Proto file so you write your definitions there only once and then you generate language specific code bases from the Proto file using the protoc compiler so once you define the contract that's it you are done with that and then for any language Let It Be nodejs python Java golang anything you just need a protoc compiler for that usage and then using that protoc compiler you can generate the classes for your different languages so let's say there's a employee Proto and there's a Proto compiler so the Proto compiler is also given by Google itself and you can use it to generate different uh files so there's a contract in Java there's a contract in C++ there's contract in Python so you are using one employee. prototo file and using that you can use the Proto compiler which will help you to generate the contract in Java contract in C++ and contract in Python we will create more videos on that like how you can use protobuf for different languages you'll see that later on but for now you need to understand that it is language neutral you define a single employee. Proto file and using this protoc compiler you can generate stubs for different languages and you can use it easily okay so next thing is what it is fast as compared to Json so Json is also used for transferring data from the client to the server or among different servers this is the most widely used thing like Json which is used mostly in Dr API architecture so Json is also used to define the contract but protocol buffer is fast and compact so where uh the protocol buffer has Advantage it is fast and it is compact but Json is not fast and compact so unlike XML and Json which are human readable so you can just see the data when you are passing between the servers like if it is XML or Json you can just see the data and read it but protocol buffer uses binary format so there's a serialization and der serialization happening in the background which converts it into a binary format which is more Compact and faster so let's say there is a 1 KB of data 1 kilobyte of data so if you're trying if you're using Json or XML it would be more than 1 KB or it would be around 1 KB but if you're using protocol buffer so it will be less than the 1 KB size because it is in binary format it uses interface definition language so there's a language definition provided by Google through which you can write your Proto buff files or do Proto files so the contract of the protocol buffer is defined using a standard language definition called interface definition language so this is one example like if you want to define a employee contract then it will be a message employ and then you can provide Name ID email and you can also say Okay string is the type in32 is the type then string is the type for email it is a optional field it is a required field everything you can provide here let's go to the browser here and let's search for Google protocol buffer so the first thing is what protocol buffers uh and this is protocol this Proto buff. Dev is the site and you can see the whole documentation is present here related to different languages also C++ C.O so there's one file only. prototo but you can use the generated classes or other things for multiple languages and you can use it so you define a simple let's say message is the person and then you can just when you compile it using the protoc compiler you will get a builder file and you can use to build person object so in Java in C++ you can use it in this way so if you go here there is language guide for Proto 2 and Proto 3 so these are the different uh semantics where or different Proto version language definitions so you need to use Proto 3 because this is most recent one so you can go through this documentation and see what are the different things that are present let's say for example if you want to see scalar type value so what are the different scaler type values is double float in 32 and how it is used in different languages it is present here so when we'll create some projects using Google protocol buffer in the next videos I'll be creating a user management system in Java using this Google protocol buffer so you can use it and understand what are different scalar value types what are default values what are imtion you will see all these things in the later videos you can go to my website that is self.in and and here you can read through new blog post that are coming if you want to learn this Google protocol buffer so I've already written a blog post here that is if I search protocol and what is protocol buffer so the whole details are listed here all the diagrams and everything are present so you can go through this also to understand more so hope you like this video on the protocol buffer this is the simplest video to understand what is protocol buffer we'll go into the details in later videos so thank you for watching my video if you want to support me you can go to my Channel or any video and use this thanks button to support me and please share these videos with other people thank you very much
Info
Channel: CodeWithRajRanjan
Views: 75
Rating: undefined out of 5
Keywords: protocol buffer, google protocol buffer, java protocol buffer, python protocol buffer
Id: th9VAfruKSY
Channel Id: undefined
Length: 8min 41sec (521 seconds)
Published: Fri May 10 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.