C
C#9mo ago
Kuno

Question about REST API

Context : ground control in aerodrome I have : 1) Console App where all aerodrome processes are happening 2) REST API should be as a messenger service between the business logic (console app from above) and any other part of the service Let's admit I receive a request: "I want to land on your runway", after that I have to analyze the information about my runway (is that possible to land on rigth now ?) from business logic, and this business logic is a separate console app, and I don't understand how to use this console app from REST API ? Or maybe it is a bad architecture initially ?
15 Replies
Angius
Angius9mo ago
It would be best to just extract the logic to a separate project and have both the CLI tool and the API rely on it Failing that, you can try referencing the CLI tool in the API project and hope that whoever created the CLI did not make extensive use of non-public classes Failing that... you'd have to just call the CLI with Process class and get the data back from it
Kuno
KunoOP9mo ago
I'm not familiar with "CLI tool" at all, could you describe it in a nutshell ?
Angius
Angius9mo ago
CLI —> Command Line Interface —> your console app
Pobiega
Pobiega9mo ago
Why is the console app running the aerodrome simulation? Can it be moved to a hosted service inside the API? That would make your life a whole lot easier
Kuno
KunoOP9mo ago
I just don't know how to do that properly... maybe What does "hosted service' mean ?
Pobiega
Pobiega9mo ago
It's a .net concept for a background service that runs inside other apps without input from them
Kuno
KunoOP9mo ago
interesting, but am i able to grab the data from this background service ?
Pobiega
Pobiega9mo ago
yes Can we see your code somewhere? is your aerodrome simulation entirely reactive, or does it "run on its own" too? ie, does it only respond to requests, or does it also trigger events by itself
Kuno
KunoOP9mo ago
I haven't wrote anything yet I planned like 'run on its own' app
Pobiega
Pobiega9mo ago
oh. Literally nothing? then absolutely consider just running it as a hosted service inside the API. If you put all of its code in a separate library as ZZZZZZZZZ suggested, you can make an alternate entrypoint with a separate console project for easier debugging
Kuno
KunoOP9mo ago
Thank a lot, I will go in that direction
Pobiega
Pobiega9mo ago
so 3 projects: a class lib that contains the aerodrome simulation itself, probably as an IHostedService and with an extensionmethod on IServiceCollection to register the entire thing then an API project that uses said extension method, and a console app that does the same the class lib would contain some class that allows communication in/out of the simulation. There are many approaches here, from events to message handlers and you'd access this via the service provider
Kuno
KunoOP9mo ago
i didn't know that very useful suggestions, thanks
Pobiega
Pobiega9mo ago
something like this
Pobiega
Pobiega9mo ago
No description
Want results from more Discord servers?
Add your server