Complete the code to implement a fallback response in a microservice.
response = call_service() or [1]
Using a default response ensures the system continues working even if the service call fails.
Complete the code to check service health before calling it.
if [1](): response = call_service() else: response = "fallback"
Checking if the service is available helps decide whether to call it or use fallback.
Fix the error in the circuit breaker pattern code.
if circuit_breaker.[1](): response = call_service() else: response = "fallback"
The circuit breaker must be closed to allow calls; if open, calls are blocked.
Fill both blanks to implement a timeout fallback in a microservice call.
try: response = call_service(timeout=[1]) except [2]: response = "fallback"
Setting a timeout of 5 seconds and catching TimeoutError allows graceful fallback on delays.
Fill all three blanks to create a fallback cache mechanism.
cache = [1]() if not cache.has(key): data = call_service() cache.[2](key, data) else: data = cache.[3](key)
CacheStore is the cache class; set stores data; get retrieves data for fallback.
