0
0
Fork 0

Execute PushUpdateWorker only for accounts who uses StreamingAPI just now. (#3278)

* Add redis key "subscribed:timeline:#{account.id}" to indicate active streaming API listeners exists.

* Add endpoint for notification only stream.

* Run PushUpdateWorker only for users uses Streaming API now.

* Move close hander streamTo(Http/Ws) -> stream(Http/Ws)End (Deal with #3370)

* Add stream type for stream start log message.
This commit is contained in:
Clworld 2017-06-04 03:50:53 +09:00 committed by Eugen Rochko
parent 8a597f0138
commit dab8fc4584
2 changed files with 49 additions and 9 deletions

View file

@ -34,7 +34,7 @@ class FeedManager
trim(timeline_type, account.id)
end
PushUpdateWorker.perform_async(account.id, status.id)
PushUpdateWorker.perform_async(account.id, status.id) if push_update_required?(timeline_type, account.id)
end
def trim(type, account_id)
@ -43,6 +43,10 @@ class FeedManager
redis.zremrangebyscore(key(type, account_id), '-inf', "(#{last.last}")
end
def push_update_required?(timeline_type, account_id)
timeline_type != :home || redis.get("subscribed:timeline:#{account_id}").present?
end
def merge_into_timeline(from_account, into_account)
timeline_key = key(:home, into_account.id)
query = from_account.statuses.limit(FeedManager::MAX_ITEMS / 4)