Comments for the project.
Dependencies:
- C++14.
- https://github.com/oatpp/oatpp
- Compiled Debug x64 with VisualStudio/16.9.3+31129.286.
Details:
- Console logging.
- Manual testing via "beeceptor"(mock server), postman(mock client) - see TrackRobot\JSON folder.
- ThreadPools in ActiveOrderService, TrackOrderService which work with coroutines - AddOrderCoroutine, UpdateOrderCoroutine, UpdateSignalCoroutine.
- ExchangeApiClient interface and component management logic, which are similar to Spring Feign, Spring Boot.
Flow: Changed recently...
- A client posts order to the client/order endpoint -> ClientController::setNewOrder -> ActiveOrderService accepts the order -> ActiveOrderService::acceptOrder -> ActiveOrderService posts the order to the exchange market -> ExchangeApiClient::postOrder -> if an error occurs, returns to the client, otherwise proccesses the order asynchronously -> AddOrderCoroutine::act -> Creates the signal with ActiveOrderService::addSignal and adds asynchronously order for tracking with OrderTrackService::addOrderAsync;
- A robot asynchronously updates the order execution statuses and signals -> TrackOrderService::executor takes next order from the queue -> updates with UpdateOrderCoroutine::act -> if changed, TrackOrderService::updateOrder + ActiveOrderService::updateSignal | if not changed, add back to the threadpool queue;
- Open .sln file in Visual Studio 2019, and click Build, or convert the VS project to CMakeLists.txt :)
- On Windows, run .exe from TrackRobot/x64/Debug.
Potential upgrades:
- Add event dispatcher system to remove strong coupling between components.
- Unhandled exceptions in coroutines might lead to missing the order track - left untouched at the moment.
- Replace sync API calls with async through combining coroutines.
- Add logging to the file, DB.
- Use Object when it's required as it creates performance overhead with shared_ptr.
- Add tests using oatpp-test.
- Add configuration file.