mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-17 21:01:53 +00:00
refactor: tighten ws batch typing and queue cleanup logging
This commit is contained in:
committed by
GitHub
parent
45158ff45b
commit
b66140bfd2
@@ -70,8 +70,13 @@ class RedisRebuildQueue {
|
||||
);
|
||||
} catch (err) {
|
||||
await redis
|
||||
?.srem(QUEUED_SET_KEY, `${job.type}:${job.id}`)
|
||||
.catch(() => undefined);
|
||||
.srem(QUEUED_SET_KEY, `${job.type}:${job.id}`)
|
||||
.catch((cleanupErr) =>
|
||||
logger.warn(
|
||||
`Rebuild queue: failed to cleanup dedupe key for ${job.type}:${job.id} after enqueue failure:`,
|
||||
cleanupErr
|
||||
)
|
||||
);
|
||||
logger.error(
|
||||
`Rebuild queue: failed to enqueue ${job.type}:${job.id}:`,
|
||||
err
|
||||
@@ -138,7 +143,12 @@ class RedisRebuildQueue {
|
||||
// can be re-queued while this one is in progress.
|
||||
await redis
|
||||
.srem(QUEUED_SET_KEY, `${job.type}:${job.id}`)
|
||||
.catch(() => undefined);
|
||||
.catch((cleanupErr) =>
|
||||
logger.warn(
|
||||
`Rebuild queue: failed to remove dedupe key for ${job.type}:${job.id} on dequeue:`,
|
||||
cleanupErr
|
||||
)
|
||||
);
|
||||
|
||||
logger.debug(
|
||||
`Rebuild queue: processing ${job.type}:${job.id}`
|
||||
|
||||
@@ -188,7 +188,7 @@ const wss: WebSocketServer = new WebSocketServer({ noServer: true });
|
||||
const NODE_ID = uuidv4();
|
||||
const REDIS_CHANNEL = "websocket_messages";
|
||||
const REDIS_DIRECT_BATCH_SIZE = 250;
|
||||
const REDIS_DIRECT_FLUSH_MS = 10;
|
||||
const REDIS_DIRECT_FLUSH_INTERVAL_MS = 10;
|
||||
|
||||
// Client tracking map (local to this node)
|
||||
const connectedClients: Map<string, AuthenticatedWebSocket[]> = new Map();
|
||||
@@ -234,10 +234,6 @@ const publishDirectBatch = async (
|
||||
targetClientId: entry.targetClientId,
|
||||
message: entry.message
|
||||
})),
|
||||
message: {
|
||||
type: "batch",
|
||||
data: {}
|
||||
},
|
||||
fromNodeId: NODE_ID
|
||||
};
|
||||
|
||||
@@ -289,7 +285,7 @@ const enqueueRedisDirectMessage = async (
|
||||
if (!redisDirectFlushTimer) {
|
||||
redisDirectFlushTimer = setTimeout(() => {
|
||||
void flushPendingRedisDirectMessages();
|
||||
}, REDIS_DIRECT_FLUSH_MS);
|
||||
}, REDIS_DIRECT_FLUSH_INTERVAL_MS);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user