mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 02:42:24 +03:00
feat(resilience): default the credential health check sweep to 60 minutes (#12138)
Validado em worktree combinada com typecheck limpo, testes focados verdes, gates de file-size/complexity/cognitive-complexity/cycles OK. Obrigado!
This commit is contained in:
@@ -129,7 +129,7 @@ export function resolveCredentialHealthSweepInterval(
|
||||
const parsed = parseInt(envVal, 10);
|
||||
if (!isNaN(parsed) && parsed >= 10_000) return parsed;
|
||||
}
|
||||
return 300_000; // default 5 min
|
||||
return 3_600_000; // default 60 min
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ function getSweepInterval(): number {
|
||||
const parsed = parseInt(envVal, 10);
|
||||
if (!isNaN(parsed) && parsed >= 10_000) return parsed;
|
||||
}
|
||||
return 300_000; // default 5 min
|
||||
return 3_600_000; // default 60 min
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -184,10 +184,11 @@ export const DEFAULT_RESILIENCE_SETTINGS: ResilienceSettings = {
|
||||
// default until an operator adds an override here.
|
||||
providerQuotaOverrides: {},
|
||||
// Global default cadence for the background credential health check sweep.
|
||||
// 5 minutes preserves the pre-setting scheduler default (300 000 ms);
|
||||
// 0 disables the sweep entirely. Per-connection overrides always win.
|
||||
// 60 minutes: the sweep makes a real upstream probe against EVERY active
|
||||
// connection, so the previous 5-minute default cost 12 requests/hour per
|
||||
// connection. 0 disables the sweep entirely. Per-connection overrides win.
|
||||
credentialHealthCheck: {
|
||||
intervalMinutes: 5,
|
||||
intervalMinutes: 60,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ function withEnv(value: string | undefined, fn: () => void) {
|
||||
}
|
||||
}
|
||||
|
||||
test("default resilience settings include a 5-minute credential health check cadence", () => {
|
||||
assert.equal(DEFAULT_RESILIENCE_SETTINGS.credentialHealthCheck.intervalMinutes, 5);
|
||||
test("default resilience settings include a 60-minute credential health check cadence", () => {
|
||||
assert.equal(DEFAULT_RESILIENCE_SETTINGS.credentialHealthCheck.intervalMinutes, 60);
|
||||
});
|
||||
|
||||
test("resolveResilienceSettings returns the default interval when nothing is stored", () => {
|
||||
const resolved = resolveResilienceSettings({});
|
||||
assert.equal(resolved.credentialHealthCheck.intervalMinutes, 5);
|
||||
assert.equal(resolved.credentialHealthCheck.intervalMinutes, 60);
|
||||
});
|
||||
|
||||
test("mergeResilienceSettings stores an operator interval and preserves other sections", () => {
|
||||
@@ -45,9 +45,9 @@ test("mergeResilienceSettings clamps the interval into the 0-1440 band", () => {
|
||||
assert.equal(high.credentialHealthCheck.intervalMinutes, 1440);
|
||||
});
|
||||
|
||||
test("sweep interval: no operator setting and no env → built-in 5 min default", () => {
|
||||
test("sweep interval: no operator setting and no env → built-in 60 min default", () => {
|
||||
withEnv(undefined, () => {
|
||||
assert.equal(resolveCredentialHealthSweepInterval({}), 300_000);
|
||||
assert.equal(resolveCredentialHealthSweepInterval({}), 60 * 60_000);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,6 +87,6 @@ test("sweep interval: non-numeric stored interval falls back to env/default", ()
|
||||
const settings = {
|
||||
resilienceSettings: { credentialHealthCheck: { intervalMinutes: "abc" } },
|
||||
};
|
||||
assert.equal(resolveCredentialHealthSweepInterval(settings), 300_000);
|
||||
assert.equal(resolveCredentialHealthSweepInterval(settings), 60 * 60_000);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user