mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 00:30:57 +01:00
Add tracking of delay to streaming API
This commit is contained in:
parent
6cdcac1396
commit
fb6aa7ad5c
3 changed files with 13 additions and 6 deletions
|
@ -123,7 +123,7 @@ const Modal = React.createClass({
|
|||
window.addEventListener('keyup', this._listener);
|
||||
},
|
||||
|
||||
componentDidUnmount () {
|
||||
componentWillUnmount () {
|
||||
window.removeEventListener('keyup', this._listener);
|
||||
},
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ class FeedManager
|
|||
end
|
||||
|
||||
def broadcast(timeline_id, options = {})
|
||||
options[:queued_at] = (Time.now.to_f * 1000.0).to_i
|
||||
ActionCable.server.broadcast("timeline:#{timeline_id}", options)
|
||||
end
|
||||
|
||||
|
|
|
@ -101,7 +101,15 @@ const streamFrom = (redisClient, id, req, output, needsFiltering = false) => {
|
|||
log.verbose(`Starting stream from ${id} for ${req.accountId}`)
|
||||
|
||||
redisClient.on('message', (channel, message) => {
|
||||
const { event, payload } = JSON.parse(message)
|
||||
const { event, payload, queued_at } = JSON.parse(message)
|
||||
|
||||
const transmit = () => {
|
||||
const now = new Date().getTime()
|
||||
const delta = now - queued_at;
|
||||
|
||||
log.silly(`Transmitting for ${req.accountId}: ${event} ${payload} Delay: ${delta}ms`)
|
||||
output(event, payload)
|
||||
}
|
||||
|
||||
// Only messages that may require filtering are statuses, since notifications
|
||||
// are already personalized and deletes do not matter
|
||||
|
@ -127,13 +135,11 @@ const streamFrom = (redisClient, id, req, output, needsFiltering = false) => {
|
|||
return
|
||||
}
|
||||
|
||||
log.silly(`Transmitting for ${req.accountId}: ${event} ${payload}`)
|
||||
output(event, payload)
|
||||
transmit()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
log.silly(`Transmitting for ${req.accountId}: ${event} ${payload}`)
|
||||
output(event, payload)
|
||||
transmit()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue