Goal
Enhance the resilience of the API Ingestion Gateway by implementing a fallback mechanism.
Problem
Currently, if Redis crashes or loses network connectivity, redis.get() in src/middleware/auth.ts throws an unhandled error, resulting in an HTTP 500 status and halting all metric ingestions.
Task
- Wrap Redis cache lookup and sets in
src/middleware/auth.ts inside a try/catch block.
- On connection error, log the failure as a warning and query PostgreSQL directly to validate the API key.
- Design a simple in-memory LRU or Map cache to store key validations locally for 30 seconds to prevent DB connection pool exhaustion during a Redis outage.
Goal
Enhance the resilience of the API Ingestion Gateway by implementing a fallback mechanism.
Problem
Currently, if Redis crashes or loses network connectivity,
redis.get()insrc/middleware/auth.tsthrows an unhandled error, resulting in an HTTP 500 status and halting all metric ingestions.Task
src/middleware/auth.tsinside atry/catchblock.