Improve failover status feedback and controls
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user