This code sample shows you how to use the mocked VAS for the dog mode scenario. The dog mode allows a car owner to keep their dog safe, while they are away from the car.
As an application developer, I want to consume events from a streaming service.
The example application dog-mode-logic showcases how to achieve this using a Rust gRPC client. In this section we show how to do this using gRPCurl calls from the command line.
From the root directory:
-
In a terminal (A) start Chariott with
cargo run
. -
In another terminal (B) start the mock-vas with
cargo run -p mock-vas
. -
In a terminal (C), open a channel to the mock-vas with
grpcurl -v -plaintext \ -import-path proto -proto proto/chariott/streaming/v1/streaming.proto \ localhost:50051 chariott.streaming.v1.ChannelService/Open
and take a note of the returned channel id in the metadata x-chariott-channel-id. -
In another terminal D call the following, using the channel id from the previous step:
grpcurl -v -plaintext -d @ localhost:4243 chariott.runtime.v1.ChariottService/Fulfill <<EOM { "namespace": "sdv.vdt", "intent": { "subscribe": { "channel_id": "", "sources": ["Vehicle.Cabin.HVAC.AmbientAirTemperature"] } } } EOM
This makes a single request for 2 subscription intents for the dog mode status and the temperature events to Chariott. Chariott then passes these intents to the mock-vas that can fulfill them.
-
In terminal B, type
temp 20
in the standard input and notice the response coming through terminal C. However, if you typebattery 10
you see that this is not coming through as we did not subscribe to battery updates.
As a provider developer, I want to create a streaming service for events.
In order to do so, you need to:
- Implement the streaming proto
and specifically the
OpenRequest
endpoint with a service.- This is done in the common examples library in streaming.rs
- Make sure to serve this service with your gRPC server.
- The application will send
SubscribeIntent
that your service would need to handle.- In order to create the required client and register the subscriptions, you can use the Event Sub System crate aka ESS crate.
- This is done in mock-vas in chariott_provider.rs