Hello and welcome to the gold and programming language course in the previous session, we talked about
some concepts obduracy, and in this session we want to do a geographic example.
Building in microservice and go like.
In this session, we want to implement your PC and practice for this purpose, we design an example
in this example, we want to implement the connection between the client and the server with the MySchool
database by G.R. PC service.
It's important to note that the client cannot communicate directly with the database, but the client
is connected to the server and the server is directly connected to the database.
The client sends its request to the server and the server analyzes them and sends the appreciated request
to the database and receives the response from the database and sends its response to the client.
Now it's time to go into the escort program and implement your example.
First, go to expel her and create a Prozac folder like named communication.
Create a folder inside it named Protocol.
And create a fight like a student with the poor, the extension site.
It's.
OK, so we define the syntax inside it and said it's value equal to proto three, which represent the
political buffer version.
So right syntax equals.
True to three.
Chroma semicon now define option and set go on the line package value, so bright option
go on the line package equals next.
This so to call the go on the line package option defines the import pass of the package, which will
contain all the generated code.
For this fine, the go package name will be the last pass component of the import pass.
In this example, we want the client to send two request to the server.
First, send the request based on the student's I.D. and receive information about that student and
second request based on sending a student name to the server and returning all the people who have that
name.
Since we know that the input parameters and return values in the methods of a service in PC are of the
message type, so we defined two messages as request and response.
We create a student messages response or return time and create a search message as a request or input
parameter for the student service functions.
Now defined message.
For example, you want to name it as students, so write the message.
Students
and defiantly variables first I.D. by Einstein, think a name by this string type and Third Age by the
end type.
So we ride in CC for I.D. and equals one.
A string.
Named vehicles two and and three to age equals three.
And define another message, for example, we want to name it, search by IED.
So we write.
This age of search by all.
And defined one variable for it, like named IED by N64 type and 64 either equals one and defined another
message, for example, you want to name it, search by name.
So you write message, search by name
and define Vong variable for it like named name Byte Eastern Time.
So write, it's strange.
Name equals one.
Now let's time to define a service us, specify a name service in your doctorate or fine, for example,
we create a service named Student Service.
So right?
Service
is to the service
in this time.
Live on to define to our PC methods and method is supposed to receive an ideas input parameter and returned
a student from the database.
And the other method is supposed to get a student name as input parameter and display the least of all
the students in the database that have that name.
So Brian R. P. C Smith, the name for methods like kids, a student by IED.
Sit input parameter.
Because in this case, we want to get a student base I.D. the use from search by I.D. message,
search by I.D. and returns.
And sit a student message as return type.
And secured rockets and defined and automated.
RBC said the name formatted like get a students by name.
Yeah.
A few things by name.
SIP input parameter, because in this case, you want to get all the students have a same name so of
use from search by name, age, search by name, you see and returns.
And because we want to fetch lists of students, some someone, we use a stream of a student's message
as return time, so we ride as train students and search other places.
How we could define two service functions in order to be able to use our service functions in stages,
we must first compile needs when we compile it a file with the extensions Dot P.B. Dot Go is created
inside the project, which is the equivalent of the messages and service methods, and we will access
the components in the portal to fine.
Now it's time to compile our Port of Fire to create the equivalent goal and find first up the truth
of it and then create job security.
Let's go with the command line, right?
See the communication
protocol.
Dash, Dash, go on there, a school out equals four destination.
You said don't.
And four source pass go to the protocol package in college student and Porto.
Fine.
Parental and student portal and run the comment.
Now we can see the student find that portal is created and run command for generate G.R. people to fire
so bright politics.
Dash, Dash, go dash to your PC, Andrew Scott House equals set destination dot and for source pass,
go to the protocol package and call student that pro to find.
So we write protocol and the student protocol run the command.
OK, we see that two funds was created in the Project Pass, which we can use to exchange our data.
That's called student and a student on their school G.R. PC with the P B that go extensions.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.