max conns?
Build and Push Docker Images / build-and-push (push) Successful in 29s

This commit is contained in:
Bram committed 2026-11-04 11:43:04 +01:00
1 parent 1276dac371
commit 454f1c9d6d
3 files changed
+28 -5

No files matched your search

+7 -2
View File
@@ -77,7 +77,7 @@ function readConfigEntries() {
} }
for (const url of validUrls) { for (const url of validUrls) {
entries.push({ url, username, password }); entries.push({ url, username, password, entryId: index });
} }
}); });
return entries; return entries;
@@ -102,7 +102,12 @@ function reloadConfig() {
seen.add(upstream.key); seen.add(upstream.key);
const existing = previous.get(upstream.key); const existing = previous.get(upstream.key);
next.push(existing || upstream); if (existing) {
existing.entryId = upstream.entryId;
next.push(existing);
} else {
next.push(upstream);
}
} }
const removed = upstreams.filter((u) => !seen.has(u.key)).length; const removed = upstreams.filter((u) => !seen.has(u.key)).length;
+19 -2
View File
@@ -26,13 +26,30 @@ function isBusy(upstream) {
} }
function totalConnectionCapacity() { function totalConnectionCapacity() {
let total = 0; const perEntry = new Map();
for (const upstream of getUpstreams()) { for (const upstream of getUpstreams()) {
const entryId = upstream.entryId ?? upstream.key;
const maxCons = upstream.state.maxCons; const maxCons = upstream.state.maxCons;
total += maxCons !== null && maxCons > 0 ? maxCons : 1;
if (!perEntry.has(entryId)) {
perEntry.set(entryId, maxCons);
continue;
} }
const current = perEntry.get(entryId);
if (maxCons !== null && maxCons > 0) {
perEntry.set(
entryId,
current !== null && current > 0 ? Math.max(current, maxCons) : maxCons
);
}
}
let total = 0;
for (const maxCons of perEntry.values()) {
total += maxCons !== null && maxCons > 0 ? maxCons : 1;
}
return total; return total;
} }
+2 -1
View File
@@ -19,7 +19,7 @@ function baseState() {
} }
class Upstream { class Upstream {
constructor({ url, username, password }) { constructor({ url, username, password, entryId }) {
const parsed = new URL(url); const parsed = new URL(url);
parsed.hash = ''; parsed.hash = '';
parsed.search = ''; parsed.search = '';
@@ -27,6 +27,7 @@ class Upstream {
this.basePath = parsed.pathname.replace(/\/+$/, ''); this.basePath = parsed.pathname.replace(/\/+$/, '');
this.username = username; this.username = username;
this.password = password; this.password = password;
this.entryId = entryId;
this.key = `${parsed.origin}${this.basePath}|${username}|${password}`; this.key = `${parsed.origin}${this.basePath}|${username}|${password}`;
this.state = { ...baseState(), inFlight: 0 }; this.state = { ...baseState(), inFlight: 0 };
} }