NG Snakeoil: A Technology Walkthrough
If the Angular code is responsible for the presentation side of SnakeoilOS WebApp, the RESTful portion is responsible for everything else (e.g. the logic, management, and so on).
The RESTful server is responsible for:
- Collating all the information the client-side application needs (e.g. CPU/RAM status for the Dashboard, Audio/player information for Music Player).
- Start/Stop music players,
- Retrieve/store SnakeoilOS configuration,
- Shutdown/reboot SnakeoilOS machine
- Run Cyclictest/top
The relationship between the Angular client-side and the RESTful server-side is asynchronous by nature (this is similar to how async USB 2.0 works). For example, when you click on “CyclicTest” on the browser, the client-side application delegate this action to the RESTful server. The RESTful server will execute the cyclictest benchmark on the SnakeoilOS machine. In the meantime, you can continue to use the WebApp to perform other actions, and the RESTful server is still available to service any requests made by the GUI. The two communicates with each other, but they don’t have to wait for each other to finish. When a task is finished, the other party will be notified, and this other party can then choose what to do with the returned response.
In the above example, you initiated the cyclictest, and the GUI now tells you the benchmark is working hard on the SnakeoilOS machine. You can continue to use the WebAPP, and when you return back to the System page, and when the benchmark has completed, you will see the results.
This is a major improvement over to the old 0.1.x SnakeoilOS WebApp. With the older Snakeoil 0.1.x, once you run cyclictest, you are locked out of the WebApp until it finish running (this can take minutes!)
The RESTful server is written with cpprestsdk from Microsoft. This is a C++ library. Of all the languages, C++ gives the best speed performance because it’s running in compiled machine code. All the web requests, I/O are efficiently handled with C with very low CPU overheads.