feat(connection): add HTTP tunnel
This commit is contained in:
1 parent
91c77e53c4
commit
b80f3e8088
21 files changed
+1515
-123
No files matched your search
@@ -34,6 +34,41 @@ describe("connectionAttemptTimeout", () => {
|
||||
expect(connectionAttemptTimeoutMs({ db_type: "access", connect_timeout_secs: 45, transport_layers: [] })).toBe(47_000);
|
||||
});
|
||||
|
||||
it("includes HTTP tunnel connection timeout values", () => {
|
||||
expect(
|
||||
connectionAttemptTimeoutMs({
|
||||
db_type: "mysql",
|
||||
connect_timeout_secs: 5,
|
||||
transport_layers: [
|
||||
{
|
||||
type: "http_tunnel",
|
||||
id: "http",
|
||||
url: "https://dbx.example.com/dbx_tunnel.php",
|
||||
connect_timeout_secs: 25,
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toBe(27_000);
|
||||
});
|
||||
|
||||
it("ignores disabled transport layer timeouts", () => {
|
||||
expect(
|
||||
connectionAttemptTimeoutMs({
|
||||
db_type: "mysql",
|
||||
connect_timeout_secs: 5,
|
||||
transport_layers: [
|
||||
{
|
||||
type: "http_tunnel",
|
||||
id: "http",
|
||||
enabled: false,
|
||||
url: "https://dbx.example.com/dbx_tunnel.php",
|
||||
connect_timeout_secs: 60,
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toBe(7_000);
|
||||
});
|
||||
|
||||
it("adds late original database errors to timeout messages", () => {
|
||||
const timeoutMessage = connectionAttemptTimeoutMessage(7_000);
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ export function connectionAttemptTimeoutMs(config: Pick<ConnectionConfig, "conne
|
||||
const agentMinTimeoutSecs = config.db_type === "access" ? ACCESS_AGENT_MIN_CONNECT_TIMEOUT_SECS : AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS;
|
||||
const timeouts = [DRIVER_STARTUP_FLOOR_TYPES.has(config.db_type as DatabaseType) ? Math.max(baseTimeoutSecs, agentMinTimeoutSecs) : baseTimeoutSecs];
|
||||
for (const layer of config.transport_layers ?? []) {
|
||||
if (layer.type === "ssh") {
|
||||
if (layer.enabled === false) continue;
|
||||
if (layer.type === "ssh" || layer.type === "http_tunnel") {
|
||||
timeouts.push(positiveSeconds(layer.connect_timeout_secs, DEFAULT_CONNECT_TIMEOUT_SECS));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user