Search⌘ K
AI Features

Enhancing Resilience with Async Fallbacks

Explore how to enhance application resilience by implementing asynchronous fallback mechanisms and local cache repositories. Understand strategies to handle data retrieval with fallback to gRPC endpoints while avoiding race conditions and stale cache. This lesson guides you through practical steps to increase module independence and efficient communication in event-driven Golang microservices.

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() ...