Okay. So other alternatives, we already mentioned Trest and GraphQL. Maybe for people who saw it before, there is SOAP. I personally haven't used SOAP myself. So I can't talk about it with a big confidence. So for the transport protocol for low level communication techniques, you can actually choose much more than just HTTP or HTTP2. So nowadays, actually, there is also HTTP3. And I think up to HTTP5 is already in beta, you can choose. But you can also choose to use some other protocols like just directly TCP or UDP, or in case of server to client communication, it's also very nice to use some kind of bi-directional stream. For example, web sockets or server side events. And yeah, the point is that you always need a client library to do this communication for you. So in case of GRPC, it's not an exception, you will need this client. But you will take care about this client inside the framework itself.
Uh-uh, yeah, yeah, yeah, Bruno, indeed, yeah. Also, I know that this is about XML definition of services, but, honestly, I never tried it of course after I started my career, I think. Um, before I started my career. So let's talk about the features that the GRPC provides. Well, first of all, let's have a look at the code of this first touch of the code that we can see this protocol buffer format. And we're going to explore it in a bit. But here, we define in this protocol buffer, we define in a very concise syntax, we define what our service will do. And, uh, as you can see here, we define the package, package is just namespace, but more important for us is we define the service, give it a name, and then we give the, we define which methods our service will have. So we have with the keyword RPC, we define the methods, just hello, then we specify in this, um, argument, what type of data we'll receive as, um, uh, as, uh, parameters for this method. And we also specify what type of data it will output. So if you think this definition is really hello world only, um, it is hello world, indeed, but, uh, uh, there are real services definition are not much harder than that. So most likely, um, services are very tiny, uh, and that can be defined, this definition of services can be really, really small, and you don't need much to express what exactly your service will be doing. So most of the services definition will look alike, I would say, um, okay. So what now, when we looked at the example definition and you maybe have more, um, idea what, what it is, um, look like. So what then gRPC provides you, it provides you the strong type definition of services. It uses protocol buffers for that, but let's talk about it a bit later. And for client and server communication, I like that. I tried to explain before, you will need to use or generate code up front, so that's a needed step, let's say. By the way, it can be also generated for you on the runtime, and in most examples that we're gonna see in the second part today, it will be just generated on the fly on the runtime when your server starts. Yeah, but gRPC will generate this stuff for you. That's what I wanted to underline here. As we already saw in the official website, they support a lot of programming languages for you. Since it was in 2015, they even included Node.js originally in these supported languages. So, as you can see, it's quite extensively storied. And it also supports lots of environments. Where did I open my link? Just a second. Okay, here. So for the environments, that means that we can use it not only for like server-to-server communication, but you can also use it, for example, gRPC on a browser side. I think I haven't tried myself to use it on that. I know it's possible. They have a tutorial for that. I think it shouldn't be differed too much on what we have on the client side, on the server side. But just, I haven't used this particular gRPC web dependency myself. Yeah, extension points. So that's a part of what actually, with which you can extend your version of gRPC. Like you can design your communication, for example, to use web sockets. In this case, you will need to adjust your gRPC with a plug-in, gRPC integration with a plug-in. You will specify intermediate layer, which will convert the data for a web socket format and then send this data over web sockets, for example. And not only that. So you have, actually, you can extend it in any way you want, like you can add some additional validations and so on. So it's a very, very, very simple format. And I think the main reason for that is that you have this stuff generated anyways. And that means that for this stuff, you can register plug-ins and the plug-ins will be doing more job if you need it. But by default, you can just use it as a Blackbox and it will be already very, very good. It will include communication over HTTP2. It will give you the serialization. It will guarantee you the message ordering. That's what happens in the HTTP format itself. It will provide you a way for streaming. Are you familiar, by the way, with the stream pattern? Maybe type minus, if you haven't heard about streams before. Yeah. Bruno's question. Can GRPC be used on socket IO? Definitely it should be possible. But I haven't saw the implementations and I mean, yeah, you can't attach implementation for WebSockets and therefore, socket IO as well. It is a possibility, I would say. But yeah, extendable points is not what we're gonna cover today unfortunately. Yeah, and then asynchronous and asynchronous.
Comments