Просмотр исходного кода

simplify redis continual traffic

we can't send double health check events to same redis, it causes
health check duplicate errors. Commit just sends health check data to
pub sub pair and then sends non health check traffic to cluster to keep
the connection open
Henry Oswald 7 лет назад
Родитель
Сommit
520857cf7a
1 измененных файлов с 7 добавлено и 9 удалено
  1. 7 9
      services/real-time/app.coffee

+ 7 - 9
services/real-time/app.coffee

@@ -134,20 +134,18 @@ if Settings.forceDrainMsDelay?
 if Settings.continualPubsubTraffic
 	console.log "continualPubsubTraffic enabled"
 
-	redisClients = [redis.createClient(Settings.redis.documentupdater), redis.createClient(Settings.redis.pubsub)]
+	pubsubClient = redis.createClient(Settings.redis.pubsub)
+	clusterClient = redis.createClient(Settings.redis.websessions)
 
 	publishJob = (channel, callback)->
 		checker = new HealthCheckManager(channel)
 		logger.debug {channel:channel}, "sending pub to keep connection alive"
 		json = JSON.stringify({health_check:true, key: checker.id, date: new Date().toString()})
-		jobs = _.map redisClients, (checkRclient)->
-			return (cb)->
-				checkRclient.publish channel, json, (err)->
-					if err?
-						logger.err {err, channel}, "error publishing pubsub traffic to redis"
-					return cb(err)
-
-		async.series jobs, callback
+		pubsubClient.publish channel, json, (err)->
+			if err?
+				logger.err {err, channel}, "error publishing pubsub traffic to redis"
+			clusterClient.publish "cluster-continual-traffic", {keep: "alive"}, callback
+
 
 	runPubSubTraffic = ->
 		async.map ["applied-ops", "editor-events"], publishJob, (err)->