Restoring old async behaviour of thread resolving as it proved to be more robust
This commit is contained in:
		
							parent
							
								
									d0a9cbbd10
								
							
						
					
					
						commit
						b7c2c5d81d
					
				
					 3 changed files with 17 additions and 13 deletions
				
			
		| 
						 | 
					@ -122,7 +122,7 @@ class ProcessFeedService < BaseService
 | 
				
			||||||
    def find_or_resolve_status(parent, uri, url)
 | 
					    def find_or_resolve_status(parent, uri, url)
 | 
				
			||||||
      status = find_status(uri)
 | 
					      status = find_status(uri)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      ResolveThread.new.call(parent, url) if status.nil?
 | 
					      ThreadResolveWorker.perform_async(parent.id, url) if status.nil?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      status
 | 
					      status
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					@ -243,15 +243,4 @@ class ProcessFeedService < BaseService
 | 
				
			||||||
      "#{username}@#{domain}"
 | 
					      "#{username}@#{domain}"
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  class ResolveThread
 | 
					 | 
				
			||||||
    def call(child_status, parent_url)
 | 
					 | 
				
			||||||
      parent_status = FetchRemoteStatusService.new.call(parent_url)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      return if parent_status.nil?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      child_status.thread = parent_status
 | 
					 | 
				
			||||||
      child_status.save!
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@ class Pubsubhubbub::DeliveryWorker
 | 
				
			||||||
  include Sidekiq::Worker
 | 
					  include Sidekiq::Worker
 | 
				
			||||||
  include RoutingHelper
 | 
					  include RoutingHelper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sidekiq_options queue: 'push'
 | 
					  sidekiq_options queue: 'push', retry: 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def perform(subscription_id, payload)
 | 
					  def perform(subscription_id, payload)
 | 
				
			||||||
    subscription = Subscription.find(subscription_id)
 | 
					    subscription = Subscription.find(subscription_id)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								app/workers/thread_resolve_worker.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/workers/thread_resolve_worker.rb
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,15 @@
 | 
				
			||||||
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ThreadResolveWorker
 | 
				
			||||||
 | 
					  include Sidekiq::Worker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def perform(child_status_id, parent_url)
 | 
				
			||||||
 | 
					    child_status  = Status.find(child_status_id)
 | 
				
			||||||
 | 
					    parent_status = FetchRemoteStatusService.new.call(parent_url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return if parent_status.nil?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    child_status.thread = parent_status
 | 
				
			||||||
 | 
					    child_status.save!
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
		Loading…
	
		Reference in a new issue