fix: align DeepSeek canary tool rounds with gate
Memind CI / Test, build, and release guards (pull_request) Successful in 1m32s
Memind CI / Test, build, and release guards (pull_request) Successful in 1m32s
This commit is contained in:
+46
-2
@@ -244,9 +244,43 @@ function appendForwardedFor(current, remoteAddress) {
|
||||
return values.join(', ');
|
||||
}
|
||||
|
||||
function dependencyHealthRequest(target, timeoutMs) {
|
||||
return new Promise((resolve) => {
|
||||
const request = http.request(
|
||||
{
|
||||
hostname: target.hostname,
|
||||
port: target.port,
|
||||
method: 'GET',
|
||||
path: `${target.pathname}${target.search}`,
|
||||
headers: { connection: 'close' },
|
||||
},
|
||||
(response) => {
|
||||
response.resume();
|
||||
response.once('end', () => resolve(response.statusCode === 200));
|
||||
},
|
||||
);
|
||||
request.setTimeout(timeoutMs, () => request.destroy());
|
||||
request.once('error', () => resolve(false));
|
||||
request.end();
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeLoopbackHealthTarget(value, label) {
|
||||
const target = new URL(String(value ?? ''));
|
||||
if (
|
||||
target.protocol !== 'http:'
|
||||
|| !['127.0.0.1', 'localhost', '::1'].includes(target.hostname)
|
||||
) {
|
||||
throw new Error(`${label} must be a loopback http URL`);
|
||||
}
|
||||
target.hash = '';
|
||||
return target;
|
||||
}
|
||||
|
||||
export function createMemindCanaryProxy({
|
||||
stableTarget,
|
||||
candidateTarget,
|
||||
candidateHealthDependencies = [],
|
||||
policy,
|
||||
identityResolver,
|
||||
diagnosticSecret,
|
||||
@@ -256,6 +290,8 @@ export function createMemindCanaryProxy({
|
||||
} = {}) {
|
||||
const stable = normalizeLoopbackTarget(stableTarget, 'stable target');
|
||||
const candidate = normalizeLoopbackTarget(candidateTarget, 'candidate target');
|
||||
const candidateDependencies = candidateHealthDependencies.map((value, index) =>
|
||||
normalizeLoopbackHealthTarget(value, `candidate health dependency ${index + 1}`));
|
||||
if (!policy) throw new Error('canary proxy requires a routing policy');
|
||||
if (!identityResolver) throw new Error('canary proxy requires an identity resolver');
|
||||
if (!diagnosticSecret) throw new Error('canary proxy requires a diagnostic secret');
|
||||
@@ -269,8 +305,13 @@ export function createMemindCanaryProxy({
|
||||
return healthCache.healthy;
|
||||
}
|
||||
if (!healthPromise) {
|
||||
healthPromise = healthRequest(candidate, candidateHealthTimeoutMs, 'candidate')
|
||||
.then((healthy) => {
|
||||
healthPromise = Promise.all([
|
||||
healthRequest(candidate, candidateHealthTimeoutMs, 'candidate'),
|
||||
...candidateDependencies.map((target) =>
|
||||
dependencyHealthRequest(target, candidateHealthTimeoutMs)),
|
||||
])
|
||||
.then((results) => {
|
||||
const healthy = results.every(Boolean);
|
||||
healthCache = { checkedAt: Date.now(), healthy };
|
||||
return healthy;
|
||||
})
|
||||
@@ -539,6 +580,9 @@ async function main() {
|
||||
stableTarget: process.env.MEMIND_CANARY_STABLE_URL || 'http://127.0.0.1:8081',
|
||||
candidateTarget:
|
||||
process.env.MEMIND_CANARY_CANDIDATE_URL || 'http://127.0.0.1:18081',
|
||||
candidateHealthDependencies: csvValues(
|
||||
process.env.MEMIND_CANARY_CANDIDATE_HEALTH_URLS,
|
||||
),
|
||||
policy,
|
||||
identityResolver,
|
||||
diagnosticSecret: process.env.MEMIND_CANARY_DIAGNOSTIC_SECRET,
|
||||
|
||||
Reference in New Issue
Block a user