Our goal is to develop a grpc-API for AGL that serves as persistent storage API for the demo. The API will be written in Rust and make use of tonic for grpc functionality as well as RocksDB as a database backend. Use cases include retaining settings over a system shutdown (e.g. audio, HVAC, profile data, Wifi settings, radio presets, metric vs imperial units).
The most important hardware consideration for this project is that the AGL demo runs on embedded hardware with flash storage, so we want to minimize number of write operations. This impacts the choice of database; we have chosen to work with RocksDB as it is well-suited for embedded computing and tunable with respect to write amplification. Ideally we want the API to be flexible with respect to database used (pluggable backends), but this is not a priority at this early development stage. Our eventual goal is to integrate this project into the then-current AGL demo version (quillback for now, later master).
We are aiming to construct the Persistent Storage API using a layered architecture:
- Controller layer: translates proto calls to service calls.
- Service layer: communicates with the controller and facade layers, implements the business logic
- Facade layer: implements RocksDB.
-
Install rust
-
Download or install protobuf (e.g. from here) and set the
PROTOC
environment variable:echo -n "export PROTOC=/path/to/protoc.exe" >> ~/.bashrc
-
Build the application
cargo run --release --bin server
Insomnia wie in https://konghq.com/blog/engineering/building-grpc-apis-with-rust beschrieben
SetupDB: {}
Write: { "key": "testkey", "value": "testvalue" }
Read: { "key": "testkey" }
Read: { "key": "wrongkey" }
DestroyDB: {}