[perf] WebsocketLoadBalancer: move back to a sync loop for msg fan out

This commit is contained in:
Jakob Ackermann 2020-02-26 10:57:14 +01:00 committed by Jakob Ackermann
parent a70c1e1fa2
commit ce4f9148c3

View file

@ -7,7 +7,6 @@ HealthCheckManager = require "./HealthCheckManager"
RoomManager = require "./RoomManager" RoomManager = require "./RoomManager"
ChannelManager = require "./ChannelManager" ChannelManager = require "./ChannelManager"
ConnectedUsersManager = require "./ConnectedUsersManager" ConnectedUsersManager = require "./ConnectedUsersManager"
Async = require 'async'
RESTRICTED_USER_MESSAGE_TYPE_PASS_LIST = [ RESTRICTED_USER_MESSAGE_TYPE_PASS_LIST = [
'connectionAccepted', 'connectionAccepted',
@ -96,17 +95,10 @@ module.exports = WebsocketLoadBalancer =
socketIoClients: (client.id for client in clientList) socketIoClients: (client.id for client in clientList)
}, "distributing event to clients" }, "distributing event to clients"
seen = {} seen = {}
# Send the messages to clients async, don't wait for them all to finish for client in clientList
Async.eachLimit clientList
, 2
, (client, cb) ->
if !seen[client.id] if !seen[client.id]
seen[client.id] = true seen[client.id] = true
client.emit(message.message, message.payload...) client.emit(message.message, message.payload...)
cb()
, (err) ->
if err?
logger.err {err, message}, "Error sending message to clients"
else if message.health_check? else if message.health_check?
logger.debug {message}, "got health check message in editor events channel" logger.debug {message}, "got health check message in editor events channel"
HealthCheckManager.check channel, message.key HealthCheckManager.check channel, message.key