And, yeah. Going back to our code. So thank you, Alex, for showing us this useful intro about protobuffer, so let's have a look what we have in sense of our currency. So, again, we really simplified that calls. I mean, it for sure will be a bit more helpful complex behind it, but for now it's just a very simple way, just trying to combine multiple parts altogether and trying to run it and see if it works or not.
So, basically, we have a package currency, we have currency's service, and we have a method which is called findall. All these messages, like currency is a message we transfer in, and here's an interesting flag called repeated, which basically represents an array of some message. So, we have currencies, and we have page metadata, very simple protobuf. I think we had a few more complex things, and here is some, already some code we moved.
So, first of all, this is a package generated from a, from Nest.js boilerplate in for gRPC, I guess. And then we just moved a module. So the module was taken from our modulate. Let's see, where is it, modulus currency. Yeah, basically moving it into the new repository. New package, and then the difference is that here it was the controller which been registering for restaurants. And instead here, we switched it to gRPC. So we have to move to gRPC format, kind of format. So we can check currency package. We'd go and try to find where these currency packages are, so defined somewhere. Yeah, so it's defined at the place which I showed before, which contains client options. Yeah, so what roles we have? Like, we have the GRPC method for the service called grpc currency service, and we'll have it find all. So basically, we have that find all method, which taken from here from this proto. And we just, what we just need to do with this chest, we just need to implement it, as easy as that, but then you probably lost. There's it, yeah. Here we added some login, just to understand, to determine if it's been called while we are testing. Underneath it just called currency service, which does pretty much the same as before. It gets all the currencies from the database, I guess. And here we also have a cron, which does the job with appealing this database with some real data. So let's, let's try to run it all together, I guess. Do you have, Aleksey, something to add here? Excuse me? Do you have something to add? Or I can just run it. No, no, I was thinking, yeah, it's, we unfortunately don't have a picture of how it looks like, but, yeah, we introduce this gRPC service. And this gRPC service is already a part, it's a new microservice, but we call on it from the monolith. So that was like our first transition step, right, between this, from monolith to microservice. So we moved it apart, but we still want to have, we need this connection to sustain as a state of the whole application, basically. Yeah. Yeah, so, yeah, the best thing about this, it still uses the same database. So there is plenty of work to be done to have the separate databases, but for test purposes, we just have one. So I would try to let's run the test. Yeah, it should fail, I guess. And then we will see why. Yeah. So it's failed, with a message, unavailable, no connections established. So what we did, so part of moving the model here from the monoreport, from the monolith, we also in the monolith, in the currency controller, we did the following, we replaced, we just, yeah so in the monolith, we inject this client for GRPC, so instead of doing this business logic in here, we instance injecting the service, currency service, which is, will be our GRPC client, for calling our GRPC server, and then we, as you can see, like, we just called the method, which was pretty much after generated from the Nest and Protobuffer definition, and we call this method, and underneath it just goes, like, to the network, and called the GRPC server, got the result, and then unpack it, and returned pretty much the same, and in this place, it just says, like, no connection established. That's right, because I didn't start the second service. Let me do this. So this one already the one, which is written in GRPC, where we moved our code from Nest, one Nest application to another. So it started, it's not so huge as Monolith before, it has just two rows, and we also have here, we also have REST definition, but as you can see, it started on a different port, like GRPC standard port. Let's try this test one more time. Okay, that's that's been executed and we got, we got it passed. So this is the test from Monolith, I guess, but yeah, it's been executed using that party server, that party service.