mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-07 06:39:52 +02:00
Fix ping function
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
|||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { recordPing } from "@server/routers/newt/pingAccumulator";
|
import { recordSitePing } from "@server/routers/newt/pingAccumulator";
|
||||||
import { validateNewtSessionToken } from "@server/auth/sessions/newt";
|
import { validateNewtSessionToken } from "@server/auth/sessions/newt";
|
||||||
import { validateOlmSessionToken } from "@server/auth/sessions/olm";
|
import { validateOlmSessionToken } from "@server/auth/sessions/olm";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
@@ -1063,7 +1063,7 @@ const setupConnection = async (
|
|||||||
// pending pings in a single batched UPDATE every ~10s, which
|
// pending pings in a single batched UPDATE every ~10s, which
|
||||||
// prevents connection pool exhaustion under load (especially
|
// prevents connection pool exhaustion under load (especially
|
||||||
// with cross-region latency to the database).
|
// with cross-region latency to the database).
|
||||||
recordPing(newtClient.siteId);
|
recordSitePing(newtClient.siteId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Newt } from "@server/db";
|
|||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { sendNewtSyncMessage } from "./sync";
|
import { sendNewtSyncMessage } from "./sync";
|
||||||
import { recordPing } from "./pingAccumulator";
|
import { recordSitePing } from "./pingAccumulator";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles ping messages from newt clients.
|
* Handles ping messages from newt clients.
|
||||||
@@ -35,7 +35,7 @@ export const handleNewtPingMessage: MessageHandler = async (context) => {
|
|||||||
// batched UPDATE instead of one query per ping. This prevents
|
// batched UPDATE instead of one query per ping. This prevents
|
||||||
// connection pool exhaustion under load, especially with
|
// connection pool exhaustion under load, especially with
|
||||||
// cross-region latency to the database.
|
// cross-region latency to the database.
|
||||||
recordPing(newt.siteId);
|
recordSitePing(newt.siteId);
|
||||||
|
|
||||||
// Check config version and sync if stale.
|
// Check config version and sync if stale.
|
||||||
const configVersion = await getClientConfigVersion(newt.newtId);
|
const configVersion = await getClientConfigVersion(newt.newtId);
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ export function recordSitePing(siteId: number): void {
|
|||||||
pendingSitePings.set(siteId, now);
|
pendingSitePings.set(siteId, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated Use `recordSitePing` instead. Alias kept for existing call-sites. */
|
|
||||||
export const recordPing = recordSitePing;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record a ping for an OLM client. Batches the `clients` table update
|
* Record a ping for an OLM client. Batches the `clients` table update
|
||||||
* (`online`, `lastPing`, `archived`) and, when `olmArchived` is true,
|
* (`online`, `lastPing`, `archived`) and, when `olmArchived` is true,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { recordPing } from "@server/routers/newt/pingAccumulator";
|
import { recordSitePing } from "@server/routers/newt/pingAccumulator";
|
||||||
import { validateNewtSessionToken } from "@server/auth/sessions/newt";
|
import { validateNewtSessionToken } from "@server/auth/sessions/newt";
|
||||||
import { validateOlmSessionToken } from "@server/auth/sessions/olm";
|
import { validateOlmSessionToken } from "@server/auth/sessions/olm";
|
||||||
import { messageHandlers } from "./messageHandlers";
|
import { messageHandlers } from "./messageHandlers";
|
||||||
@@ -424,7 +424,7 @@ const setupConnection = async (
|
|||||||
// pending pings in a single batched UPDATE every ~10s, which
|
// pending pings in a single batched UPDATE every ~10s, which
|
||||||
// prevents connection pool exhaustion under load (especially
|
// prevents connection pool exhaustion under load (especially
|
||||||
// with cross-region latency to the database).
|
// with cross-region latency to the database).
|
||||||
recordPing(newtClient.siteId);
|
recordSitePing(newtClient.siteId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user