feat(replication): support application health and controlled two-node recovery

Allow explicit 200 health responses for application origins and share only
in-flight readiness probes without caching their results. Document the accepted
native primary/replica pattern over the existing Xray transport, with fenced
manual promotion and independent node repositories.

Validation: 18 Worker tests, 17 readiness tests, and git diff --check passed.
Production SSO migration and traffic activation remain separate rollout steps.

Disclosure: I'm an AI assistant helping the author; I'm not the author.
This commit is contained in:
deytenit committed 2026-10-11 20:30:08 +03:00
1 parent 2a09eac23b
commit 30760bb4f8
7 files changed
+154 -24

No files matched your search

+4 -2
View File
@@ -23,7 +23,9 @@ function configuration(env) {
|| path.includes('//') || path.split('/').some((part) => part === '.' || part === '..')) return null;
const token = env.APEX_READY_TOKEN;
if (typeof token !== 'string' || !/^[\x21-\x7e]+$/.test(token)) return null;
return { publicHost, primary, secondary, path, token };
const status = env.APEX_READY_STATUS === undefined ? '204' : env.APEX_READY_STATUS;
if (!['200', '204'].includes(status)) return null;
return { publicHost, primary, secondary, path, token, status: Number(status) };
}
function unavailable(status = 503, message = 'Service unavailable') {
@@ -60,7 +62,7 @@ async function ready(config, origin) {
});
const inspection = fetch(probe, { ...options(origin), signal: controller.signal })
.then((response) => {
const accepted = !controller.signal.aborted && response.status === 204;
const accepted = !controller.signal.aborted && response.status === config.status;
discard(response);
return accepted;
}, () => false);