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:

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.

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. Download or install protobuf (e.g. from here) and set the PROTOC environment variable: echo -n "export PROTOC=/path/to/protoc.exe" >> ~/.bashrc

  3. Build application

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

rpc Usage

Insomnia usage for manual testing is describd in https://konghq.com/blog/engineering/building-grpc-apis-with-rust

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: { "key": "foo", "layers": 1, "namespace": "bar" }