refactor(gateway): cache hook proxy config in runtime state

This commit is contained in:
Peter Steinberger
2026-03-12 21:43:36 +00:00
parent 1d986f1c01
commit 445ff0242e
5 changed files with 34 additions and 15 deletions

View File

@@ -107,6 +107,7 @@ import {
incrementPresenceVersion,
refreshGatewayHealthSnapshot,
} from "./server/health-state.js";
import { resolveHookClientIpConfig } from "./server/hooks.js";
import { createReadinessChecker } from "./server/readiness.js";
import { loadGatewayTlsRuntime } from "./server/tls.js";
import {
@@ -511,6 +512,7 @@ export async function startGatewayServer(
tailscaleMode,
} = runtimeConfig;
let hooksConfig = runtimeConfig.hooksConfig;
let hookClientIpConfig = resolveHookClientIpConfig(cfgAtStart);
const canvasHostEnabled = runtimeConfig.canvasHostEnabled;
// Create auth rate limiters used by connect/auth flows.
@@ -613,6 +615,7 @@ export async function startGatewayServer(
rateLimiter: authRateLimiter,
gatewayTls,
hooksConfig: () => hooksConfig,
getHookClientIpConfig: () => hookClientIpConfig,
pluginRegistry,
deps,
canvasRuntime,
@@ -954,6 +957,7 @@ export async function startGatewayServer(
broadcast,
getState: () => ({
hooksConfig,
hookClientIpConfig,
heartbeatRunner,
cronState,
browserControl,
@@ -961,6 +965,7 @@ export async function startGatewayServer(
}),
setState: (nextState) => {
hooksConfig = nextState.hooksConfig;
hookClientIpConfig = nextState.hookClientIpConfig;
heartbeatRunner = nextState.heartbeatRunner;
cronState = nextState.cronState;
cron = cronState.cron;