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
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 itI'm not familiar with "CLI tool" at all, could you describe it in a nutshell ?
CLI —> Command Line Interface —> your console app
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
I just don't know how to do that properly... maybe
What does "hosted service' mean ?
It's a .net concept for a background service that runs inside other apps without input from them
interesting, but am i able to grab the data from this background service ?
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
I haven't wrote anything yet
I planned like 'run on its own' app
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
Thank a lot, I will go in that direction
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 provideri didn't know that
very useful suggestions, thanks
something like this