Assignment 4 - Add Dapr state management
October 7, 2021 ยท View on GitHub
In this assignment, you're going to add Dapr state management in the TrafficControl service to store vehicle information.
Dapr State management building block
Dapr offers key/value storage APIs to create stateful, long-running services. Services can use these APIs to leverage any of the supported state stores, without adding or learning a third party SDK.
When using state management, your application will also be able to leverage several other features that would otherwise be complicated and error-prone to build yourself such as:
- Distributed concurrency and data consistency
- Retry policies
- Bulk CRUD operations
See below for a diagram of state management's high level architecture:
For this hands-on assignment, this is all you need to know about this building block. If you want to get more detailed information, read the introduction to this building block in the Dapr documentation.
Assignment goals
To complete this assignment, you must reach the following goals:
- The TrafficControl service saves the state of a vehicle (
VehicleStateclass) using the state management building block after vehicle entry. - The TrafficControl service reads and updates the state of a vehicle using the state management building block after vehicle exit.
This assignment targets number 3 in the end-state setup:
DIY instructions
Open the source code folder in VS Code. Then open the Dapr state management documentation and start hacking away. Make sure you use the default Redis state-store component provided out of the box by Dapr.
Step by step instructions
To get step-by-step instructions to achieve the goals, open the step-by-step instructions:
Next assignment
Make sure you stop all running processes and close all the terminal windows in VS Code before proceeding to the next assignment.
Go to assignment 5.