Persistent Storage API for the Automotive Grade Linux demo

The AGL Persistent Storage API is a grpc API for AGL that serves as persistent storage API for the demo. The API is written in Rust and makes use of tonic for grpc functionality as well as RocksDB as a database backend, using rust-rocksdb. 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. In principle the API is flexible with respect to database used (pluggable backends), but only RocksDB is implemented. This API is part of the AGL demo as of release 'Royal Ricefish'.

The AGL Persistent Storage API is constructed using a layered architecture:

By default, the API can be accessed through port 50054. This can be changed in main.rs. The RocksDB database files are stored in directory "AGLPersistentStorageAPI", located in the home directory of your system. This can be changed in service.rs.

API Specification

Namespaces

The rpcs described below interact with keys belonging to specific namespaces. This feature enables applications to maintain private namespaces within the same database. Not specifying a namespace when calling the API will result in the default namespace "" being used. Alternatively, a specific namespace (e.g. "AppName") can be chosen. With the exception of DestroyDB, which acts on the entire database, all rpcs can only interact with one namespace at a time.

Remote procedure calls

Example Tree

Note: nodes marked by * are keys (and therefore have a value)

Namespace: "" - Vehicle - Infotainment * - Radio - CurrentStation * - Volume * - HVAC - OutdoorTemperature * - Communication - Radio - Volume * - test *

Namespace: "AppName" - Private - Info *

Setup instructions

  1. Install rust.

  2. Install the Protobuf Compiler, e.g. by downloading the latest pre-built binary for your system here and following the installation instructions included in the readme. Be sure to add your Protobuf installation to your PATH. See also the general Protobuf installation instructions.

  3. Install a clang compiler, e.g. by downloading the latest pre-built LLVM binary for your system here and adding the LIBCLANG_PATH variable to your environment.

  4. Build application.

cargo build
  1. Run tests.
cargo test
  1. Start server.
cargo run --release --bin server

Remote Procedure Call Usage

To ensure your API is working as expected, you can use Insomnia to manually send remote procedure calls to the API, following the instructions provided in the Insomnia documentation. For each procedure call, an example is given below:

DestroyDB: {}

Write: { "key": "foo", "value": "foobar", "namespace": "bar" }

Read: { "key": "foo", "namespace": "bar" }

Delete: { "key": "foo", "namespace": "bar" }

Search: { "key": "foo", "namespace": "bar" }

DeleteNodes: { "key": "foo", "namespace": "bar" }

ListNodes: { "node": "foo", "layers": 1, "namespace": "bar" }