Enhancing Resilience with Async Fallbacks
Understand how to handle fallbacks from gRPC endpoints, adapt cache repository interfaces, and update integration event handlers.
Synchronous state fallbacks
We do not have to have the fallbacks, but since we already have the gRPC endpoints for the Store
and Product
data, we can choose to use those as fallbacks when we do not locate the requested data locally. This will not help us to determine if our cache is stale, and we will need to be careful about how we handle inserting new rows when they may already exist.
The Postgres implementations of the cache repository interfaces will accept a fallback parameter. When the data cannot be located locally, we will retrieve it from the fallback and then make a cached copy. We will implement the Find()
method in a way that will use the fallback only if the error we get back from the database signifies that no rows were found:
Get hands-on with 1400+ tech skills courses.