- Implement ModelCircuitBreaker to track (provider, model) overload states independently of API keys - Skip remaining keys in active tier immediately on 503 Service Unavailable / High Demand - Protect key quotas by preventing 503 errors from marking keys as rate-limited - Add 15s streaming TTFT timeout and reduce candidate timeout to 20s - Add Model Circuit Breaker live telemetry and manual reset in Admin Console - Add comprehensive automated test suite for circuit breaker and failover cascades
27 lines
1.4 KiB
TypeScript
27 lines
1.4 KiB
TypeScript
import dotenv from 'dotenv';
|
|
import path from 'path';
|
|
|
|
dotenv.config();
|
|
|
|
export const config = {
|
|
apiPassword: process.env.API_PASSWORD,
|
|
geminiApiKeys: (process.env.GEMINI_API_KEYS || '').split(',').map(k => k.trim()).filter(Boolean),
|
|
port: parseInt(process.env.PORT || '3000', 10),
|
|
logDir: process.env.LOG_DIR || './logs',
|
|
configFilePath: process.env.CONFIG_FILE || path.join(process.cwd(), 'data', 'revolver-config.json'),
|
|
model: 'gemini-flash-lite-latest',
|
|
rateLimitDurationMs: parseInt(process.env.RATE_LIMIT_DURATION_MS || '60000', 10),
|
|
// Cloudflare Anti-Timeout & Keep-Alive settings
|
|
keepAliveIntervalMs: parseInt(process.env.KEEPALIVE_INTERVAL_MS || '15000', 10),
|
|
enableNonStreamingKeepAlive: process.env.ENABLE_NON_STREAMING_KEEPALIVE !== 'false',
|
|
nonStreamingKeepAliveDelayMs: parseInt(process.env.NON_STREAMING_KEEPALIVE_DELAY_MS || '20000', 10),
|
|
candidateTimeoutMs: parseInt(process.env.CANDIDATE_TIMEOUT_MS || '20000', 10),
|
|
// Model Overload & Fast-Failover Circuit Breaker settings
|
|
streamFirstTokenTimeoutMs: parseInt(process.env.STREAM_FIRST_TOKEN_TIMEOUT_MS || '15000', 10),
|
|
modelCooldownDurationMs: parseInt(process.env.MODEL_COOLDOWN_MS || '60000', 10),
|
|
maxTargetTimeoutRetries: parseInt(process.env.MAX_TARGET_TIMEOUT_RETRIES || '0', 10)
|
|
};
|
|
|
|
if (!config.apiPassword) {
|
|
throw new Error('API_PASSWORD is required. Please set it in .env file');
|
|
}
|