support per-doc pubsub channels

This commit is contained in:
Brian Gough 2019-07-22 12:20:06 +01:00
parent 0c8922c769
commit c9ccf62d71
2 changed files with 9 additions and 2 deletions

View file

@ -36,4 +36,9 @@ module.exports = RealTimeRedisManager =
# create a unique message id using a counter # create a unique message id using a counter
message_id = "doc:#{HOST}:#{RND}-#{COUNT++}" message_id = "doc:#{HOST}:#{RND}-#{COUNT++}"
data?._id = message_id data?._id = message_id
pubsubClient.publish "applied-ops", JSON.stringify(data) # publish on separate channels for individual projects and docs when
# configured (needs realtime to be configured for this too).
if Settings.publishOnIndividualChannels and data.doc_id?
pubsubClient.publish "applied-ops:#{data.doc_id}", JSON.stringify(data)
else
pubsubClient.publish "applied-ops", JSON.stringify(data)

View file

@ -92,3 +92,5 @@ module.exports =
sentry: sentry:
dsn: process.env.SENTRY_DSN dsn: process.env.SENTRY_DSN
publishOnIndividualChannels: process.env['PUBLISH_ON_INDIVIDUAL_CHANNELS'] or false