Improve failover status feedback and controls
Build and Deploy Gateway / build-and-push (push) Successful in 26s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-08-20 01:32:03 +03:00
parent 9055934e92
commit 74227ae38c
7 changed files with 174 additions and 87 deletions
@@ -341,6 +341,8 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
if (!prepared) return;
const { state, policy, role } = prepared;
const checkedAt = now().toISOString();
const previousSnapshot = snapshot;
publish({ ...snapshot, reason: 'checking-channels' });
let primary;
let reserve;
try {
@@ -375,7 +377,6 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
memory: decisionMemory,
});
decisionMemory = decision.memory;
const previousSnapshot = snapshot;
const next = activeSnapshot(state, decision.status);
next.currentRole = role;
next.primary = {
@@ -526,6 +527,11 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
const capturedGeneration = generation;
roundPromise = performRound(capturedGeneration).finally(() => {
roundPromise = null;
if (capturedGeneration === generation && snapshot.reason === 'checking-channels') {
const failed = activeSnapshot(dependencies.state.read(), 'error');
failed.reason = 'health-unknown';
publish(failed);
}
const policy = dependencies.state.read().failoverPolicy;
if (capturedGeneration === generation && policy.enabled && dependencies.state.read().appliedFailoverPolicy) {
const decisionAt = snapshot.nextDecisionAt ? Date.parse(snapshot.nextDecisionAt) : NaN;
@@ -634,6 +640,7 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
generation += 1;
clearTimer();
const checkedAt = now().toISOString();
publish({ ...snapshot, reason: 'checking-channels' });
let primary;
let reserve;
try {