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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user