 All right, I think we're we're up and running. Well, good day everyone. Thank you for joining us Rob Sidor I'm a chief architect here at Red Hat for application development and My partner in crime Jeremy I also an architect at Red Hat Right and Ian Yeah, hi guys. I'm a Developer applicant now even though I was a solution architect for 10 years. So I'm still getting used to Saying for good instead of solution after yeah Yeah, I don't I don't get to see too many developer advocates. I mean we see You know folks all the time like Eric DeAndrea and Daniel Oh and stuff is the same kind of thing. Yeah. Yeah similar. I mean I because I come from a solution architect background I'm more sort of what he was the phrase customer friendly I Don't immediately jump up and down and start screaming about tech, but it's it's a wonderful role because I get to talk about the stuff I love without worrying about selling it for a change. Well, that's cool because today What we're gonna talk about is GRPC which I hope that's why people would join or view this later and the reason why we're talking about GRPC is because The genesis of this was that We go to a lot of customers and you know, we get to talk to a lot of people and as they're doing microservices and getting into that It becomes a very common question, you know, when should I use rest? When should I use Kafka? When should I use GRPC? When should I use graph QL that kind of thing? so the last session we did was on rules the road for rest and so we're following this up with GRPC and While we're not talking about Red Hat specific technology per se, we're we're gonna demonstrate How to do it kind of the hard way and then how to do it with corkis. All right, which makes it look like a lot easier for us. So That that's pretty much the genesis of that What we find is is that GRPC is becoming more and more popular especially Even in the dotnet community the Java community. It's way beyond just go any longer heck just the other day I was Trying to figure out how to get it all working properly with rust so if you can imagine so there you go I don't know if you guys have have you seen similar things? Is it the same kind of? I'm not sure what goes on and I mean Jeremy is in England right now and In I have no idea where you're I'm also in England, but I mean As far west as you can go before ending up in Wales No, I tend to see it a lot in customers But it tends to come from customers who who don't want to embrace the next generation arrest and stuff like that So they come from things like an old-school C++ background And those kind of days and they're more into the good old-fashioned RPC way of doing things We do tend to find an issue and I'd love if you cover a sort of discussion about this during this this conversation today But we do have a kind of the major issue We normally have is connectivity when you're running it as a container So if you're running it for example in a container running on Kubernetes You have to get into this whole whole sort of the Thor of node ports and stuff like that In order to be able to do the direct communications. So I'm genuinely because I I'm Tied a bit of background so I miss this I was a Die-hard Java programmer for a long long long long long long time I went through the pain. I guess you both did of JEE and J2 I've still got scars from J2 to be honest when everyone did and it whenever anyone says manage being persistence I get really upset and cry and go and sit in the corner So I come from a background of writing old-school Java, you know before all these wonderful annotations and all these caucus So I come from that kind of background But I'm really interested in seeing how you do the kind of RPC stuff from a caucus perspective, but I'm jumping ahead So yeah, it's very different. I've seen it mostly for performance people who are interested in performance the performance game So should we jump into this? Let's let's look Let's go So we're gonna do a little bit of a mixture here where we're gonna we have slides and we have a boatload of slides But we're not gonna really Go through all the slides per se. That's for your edification after the fact What we're gonna do is mix in the code in there so that we can talk about that and Yes, Ian I come from a 20-year plus C++ background And after C++ 11 it it became like a different language. It was more Java like yeah But then when I jumped into Java, it was in the days of EE 6 so I got the annotation I didn't do the J2E thing so I didn't feel your pain and What I'm discovering is that That's added into caucus and the CDI beans are pretty natural fit for a transition from somebody coming from Java EE or Jakarta EE so J2E I hear a lot of pain about it and I hear that's why everybody jumped on spring, but I didn't experience that so It's basically why everyone said the Java was slow when it wasn't And you know, I do a lot of pages nowadays about you know, please use caucus because It makes Java fast, but also it gets rid of those myths that used to be around from the J2E per EE time But I went through a period of writing. I actually shifted from J2E to net and that was back when dotnet It was C sharp actually had annotations before Java So it was very pleasant to come back to Java and see that annotations were there But again, if we go on to the caucus side, you know nine on seventy percent of stuff We do with caucuses is annotation based anyway. Yeah Oh, can you guys see my screen? Nope. No. No now we can. Yes. All right. Yeah. Okay. So this is my screen this is the palm file of a traditional and Rob, I'll hand this over to you. You just tell me what to click on here but this is a not chorus just a very typical way of building out GRPC using Java and I think maybe we'll start with some of the things you'll notice. There's a lot of stuff a lot of configuration In the side of here, right? So just stay there with the properties for a second go back up So so this is a regular palm file For just a plain old maven project that does GRPC without cork is and And There's really no discovery about the GRPC and protoc version. So on my machine. I have a Mac and one And if you just do a brew install, you're gonna get the latest, right? Unless you do it, you know it at a particular version You're just gonna get the latest and if you do brew install GRPC and you get the latest at the latest right at this moment is 1.55.1 and it installs Protobuf for you and we're gonna talk about what protobuf is but Think of GRPC as The RPC mechanism, right? It's a client server mechanism. It's a communication protocol Jeremy and I joked about saying this but for those of us that have been around the block It it's think of it like Corba if you're from a Microsoft world that was calm I think it was DCL or something RPC that ran calm underneath the covers and the Description language at the time was IDL for both Corba and calm And that's where it stopped and then you had to implement everything yourself and whatever particular language you were using in those old RPC mechanisms but when you install GRPC it comes with a whole bunch of functionality way above and beyond old RPC mechanisms and In addition to that the IDL is protobuf Or protocol buffers and it comes with a compiler for just about every language you can think of so Python You can do Kotlin, Scala Java go rust C++ C and it will create things for you if we're doing this with a Maven project We have to include all these Dependencies here in this standard Maven project to get there and you have to know the particular version that your target is And if you scroll down You get to this Exhaust this Maven plug-in here So this protobuf Maven plug-in what we want to do is actually detect the platform we're on Which can be a problem with particular versions because if you go back too long It doesn't support the M1 Mac and then other versions do support the M1 Mac So you have to figure out which ones which yourself and then it detects the operating system and it looks for the Protoc compiler to compile Stuff from your protobuffer or your proto file and then Antler we all know what that's just going to pull in our our generated classes, right so If you want to show the proto file that we're talking about Yeah, we should have the reason we're compiling all this stuff is we're going to define this We're going to define our objects inside this proto file and then it's going to compile everything you need for us, right? Yep, so what you're seeing here is we gave it a package The service Greeter service is actually the thing that is the service and in protobuf We're going to get into this a little bit We we're not going to pass just intrinsic data types. We're going to pass Types that are defined by us so the message We always have a request and a response and a good practice is actually to call it request and response Right, so we know what it is. Well, you'll also see that there's a an enumeration here So the one is a position. So if you are familiar with the old RPC mechanisms like Corba or calm, you know that those were actually tied to The order that things were put in and kind of a virtual stack and C++ in the background underneath the covers and That dictated the address in Memory of where those things were so we still kind of have that by giving it this enumeration But because it's hidden from you from a language perspective, you don't have to know about any of that in Java You just need to know that in there our proto file. We're we're gonna say so if we had Hello request and we had added a second element there. It would be number two right and then number three and number four kind of things so All that's doing is telling it what order and that's gonna come and play later when we decide You know how we're gonna version things and what what's a breaking change and what's not a breaking change When this this package don't confuse this with a Java package because this is a this isn't language Dependent if you want a Java package to work put your Java package as an option. Yeah Yeah, think of it. It's not quite like a namespace All right, so what do you want me to do here if we want me to compile this? Just before we go on just go jump in main really quick because we don't have that in corkis This is also some boilerplate code that we don't need to put in corkis now If we were really doing this in the wild We create a config file and we you know put the port number in there and a bunch of other things And then we would probably try to attach that to a service In kubernetes so that we could get the dynamic change, you know if I moved something or whatever Here we're just hard coding it because we're gonna run it and this is the most boilerplate of boilerplate code we could I have other code that can make this look really complicated But at the end of the day this this is really all that's up and running and then Jeremy's gonna compile He started a service. We used Just an arbitrary port number and I think you're gonna use postman We're gonna go to postman because postman has this really cool feature for gRPC So he already has a collection started. He's gonna go to 899 If he imports the proto file so when you're in postman, we figure most people are should be using postman When you want to add something new to the collection instead of saying a hdp rest endpoint You can actually choose gRPC now when you do new And then you can point it to the proto buff file the dot proto file and it'll get the definitions for us and there you go and Our actual work is done in this hello service, right? Yep Now you'll notice it's a little unnatural here because we have a void for the function and the first Element is the request and the second element is the response Right, we know Java does this by val by ref thing so You know for C++ programmers, it's not a pointer And in dot net it would be you know by ref I think you have to put the by ref keyword in there or something like that But anyway, the point here is is that we have a stream object for the response We're going to build the message out of You know our request and then we're going to say when it's completed you're done and then we exit the reason I say it's on naturals because we have that void in front of it and then you know your requesting responses are are in the function call so When we get to cork is it's going to look a Little more natural because it's going to look like a regular function definition We'll also see a couple other nice things. So now I yeah, I just recompiled You know I changed that to hello comma and add an explanation point Java I have to stop and recompile and so yeah, that's the thing Jeremy So you got to stop and recompile and then cork as we get the live coding thing going on So I think we're going to talk a little bit about that too So that's it. That's that's a basic Grpc with maven and Java. I know Ian looks pretty simple, right? Yeah, absolutely and we can make it way more complicated But cork is You know actually takes and simplifies that whole thing So I don't if you want to wait Jeremy or we can jump into that now Well, you want to jump in that right now you wanted some slides we want to look at well Yeah, I mean we got all these slides. So why don't we look at some of these slides? So All right, let me show you the screen again. I'll start here. Okay That's us we've already introduced ourselves. Yeah People aren't interested in some of this. All right. Okay, cool so last time we talked about rest and rest is really a resource-based mechanism and We're going to talk a little more later about the differences between rest and grpc There's you know pros and cons to each um, I would say for those folks that are probably coming from An environment where they had a monolith and they were trying to decompose it You know, maybe into hexagonal architecture or something but not going all the way into microservices We've had talks about that and what those decomposition patterns are and stuff like that um, but grpc represents a a great way for Basically a high performance communication Between your stuff that's more coupled right? um If we take a look at the things that are using grpc today And well if you're using containers at all they use it uses grpc under the covers if using kubernetes Uses grpc. So that's what all the communication is in It's very easy to version it It's very easy to control what you're doing and you know What you're running with uh grpc and it gives a bunch of performance enhancements that we're going to talk about a little bit um graph ql is basically a query language kind of mechanism that we would stick on to hcp Web sockets web hooks. We all know about that the thing at the bottom We try to avoid soap, but there's still a lot of people out there using soap The reason why i'm even including this on the diagram Is because people that were using soap were basically trying to replicate an rpc mechanism across hdp And they got into all this whistle definition in order to do that you had to have xml based definitions for all your data And everything else and you got into this morass of you know What's the difference between an exception and an error and what do I how do I handle that? and we redefined it over and over and over again And it only did hdp You know up to 1.1, right the same with rest today. It's hdp 1.1 and we're going to get into grpc's mechanism for using hdp 2 And um, we might even touch on later Maybe briefly touch on what's coming down the pipe, which is on the uh new standard for hdp 3 so um but right now Hdp 2 is going to give us a bunch of advantages. We're going to talk about a little bit I don't know if you got anything to you guys have anything to add I I hated soap. I hated it with all the passion that I could And and I was in Barcelona when don box from microsoft Um sat in a bath was wheeled out on stage and sat in a bathtub and gave the whole soap talk back in their early 2000s Um, that was the first real big soap talk. I don't know if you guys ever Googled for that look up don box and soap speech Barcelona he talked about soap and everybody loved it because It was a web-based kind of rpc ish mechanism, right? That's what everybody wanted, right? So Um, and it never fulfilled its promise. It just created super complicated life for us, but um, I could go on for the next 45 minutes. I guess about that but how much I disliked it I I still have soap. I still have soap ui on my desktop Seriously, oh, wow. Sorry, but it does rest now, doesn't it? About that What are my critical tools? Is it really? Yeah Do you have I mean are there that many people still using soap? I guess there's probably a lot of legacy code out there, right? Yeah, it's it's it's more to do with the legacy windows estates So there's a there's a huge amount of legacy dot net, you know dot pre dot net three estates, which are all based around soap Oh, I didn't know dot net was a soap. Could you do soap stuff? I never really did a lot of dot net but Yeah, well before dot net before before dot net became dot net core It was basically basically right on the website. So it was iis and the the soap interfaces and all those kind of things But there are a surprisingly large amount of systems out there that's still used so Really, okay All right, so, um Hopefully everybody feels as objectionable about it as I do but um, I I I am feeling like the Luddite now All right, we already we already did most of this stuff, right? We installed or we didn't show you blue install But yeah, you have to install the grpc, right? Yeah, you got to install grpc It'll have the it's it's it's required at runtime But um the protobuf compiler isn't required on a target machine um So, sorry, sorry a very dumb question from uh from the Luddite What does brew actually install there? So what what what makes grpc on the machine? Is it a set of? libraries Just think of it as libs. Okay um, if you're on the linux machine, it's going to install some libs um, they seem to have to be There is some compatibility required. I'm sorry. Yeah, does it bolt you to us to a specific version? Is that what you mentioned earlier that once you do the brew? I can have What I prefer to do is put it in you know do the development in containers You know in the old days we'd use virtual machines, but now you know containers And then just have the container versions what I've played with is um What's more important probably is having the same version of the protobuffers Right because that's how your definition is going to generate the code for you And Making sure that you're both using compatible protobuffers for the client server. Yeah You know, um for the generated code All right, so we mentioned that the quarkus is easier, right? So, uh, it Knocks a couple of these steps out, but it's it's fairly similar, right? Um, you'll need to install if you want to use the quarkus quarkus as a cli and a project generator If you want to use the cli you need to have that installed. Um, if not, you just use the generator You still define your service, right? That's going to go on with any language you use or toolkit and then Quarkus makes the compilation of code generation easier. So you can do it the same step that you just build everything And then you create your apps. So should we show off quarkus next? Yeah, so before we start that just jump over quick to the um code.corkus Um website Cool. So if you go here, what jeremy and I did to start this project off as we just chose the top one and added to the g rpc code So right, but if you scroll down There's actually a g rpc project that'll get you started Probably just search for g rpc. There you go. Oh, yeah. Yep. Oh and the camel one You know, i'm in love with that. Yeah, so, um um Yeah, I should send class hips in a A bottle of something every year. So, um, he does all the work at fabulous work on camel, but uh Yeah, so you can choose a g rpc project Uh, I would say the only caveat here is we're gonna have to add some stuff to your maven to pick up the generated files, but um We're gonna do that. Anyway, so if we jump into the code Let's go here. Let's let's create the project in scratch Yeah Oh, you're gonna generate it from scratch. Sure. Okay. Yeah, a directory. There's some other stuff in here I'll say aquarcus. I'll use the cli for this. Uh create app. I'll say come red hat Have corner and we'll say, um We call this g rpc Get a quarter And I I assume I assume that this is corpus three Yeah, uh, yeah, I don't know. Are you using corpus three? I am using corpus three Okay, cool Because I I switched to to using corpus three last week and all my java x dot stuff no longer can pass Oh, really? It's because it's moved to carter. Uh, right Oh the namespace changed, right? Yeah all the libraries changed Yeah And we actually have already got intelligent running. So let's just go ahead and pull intelligent Close out the product I was showing and we'll just pull this in as a model, right? model use existing sources We're in g rpc and we just did g rpc dev corner, right pull that in it's maven project It gives a second Does your intelligent turn your macintosh into a hair dryer like it does mine? No Oh Yeah, I've got an intel not an m1. So it really thrashes it. So now This isn't an apple commercial, but um, I have a beautiful, uh del xps laptop here with 64 gigs of ram You know an i9 blah, blah, blah, and it's wonderful and I run linux on it and on my mac You know, um, I I have three id's open right? I have intelligent open go land and um Sea lion all open right now on my desktop plus a bunch of other crazy stuff open and um The battery will last hours and hours and hours on this thing and if I had the same thing open on the del it's uh hour and a half tops maybe And that's running linux, which is using way less resources for some reason Um, but the fan will kick on, you know, um not not to smash on del I love the xps But that mac is amazing with its resource utilization. So Um, yeah, so first of all, yeah here we've got a lot less in here Right, this looks like any kind of corvus project you're gonna generate right so of course All the other stuff is abstracted away. I don't have um g rpc installed on my machine, by the way Um, and then we've got a couple of things in here Oh, you didn't install it on your machine because you're pulling it, right? Yeah Oh, actually, you know, I I forgot to install Orcas and I'll say orcas Rpc I forgot I grabbed rest of the rest is reacting on the command line. I forgot to grab it Grab corkis. So let me just wait. Let me just tell uh Uh Get intelligent to recognize that I have now changed the plugins All right, and you know what? Let's just um instead of just starting that proto buff from scratch What we'll do in corkis. We'll create a folder here new directory I will call proto And let me just copy the one that we were using from the non corkis. I'll just use the exact same one, right? that makes So proto Let's copy And paste that in here But I'll change this to That's code reuse, right? I wouldn't All right, so this case we have let me get our presentation mode here So appearance exit presentation mode So we've got the same file I changed the name of the package, right? So we're going to match what the project we're in and I'm right here in depth corner I'm going to run corkis build here. Um, we'll run this out and um Should notice I should have skipped tests. Um, let's see We were compiling some files Let's see if we got all our files in here. So inside of our target folder We have uh generated sources and g rpc. Let's take a look here So corkis generated all these all of these for us right here, right? So we've got um A couple of different things greeter g rpc and a greeter. I feel like our greeter class. This is an interface, right? And it has one method in it, right? So it's a One method here and the method is say hello, which is has been generated from Our proto file. It's got our you know, it gives us generated classes always a little bit ugly, right? Generating code, but it gives us our you know, our reply and our response, right? So we can see that And what corkis did was it discovered what what platform he was on so he's on a mac os um, you know arch a arch 64 Right. Yep. I think right you're on an m1 Yeah, I'm on an m1 so yeah Discover all this and it pulled it discovered all that pulled it all I didn't have to tell it anything right and um And then generated the code with the pro the right protoc compiler that was compatible Also, the interesting thing to me is it's actually using the mutiny stuff. So it's using asynchronous stuff Yeah We just have to be reactive stuff. Yeah. Yeah, we don't have to at all. So uh, but introduces greeter My palm should have picked up the new code, but let's just uh We love the product is to make sure is there any reason why it defaults to using mutiny is that um It doesn't so both of both are generated in here. So if we want to look at GRPC, we've got it right here Yeah, you have both options, right? So corkis doesn't it provides you with reactive api That doesn't force that force you into reactive api. We've already seen the traditional one So the greed is are the if we were to use the imperative api It's going to look exactly like the non the non corkis one. We just generated. So I was just going to skip that But we could do it exactly that way if we wanted to um, and so I'm going to implement methods We need our say hello method here, right? And so mutiny if you have not used mutiny before mutiny mutiny has the concepts of unis and multis And this is a reactive framework a uni is one thing and a multi is multiple things and so uh, we need to inject our Oh, we're creating our grp service. So we want to say is return uni create from item new All right, that's a great question and because one of the things we're going to do is the streaming stuff and it's going to be If I was doing that You know with the just writing the java code where I said I could make it way more complicated Um, that's going to look way more complicated than what you're going to see when you're using the reactive code that mutiny provides Yeah, unless you don't like reading The reactive code It can sometimes be a little bit, you know complicated, right? Um, but essentially what we're doing here is We are calling um We're going to create a uni mean we're creating a singular response We're creating it from an item the item that we're creating it from is going to be a hello reply And that's one of the that was one of the the messages, right or the objects that we defined inside of our protobuf file um That's been built out for us By quarkus by our compiler our hello reply is right here So we can still see if we want to see like all of our methods with class structure thing Um, I said a tiny question for me on that one as well. Um, the protobuf stuff Is that also compiled by the maven build as well? Yeah, right. I just used the quarkus builder. So under the covers quarkus took care of it for me Maven will take care of it as well. So now let's The two-step processing you first you got a the protoc. It's going to pull in the protoc compiler for protobuf Yeah, discover the language that you're using right through, you know, because maven did it It's going to pull down the right version of it for your platform that you're on And then it's when you compile it's going to compile it in Right um And that so it's you know, think of it as the the code generation part and then the compile it into your code part So it's almost like uh static linking into your code, right? Is it a separate build step in the maven or is it just automatically done? So for us in the um in the Straight up maven generic maven code. It would be a separate step that you're going to call In the quarkus, that's all hidden from you behind the scenes Um, I'm sure that it's actually kind of controlling the running of that behind the scenes But um for you it's kind of transparent the only thing that Jeremy had to do was actually pull in that That new dependency And so first is having to know all the other stuff that I showed you And it and the more functionality you want to include in a normal maven project The more stuff I would have to include in that palm file and know what it is and where it goes and what version numbers Um with quarkus, it's it's going to dynamically find that for you Yeah, that that that's utterly brilliant because I don't want to spend my life writing maven palm files Yeah, it's uh, I have the same feeling about yaml. Oh, by the way Yeah, I don't want to have to I don't want to have to manage all that all the time And I don't want to have to keep track of deploying a particular version to the you know, my target platform either Yep, so we're here. So now we take hello, you know, let's make it sound more emphatic to you, right? So plus right And so now we've got our api and if you guys what we're watching What I do is I just created a new api. I chose Uh g rpc and then in your in your service definition, you can just import the api Right. Yeah, but the cool thing that Jeremy did was that we couldn't do the other way around was He did that while the code was already running Yep And then another kind of nice trick that I like so there's different and we'll talk about this in a second But inside of protobuf, right? We've got a couple of different are inside g g rpc There's a couple of different ways that we can send these messages. So we have here We're we're sending one request and getting one response. But what we you can also do things like where we say we say hello Multiple times and we can say a hello Hello Quest and we can say returns Stream Hello reply So Ian, I don't know if you noticed but Jeremy types like about 150 words a minute if you include the backspaces Um, so yeah, sorry Jeremy I just needed to So we got say hello multiple times, right? I've got a new Uh a new method in my interface, right? So let's come back to our what we call it meet me greeter So now I've got an error in my code, right? And so what is it wanted? What is it doing? It wants to implement the method Because running quarkus in dev mode, it's watching everything including the protobuf files, right? So it knows that I've now it's it's recompiled because it says protobuf files changed It's gone ahead and recompiled regenerated everything. I haven't had to stop or run a compiler anything again, right? I'm just really nice the dev mode extends to to grpc. So now I've got a That was literally where I was trying to get trying to get to the best perspective because it's two different steps And you know, you're not actually doing a compilation of of java. You're going to do the protoc in advance So it's very cool that quarkus dev actually handles that as well So we've got you know what I'm going to cheat on this and copy and paste Copy and paste my method here So because it gets a little bit It's While he's doing that and for those gradle a fishing autos out there who are like, uh, you know, it's in maven If you're back on that uh website where we generated the original project, um, the same there's a gradle option there So yeah, you can use a gradle. So what I'm going to do here is I just creating a list Of replies that I can then I thought I'd add some like little a little like nice little things to say in here So say a list of replies I'm going to stream through that and this is not particularly mutiny. This is just java stream, right? And then I'm going to map that I'm going to create a new message based on the request to get name plus one of these little Responses and then I return a new hello reply and then I collect all of those as a list So then I'm going to call my malty and this is this is mutiny. I call malty and I'm creating it from an iterable Which is replies. So what that means is I'm going to have one request coming in And I'm going to send out multiple replies, right? So let's come back and look over here I'm going to have to do anything new either. I should have this Um, actually, you know what we can refresh this. I think this will pull in both methods. Did it not? I thought we'd get Pull that in so anyway, let's import our prototype again imported as an api We got a little close 9 000 there and we can now we have both of our methods here So we'll say hello multiple times. So what we'll do So I'll say hello London Actually, it won't make any sense because our brooding will be making you feel better. So say hello to oof and Now what happens is we have multiple replies come back, right? So we can see Zoom in a little bit so you can see so we have one oops One request send and then three replies Return so oof have a wonderful day oof your wit and wisdom are apparent and oof your skin tone is fabulous You are a master of hydration We get all three back, right and we can do this So we've got there's a couple of different things we can do with protobuf 2 I think maybe we'll maybe we'll talk a little bit more behind the scene stuff and come back to that But there's two other things we can do we can um We can do bidirectional streaming and we can also send a stream of multiple requests that are then collected and batched back as a response And we'll show those in a couple of minutes There's a another question from me on this if you don't mind when I'm using corpus dev mode because I like rest so I missed the last one when you guys talked about rest but I used I use corpus dev to do some rest test and if I change the code It doesn't actually do a recompilation of the code until the rest request is requested So if I do for example, uh, you know, I get and put it on a sub directory and then put a return of a value When I save that code, there's no actual build of the code until I request it at which point corpus Then does a very quick rebuild the code and sends the new version to me Now with that I noticed that when you do the change to the the buffer itself The build was done instantaneously. So the build was done on the change of the code Was that something I was doing wrong or does corpus dev have a different default way of doing a build Based on the actual technology that's actually doing at the back end Does that make sense? Yeah, so I you know, I had a great question Yeah, we can we can see in a minute That out a second So actually, you know if you want so that was implementing maybe maybe since we're doing that was going to implement a consumer, right? So, um, we we're using this we're using postband as a consumer right now, right? But we can also create a consumer inside of corpus, right? Um, so let's say we have our mutiny greeter Let's say java class Mutiny consumer api, right and we'll say yet Not yet at path and what we call this uh, hello grpc Do that again public Look at that fantastic import with jacarta not java rex Yeah Why is this not gonna take that long So i'm only i'm only stuck across because i've broken every idea on my machine So i'm currently using net beans uh for those who who want to really feel That beans Yeah Your hardcore, um Is the only one that actually works at the moment. That's like c++ programmers to use emacs, right? That's that's the hardcore people I You know, I find that, um Visual studio code is advocated a lot, but mostly by people who come from like a javascript background I use it just as a replacement Um for adam, right because I like to have an editor also kind of on the on the side um You know, we create the plugins for it at red hat um and all that but I still wind up going to The jet brains family of tools for just about everything it's uh feels comfortable in jet brains, but um tools but And and they're all the same. So if i'm doing Go lang code and go land. It's basically the same ide is intelligent, right? So It's it's a bit one though. It's a bit like a religious war because Yeah, I I don't like to get in that kind of More about which one's which I just know which one I personally feel more comfortable with I come from a too many years of pain of eclipse To oh eclipse Well, that one's not really religious, uh, you know with uh, you know, I can definitively say I Never liked eclipse, but um So we have here, um, hello g rpc, right? We are uh, I have injected my g rpc service greeter quarkis So, you know, you have to tell them to inject it. Yeah Um, and I've got a path called name and I'm going to return a uni a single thing a string And I'm going to get it from this path pram, right? So I'm calling my method say hello And I'm just creating a hello request on the fly to pass in right and this is the method we have hello request This is how it's generated, right? So I'm going to pass in my hello request and when I get it back And this is when you know intelligent tells me what I'm getting back. I'm getting back a hello reply I'm going to transform that hello reply because I don't want the whole thing Um, I want the hello reply get message and that's the syntax and now I so I return that that's going to come back as a string So let's come up here and see what that's going to look like New and we'll use hdp this time local The host 80 80 and Hello grpc right grpc and we'll say Right and so There we go. We have hello rob Now you were saying you weren't sure it compiles. Let's just do something like this that's a longer add a logger here. We'll just say So literally I was I was doing a live demo to a customer and It just it occurred to me There was only doing a compilation when I actually requested when it got the request for the the the changed method um I need to come up to set my logging parameters if I do this Uh, we'll see in notes again. This is purely out of interest No, it's a great question. I uh, I think we'll find out here. Hang on a second Because the theory behind it is that it only needs to recompile it when it's called right Let's see if we got a uh log It was a live reload time. We didn't get our log there. Um, let's try this say let's change our, uh Greeter let's add another list in here. Let's say uh insightful Comments about software. There we go. There's another uh, that's not what we called it. Was it so let's say, uh, hello I'm not touching the code for the rest api, right? Yeah. Yeah, but yeah, it's sort of it. It compiled it caught it So maybe it's maybe it's an older version or something. Anyway, um So when we got here, we have a consumer api. This is what it looks like to consume these Well, we can go ahead and consume one two. I guess we want, um Multiple one. What do we say hello a few times we could say get and get we could say let's say multiple times This would be a public Multi string, right and we could we could actually return the hello reply say hello times Well multiple times then I'll need to put Name there so we get that This time we will return We'll say greeter They hello multiple times, right? And so we're going to send in one hello request, right new hello, or not new Hello request new builder Name name Build And then we want to do when we get that back. I think I might cheat again here because We're going pretty fast today So, uh, what I'm going to do is Yeah, map the reply. Okay, so then I'm going to say when I get my reply I'm going to say app Go to apply get message Well, what's the matter about it's mad about unexpected For those okay, so what this is going to do is I'm going to say hello multiple times I'm going to send this request out I set the name on it, you know create the request message that g rpc is expecting when I get it back I'm just going to call I'm going to get back a Hello response a hello reply and each time I'm going to say get message and I'm going to stream them back out to the front end So let's take a look over here We say hello multiple times. We've got say hello multiple times And we've now got all four of ours. And so let's do over there Get request local host 8080 Hello g rpc Multiple times There we go. Rob. You have insightful comment thoughts off where rob. Have a wonderful day rob. You're a wisdom or apparent rob Your skin knows fabulous. You are a master of hydration. Wow Um, we don't have our guests. We have our get request as well, right? So Basically this is how you build a client, right? So this is the client. I mean, jeremy just built like Almost a bff or something like that pattern where you know, um, I could now Do an abstraction but behind the scenes I have a client server or you know, producer consumer For the g rpc mechanism So, um, you know some things You know We're probably not going to demonstrate here is like, you know, something that's blocking versus non-blocking, you know, that kind of discussion but um I'm gonna I'm gonna cut and paste just some, you know, uh, wit and wisdom here into the um into the chat Hopefully And we are We've we've gone on a lot of tangents. So case you want to leave for two. Let's Let's jump we've covered what g rpc is. I think pretty well Well here just go real quick to the uh, look in your chat and then um on the for the um Session here and just click on that github thing Oh here. I'll send it to the other. Um I guess I'll send it to your other chat. What would be I just telling you this Oh, it's too long. It's just what does g rpc stand for? Um, most people think, you know, it means google And it doesn't so there's a link. I will share Um, uh with a read me, uh, and every version Of g rpc means something different So it kind of stands grounded Right Is that does that mean like you're well grounded? There's an infinitesimal amount of um g's so we can have an infinite Number of versions. Yeah It's it's in the slide deck, but um, we'll put it out there when people are, you know, get that Let's let's zoom through a couple of these things because you know what let's um Here just uh, yeah here the slides up there for a minute Uh, we have a client server mechanism. This is basically how it works Um, it's just like every other rpc mechanism, you know, google's jrpc doesn't is it really different and that perspective keep going Um, you know from the perspective of You know what What are the core concepts so hdp2 is a core concept? It's something that came out in 2015 It's supported by basically, you know every browser Um, and it's got a bunch of capabilities that uh, one of which is this binary framing layer Um, and basically says, you know, hdp2 request response can be divided into, you know Small messages and framed in a binary format Which makes the message transmission much more efficient than hdp1.1 So the binary framing allows request response multiplexing also possible Um without blocking network resources. So This is really important because this is uh, uh, what grpc is based on and why um, it's it's pretty performant go on to the next slide Another aspect of that is is that the previous aspect allows us to do some other things too like header compression. So um everything in hdp2 Includes including the headers is encoded before sending So this significantly improves, you know, overall performance and it uses something called the h pack, you know, capital hpack compression method And it only shares the values that are different from a previous hdp header packet So in this example, if I have request one and request two When I change something it's only going to pass the thing that changed All right, so go on to we're going to zoom through these pretty quick um This allows me to do, um, you know, uh protocol, you know, uh, there was another concept You know from hdp2 like streaming and flow control and processing those are all things that allow synchronous and asynchronous processing which allows me With protocol buffers to do a bunch of things that we just demonstrated like the streaming Capability or the multi capability. So protocol buffers Think of it as, you know, the idl that we talked about earlier. It's a way for us to Standardize serialization and deserialization It's very different from when I do REST because there's no standard. I can um In in grpc. I need to do my design up front For what my api is Now we can say You your standard within your company might be to use open api and swagger or whatever But there's no actual REST full standard for that. It's There's the restful design But there's nothing enforcing that other than your own internal Enforcement of it and that could be different everywhere you go This provides a standardized way to do it, which is what makes it, you know, pretty popular And the product Is basically, you know, a proto c is basically the proto buff compiler that generates everything that we've been talking about Um, and it really creates this efficient in-memory schema for serialization and deserialization In a binary format, which makes it much more efficient. Keep going to the next one So, um, some additional Um, you know some additional points here, um Your uh You know streaming channels metadata load balancing call canceling um You know, all of these things are Additions that it brings to the table so So When I say performance, um, you're really talking about speeds, you know, you can speeds may vary of course But, you know, generally we can expect something like 10 times faster than just a api, you know, restful json communication From a streaming perspective Jeremy already started talking about, you know, unary Streaming and bi-directional streaming But you can do, you know client server streaming server to client streaming. There's a bunch of different, um capabilities there Metadata interoperability Think about it as, you know, we talked about all the tooling So the same mechanism can be used with the javascript java ruby C sharp dart objective c c plus plus c, you know go whatever security hcp2 uses tls And uh usability we kind of talked about that. So let's talk about real quick, um comparison with rest Oh, sorry. Yeah. Yep. I think uh Keep going to the next one Yep, there you go So this is where we we talked about rest the last time I just talked briefly about it There's really no standardization on what rest is unless even when you get into restful, um things You know where we talk about using the media type reversing and what that enables us to do etc um g rpc has, you know, very Well understood standardization um the rpc mechanism You know, it is client server based, but it's very efficient and fast. So if you're Doing those things where you're modernizing an app by Componentizing things and breaking down your monolith or whatever or you're doing something from scratch A lot of times people are using rest Calls instead of maybe kafka to do decoupling. They're they're doing rest anyway within their You know a service to service and they think that that's the way to go Um, but it's not as performant, right? So what I would say is, you know g rpc is going to be much more performant internally and use rest from the outside in because Your external clients are going to probably want a restful endpoint That's pretty standard to present to somebody But internally you want as fast a performance as possible because that request latency is really the accumulation of all the calls after you get into your service calls, right? So I want that to be as fast a communication as possible um From a design perspective, this is what's most important to me personally is, you know, uh, the api design we can say We can again open api swagger. We can do that and generate some stuff from it But really rest isn't is a code first kind of design and g rpc is a design first kind of design and I I I enjoy that a lot more. Um json Here's here's where the some people get um start to uh diverge here. So json's a human readable format And protobuf is not right. It's binary format But you can use json with you can use json. You could use json. That's true But you're still going to serialize it as a as a string, right? And which is and you're going to put in a binary format um The deal there is is people like that human readability because they can see it I'm more interested in the performance of it, right? So, um, it's really a tradeoff on what you you want to do And architecture is what about the least worst thing that you could choose So, um, you know, I I want the performance. So I prefer the g rpc mechanism Uh, I don't know. What do you guys think about these? I mean my my take is it is depending. I like that I mean, I love that I think it's a little forwarder that came up that quote, right? The architecture is not the least worst decision Right, if you want performance, which is most of the people most of our customers that I work with We use g rpc have made that decision because um, they they are squeezing performance out of their app, right? So that that definitely seems to me to be the the primary use case. Can we run through it? We don't have much time left, but I think yeah, I mean we can run through these really quick. Um, yeah So it's yeah, uh What I would say is if you don't take anything else away from this Uh, there's a really good linter that uh works with intelligent. I think there's a plug and also for vs code Why do I say that is because the style guide? I would say go to the style guide Go to the style guide for everything and you can't go wrong So even if you don't take anything else away from this conversation But you're interested in g rpc definitely, um, go to the style guide Um, well documented to both protocol buffers and g rpc are well documented Yes, super well documented. So go to the next one Um, definitely, um, separate your request and your response messages Right, um so You know always, you know, don't do the first thing where you're trying to reuse order for instance and create order what I would say is, um You know create the order our request and the order response Um, uh, but just make sure they're separate because if you start to commingle them and then you need to change Uh the response for some reason You're now stuck with you know, the request and response being the same, uh, you know, like in the create order example Just separate them out keep going single responsibility Um enums are a problem in any language Um, and the reason why there are problem is because there are problem when you cross languages. So Code generators like for c sharp might, uh, you know remove the prefixes to keep the code looking quote-unquote clean um You know, you might have duplications across enums where that causes trouble You know And other languages like c and c plus plus don't see enums the way that other you know additional languages do right so In addition to that use well-known types. So there's A couple different kinds of things when I say types. So When you install or use proto buffers, um, it will come with um You know on your machine if you install it on your machine or whatever it'll come with a path To a bunch of in kind of intrinsic types if you will that are for proto buffs So don't recreate the wheel so a timestamp is a timestamp if you have a special meaning of timestamp then create your own But um try to use the ones that are there, you know, empty is another one any is another one in addition to that There are some proto buffer definitions that you should Probably examine using but then you'd have to include them into your proto Such as money, um money's one. That's a that's an interesting definition because we all know that um, you know, if I use difference between euros and pounds and dollars and maybe You know, if i'm in india, they put commas, you know after certain things Um versioning there's a bunch of rules to the road to versioning So when we talk about versioning in particular, um, we're looking for backward compatibility So basically it's same as all old. Um g rpc idl mechanisms Adding things is okay adding things. Um, obsolete is okay. Um, and breaking changes are Could be in older languages when you delete something or remove something Here with proto buffers a lot of work went into Making sure that you know things Didn't break right so I can actually delete a field And not break my interface here. So um, again, uh, you know The style guide and looking at things. So removing fields Um, you know might be a breaking change, but um, you know deleting Under certain circumstances, uh might not be so Um next optional fields. Um, yep optional fields is interesting um in in the sense that uh, You know, we might want to check things for nullability And um, there's this whole thing with that link there. Um, so we can actually track things with the field presence tracking On whether or not it's optional and why that's important is because everybody sees nullable is different depending on the language that they're in One of is uh, also interesting because it means that um, I only want one of those things in this message I'm not going to have multiple of those things in the message. So that's that's a pretty cool feature There's a couple additional g rpc things The default messaging size is four megs. So you might want to consider that that is uh, changeable So if I want to change that, um, but Even though the limit can be increased I would say uh, first look at uh, streaming it or splitting the payload instead So that you can stay within that because it's going to be page based Uh g rpc is a layer seven. So that's at the application layer instead of like a layer three at the networking layer Um, but what that means is that from a load balancing perspective This might be an interesting conversation for some folks and that I can do client side load balancing after I discover all my endpoints, right? um That means that the client can load balance if I want to scale out Um, you know more stuff. It's not just uh load balancing, you know in the traditional sense We're using channels whenever possible. Uh, these are all Interesting things we use to keep alive pangs for hcp2 during periods of inactivity. So there might be some things that you want to do to Keep those, um, you know connections alive because the most expensive thing you can do With anything is do what you know create a socket, right? So, um, even when you create a database connection What's a thread in a socket, right? And why is it so expensive because you had to start that up? So we want to keep that alive um Reusing channels max concurrent streams so max concurrent streams, um Yeah, there's a limit on how many, um concurrent stream requests you can have This is just like, you know an out-of-the-box limit on how many requests a Um web server could have usually that's dependent on the threads that are going on behind the scenes On a web server, but think about it this way is that out of the box it's configured for 100 concurrent streams or connections so, um You know everything can is changeable, but you know, I like to leave it at you know, whatever the out-of-the-box Is until I need to change it Uh, there's some additional information a bunch of links here We're going to have eric d'andrea on here later. He wrote some great articles. Um, uh, we're going to have him on Uh g rpc and there's some uh, daniel. Oh wrote a couple Did a couple nice videos on that. Um, and then of course camille and corkis and g rpc is always fun and uh, clement has a, um, a really nice, um Article from uh, uh, just a couple years ago, but it's all still works the same so, um That'll all be provided by whoever gets the You know the the slides from here And we should we should throw that we'll put a pdf of those slides up on because those resources are really good really good stuff Um, but we'll put that up in the in the repo. I think Okay, cool right in any Comments you want to make about today? No, I've been quite excited just thinking about rewriting my restful stuff So dwayne asks us a question is this in the red hat lab and I don't know Dwayne, yes, you will be able to get a copy of the presentation. We'll put a pdf up in the repo I'll tweet it. Um, and I guess we'll put it We'll have the link on the site on the dev nation site. Um, and I'm not sure which red hat lab you're you're referring to um, you can Reach me uh at jeremy.davis at red hat dot com or you can reach me on linkedin linkedin.com slash i n jeremy r davis Or you can tweet at me at arrogant programmer But it's it's no vowels ar and g I can't spell it again without vowels um But uh, so yeah, if you want to follow up with that feel free to contact us Would love to hear from you and thank you everybody. Thanks for staying staying over to Right, cool. Thank you very much. And uh, we'll see you next time