Files
discord-decomp/modules/gateway/AltGatewayTracker.tsx
T
2026-11-01 12:12:55 +02:00

43 lines
1.1 KiB
TypeScript

// Metro module 12698 (f12699).
import getCachedUseAltGateway_native from "./getCachedUseAltGateway.native";
const GATEWAY_ALT_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ALT_ENDPOINT;
let c8748_1 = getCachedUseAltGateway_native();
class AltGatewayTracker {
constructor() {
return {
__proto__: new.target.prototype,
failures: 0,
fallbackTripped: false
};
}
shouldUseAltGateway() {
const fallbackTripped = this.fallbackTripped;
return (fallbackTripped ? !fallbackTripped : GATEWAY_ALT_ENDPOINT != null) && c8748_1;
}
isAssignedToAltGateway() {
return GATEWAY_ALT_ENDPOINT != null && c8748_1;
}
getDidFallBack() {
return this.fallbackTripped;
}
getAltGatewayUrl() {
return this.shouldUseAltGateway() ? GATEWAY_ALT_ENDPOINT : null;
}
recordSuccess() {
this.failures = 0;
}
recordFailure() {
if (this.shouldUseAltGateway()) {
this.failures = this.failures + 1;
if (this.failures >= 3) {
this.fallbackTripped = true;
}
}
}
reset() {
this.failures = 0;
this.fallbackTripped = false;
}
}
export default AltGatewayTracker;