Failsafe Mechanism in Direct Mode
While the Lunar Interceptor includes a built-in failsafe mechanism to ensure uninterrupted API traffic routing, users of Direct Mode must implement their own failsafe mechanism.
A robust failsafe mechanism combines error tracking, conditional routing, and timers to address connectivity issues with the proxy or API gateway. These components work together to minimize downtime and provide flexibility in routing traffic. Let’s explore these elements and their application in a practical workflow.
Error Detection and Indicators
Error detection is the cornerstone of a failsafe mechanism. This involves monitoring responses for issues, using specific error indicators such as response headers or status codes. For instance:
- Error Indicators: Custom headers or HTTP response attributes signal problems with the proxy.
- Connection Failures: Inability to establish a connection to the proxy or gateway triggers error handling logic.
To effectively address errors:
- Define clear conditions for detecting errors (e.g., timeouts, error headers).
- Ensure that the system distinguishes between proxy-related issues and provider-related issues.
Managing Errors and Activation Thresholds
Once errors are detected, an Error Counter tracks consecutive failures. This counter ensures that occasional, transient errors don’t trigger unnecessary rerouting. Key considerations include:
- Max Error Threshold: Set a threshold for consecutive errors before activating the failsafe. For example, allow five consecutive errors before switching traffic routing.
- Error Handling Logic: This logic determines actions based on the error counter, such as incrementing the counter or initiating rerouting when the threshold is exceeded.
Example:
- If Error Counter < Max Error Threshold: Continue attempting to use the proxy.
- If Error Counter ≥ Max Error Threshold: Activate a cooldown period.