Hello and welcome to the Golang programming language course.
In the previous session, we talked about some concepts of PC and indecision.
We want to talk about the others G.R. PC concepts.
Defining services.
In G.R. PC, a client application can directly call a method on a server application on a different
machine as if it were local project, making it easier for you to create distributed applications and
services.
As in many are, peace assistant G.R. PC is based around the idea of defining a service specifying the
methods that can be called remotely with their parameters and return types.
On the server side, the server implements these interface and runs a G.R. PC server to handle client
cards.
On the client side, the client has this to refer to as just the client in some languages that provides
the same methods as a server.
Do your PC clients and servers can roam and talk to each other in a variety of environments, from servers
inside Google to your own desktop and can be written in any of your PCs supported languages?
So, for example, you can easily create the GOP server in Java with clients in gold, python or ruby.
In addition, the latest Google API will have a G.R. PC version of during their faces, letting you
easily build Google functionality into your applications.
Defying that protocol fine.
By default, G.R. PC uses protocol buffers, Google's major open source mechanism for serializing a
structured data.
The first step then working the protocol buffers is to define the structure for the data you want to
serialized into a port of fire.
This is an ordinary text file with a dot proto extension protocol.
Buffer data is a structure, as messages for each message is a small, logical record of information
containing a series of name value pairs called feeds.
Here is a simple example message a student message search.
Then, once you have a PC, find your data structures.
You use the protocol buffer compiler portable to generate data, access classes in your preferred languages
from your reported definition.
These provide simple accessories for each field like name and set name, as well as methods to serialize
past the Hulu structure to from robots.
So, for instance, if you'd chosen languages, go land, grind the compiler and the example above will
generate a class called the student.
You can then use this class in your application to populate, serialize and retrieve student protocol
buffer messages.
You defined job services in all in report to find with RBC method parameters and reason tolerance is
specified as a protocol for messages.
For the example, we can create another message like search for the parameter as request.
Now you can create a service for your PC.
So right service, a student service and right your job, your senior thoughts.
Then you define RTC methods inside your service.
Definition is specifying the request and response times.
G.R. Pieces Service told.
It lets you define four kinds of service method.
A simple RTC where the client sends a request to the server using the S2 and waits for a response to
come back.
Just like a normal function.
Com Now you can see the syntax.
A server side is threatening our PC, where the client sends a request to the server and gets a stream
to read a sequence of message back.
The client reads from the returned stream until there are no more messages.
Results are estranged rather than return at once.
Now you can see the syntax.
A client site is training RTC.
Then the client writes a sequence of messages and sends them to the server again using a provided stream.
Once the client has finished writing the messages, it Vespas the server to read them out and returns
its response.
You specify a client side the streaming method by placing the estranged keyboard before the request.
Type a bi directional streaming RTC where both sides send the sequence of messages using a read virus
stream.
The two extremes operate independently so clients and servers can read and write in whatever order they
like.
For example, the server could wait for receive all the client messages before writing its responses,
or it could alternately read a message, then write a message or some other combination of reads and
writes.
The order of messages in each student is preserved.
US specify this type of method by placing the Edstrom keyboard before both the request and the response.
Create a method for G.R. PC service.
Now we define the method for our service.
Now you can see the syntax for student service.
DARPA uses Pro with a special DARPA plugin to generate quote from your approach of fine.
You get generated DARPA, the client and server code, as well as regular protocol Boffa code for populating,
serializing and retrieving your message types.
So we designed a method inside the G.R. PC service that is supposed to return a student based on its
build of a student.
It's not very that within the service, the input parameter and the region and value are both of the
message type this that profile exposes our student service, which features a solitary get to student
function, which can be caused by any job decline written in any language.
These dark portal definitions are typically share across clients of all shapes and sizes so that they
can generate their own code to talk to our job, etc..
You can generate the go in specific G.R. PC code using the Pontotoc tool in two ways.
You can see the syntax after executing advanced comment.
You'll see this will have generated A-student Dot PBE Dot Go Fine, which will contain generated code
for us to easily call within our code in order not to prolong the time of decision to be finished,
and we will continue the content in the next session.
Goodbye.