Merge remote-tracking branch 'parent/main' into kb-merge-231010

This commit is contained in:
KMY 2023-10-10 22:17:15 +09:00
commit 80498c8377
45 changed files with 289 additions and 251 deletions

View file

@ -256,7 +256,7 @@ const startServer = async () => {
CHANNEL_NAMES.forEach(( channel ) => {
connectedChannels.set({ type: 'websocket', channel }, 0);
connectedChannels.set({ type: 'eventsource', channel }, 0);
})
});
// Prime the counters so that we don't loose metrics between restarts.
// Unfortunately counters don't support the set() API, so instead I'm using
@ -1363,7 +1363,7 @@ const startServer = async () => {
log.verbose(request.requestId, 'Subscription error:', err.toString());
socket.send(JSON.stringify({ error: err.toString() }));
});
}
};
const removeSubscription = (subscriptions, channelIds, request) => {
@ -1383,7 +1383,7 @@ const startServer = async () => {
subscription.stopHeartbeat();
delete subscriptions[channelIds.join(';')];
}
};
/**
* @param {WebSocketSession} session
@ -1403,7 +1403,7 @@ const startServer = async () => {
socket.send(JSON.stringify({ error: "Error unsubscribing from channel" }));
}
});
}
};
/**
* @param {WebSocketSession} session
@ -1481,7 +1481,7 @@ const startServer = async () => {
const subscriptions = Object.keys(session.subscriptions);
subscriptions.forEach(channelIds => {
removeSubscription(session.subscriptions, channelIds.split(';'), req)
removeSubscription(session.subscriptions, channelIds.split(';'), req);
});
// Decrement the metrics for connected clients: