@jeffusion/bungee-core 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.js +17 -4
- package/package.json +2 -2
package/dist/worker.js
CHANGED
|
@@ -21936,7 +21936,8 @@ function initializeRuntimeState(config) {
|
|
|
21936
21936
|
consecutiveFailures: 0,
|
|
21937
21937
|
consecutiveSuccesses: 0,
|
|
21938
21938
|
healthCheckSuccesses: 0,
|
|
21939
|
-
healthCheckFailures: 0
|
|
21939
|
+
healthCheckFailures: 0,
|
|
21940
|
+
recoveryAttemptCount: 0
|
|
21940
21941
|
}));
|
|
21941
21942
|
runtimeState.set(route.path, { upstreams });
|
|
21942
21943
|
if (route.failover.healthCheck?.enabled) {
|
|
@@ -22511,6 +22512,12 @@ var init_selector = __esm(() => {
|
|
|
22511
22512
|
});
|
|
22512
22513
|
|
|
22513
22514
|
// src/worker/upstream/filter.ts
|
|
22515
|
+
function calculateBackoffInterval(baseIntervalMs, attemptCount) {
|
|
22516
|
+
const backoffMultiplier = Math.pow(2, attemptCount);
|
|
22517
|
+
const intervalWithBackoff = baseIntervalMs * backoffMultiplier;
|
|
22518
|
+
const cappedInterval = Math.min(intervalWithBackoff, MAX_RECOVERY_INTERVAL_MS);
|
|
22519
|
+
return addJitter(cappedInterval, 0.2);
|
|
22520
|
+
}
|
|
22514
22521
|
function canAttemptUpstream(upstream, recoveryIntervalMs) {
|
|
22515
22522
|
if (upstream.status === "HEALTHY") {
|
|
22516
22523
|
return { canAttempt: true, shouldTransitionToHalfOpen: false };
|
|
@@ -22520,14 +22527,17 @@ function canAttemptUpstream(upstream, recoveryIntervalMs) {
|
|
|
22520
22527
|
}
|
|
22521
22528
|
if (upstream.status === "UNHEALTHY" && upstream.lastFailureTime !== undefined) {
|
|
22522
22529
|
const elapsed = Date.now() - upstream.lastFailureTime;
|
|
22523
|
-
const jitteredInterval =
|
|
22530
|
+
const jitteredInterval = calculateBackoffInterval(recoveryIntervalMs, upstream.recoveryAttemptCount);
|
|
22524
22531
|
if (elapsed >= jitteredInterval) {
|
|
22525
22532
|
return { canAttempt: true, shouldTransitionToHalfOpen: true };
|
|
22526
22533
|
}
|
|
22527
22534
|
}
|
|
22528
22535
|
return { canAttempt: false, shouldTransitionToHalfOpen: false };
|
|
22529
22536
|
}
|
|
22530
|
-
var
|
|
22537
|
+
var MAX_RECOVERY_INTERVAL_MS;
|
|
22538
|
+
var init_filter = __esm(() => {
|
|
22539
|
+
MAX_RECOVERY_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
22540
|
+
});
|
|
22531
22541
|
|
|
22532
22542
|
// src/worker/upstream/priority-group.ts
|
|
22533
22543
|
class PriorityGroup {
|
|
@@ -26730,7 +26740,8 @@ async function handleRequest(req, config, upstreamSelector = selectUpstream) {
|
|
|
26730
26740
|
status: "HEALTHY",
|
|
26731
26741
|
lastFailureTime: undefined,
|
|
26732
26742
|
consecutiveFailures: 0,
|
|
26733
|
-
consecutiveSuccesses: 0
|
|
26743
|
+
consecutiveSuccesses: 0,
|
|
26744
|
+
recoveryAttemptCount: 0
|
|
26734
26745
|
};
|
|
26735
26746
|
});
|
|
26736
26747
|
const selectedUpstream = upstreamSelector(staticUpstreams, route, expressionContext);
|
|
@@ -26839,6 +26850,7 @@ async function handleRequest(req, config, upstreamSelector = selectUpstream) {
|
|
|
26839
26850
|
selectedUpstream.status = "HEALTHY";
|
|
26840
26851
|
selectedUpstream.lastFailureTime = undefined;
|
|
26841
26852
|
selectedUpstream.consecutiveSuccesses = 0;
|
|
26853
|
+
selectedUpstream.recoveryAttemptCount = 0;
|
|
26842
26854
|
activateSlowStart(selectedUpstream, route);
|
|
26843
26855
|
logger.info({
|
|
26844
26856
|
target: selectedUpstream.target,
|
|
@@ -26880,6 +26892,7 @@ async function handleRequest(req, config, upstreamSelector = selectUpstream) {
|
|
|
26880
26892
|
if (selectedUpstream.status === "HALF_OPEN") {
|
|
26881
26893
|
selectedUpstream.status = "UNHEALTHY";
|
|
26882
26894
|
selectedUpstream.lastFailureTime = Date.now();
|
|
26895
|
+
selectedUpstream.recoveryAttemptCount++;
|
|
26883
26896
|
deactivateSlowStart(selectedUpstream);
|
|
26884
26897
|
logger.warn({
|
|
26885
26898
|
target: selectedUpstream.target,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffusion/bungee-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Bungee reverse proxy core engine",
|
|
5
5
|
"main": "dist/master.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "bun test"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@jeffusion/bungee-types": "^3.2.
|
|
13
|
+
"@jeffusion/bungee-types": "^3.2.1",
|
|
14
14
|
"winston": "^3.17.0",
|
|
15
15
|
"winston-daily-rotate-file": "^5.0.0",
|
|
16
16
|
"lodash-es": "^4.17.21",
|