mirror of
https://github.com/fosrl/pangolin.git
synced 2026-04-03 00:16:39 +00:00
Prevent increase in writes on reconnect
This commit is contained in:
@@ -77,7 +77,8 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
|
|||||||
const [targetCheck] = await db
|
const [targetCheck] = await db
|
||||||
.select({
|
.select({
|
||||||
targetId: targets.targetId,
|
targetId: targets.targetId,
|
||||||
siteId: targets.siteId
|
siteId: targets.siteId,
|
||||||
|
hcStatus: targetHealthCheck.hcHealth
|
||||||
})
|
})
|
||||||
.from(targets)
|
.from(targets)
|
||||||
.innerJoin(
|
.innerJoin(
|
||||||
@@ -85,6 +86,7 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
|
|||||||
eq(targets.resourceId, resources.resourceId)
|
eq(targets.resourceId, resources.resourceId)
|
||||||
)
|
)
|
||||||
.innerJoin(sites, eq(targets.siteId, sites.siteId))
|
.innerJoin(sites, eq(targets.siteId, sites.siteId))
|
||||||
|
.innerJoin(targetHealthCheck, eq(targets.targetId, targetHealthCheck.targetId))
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(targets.targetId, targetIdNum),
|
eq(targets.targetId, targetIdNum),
|
||||||
@@ -101,6 +103,14 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if the status has changed
|
||||||
|
if (targetCheck.hcStatus === healthStatus.status) {
|
||||||
|
logger.debug(
|
||||||
|
`Health status for target ${targetId} is already ${healthStatus.status}, skipping update`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the target's health status in the database
|
// Update the target's health status in the database
|
||||||
await db
|
await db
|
||||||
.update(targetHealthCheck)
|
.update(targetHealthCheck)
|
||||||
|
|||||||
Reference in New Issue
Block a user