diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-12 21:12:19 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-12 21:12:19 +0100 |
commit | 668013265c3153383088d9dd53970ae837c1d405 (patch) | |
tree | e2794433dc0f4548d33c505e5d75383526425efa | |
parent | 908fcf83c6a2df34769f04c98fbe0edf31f6959f (diff) |
Restoring old async behaviour of thread resolving as it proved to be more robust
-rw-r--r-- | app/services/process_feed_service.rb | 13 | ||||
-rw-r--r-- | app/workers/pubsubhubbub/delivery_worker.rb | 2 | ||||
-rw-r--r-- | app/workers/thread_resolve_worker.rb | 15 |
3 files changed, 17 insertions, 13 deletions
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index a525bc321..3860a3504 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -122,7 +122,7 @@ class ProcessFeedService < BaseService def find_or_resolve_status(parent, uri, url) status = find_status(uri) - ResolveThread.new.call(parent, url) if status.nil? + ThreadResolveWorker.perform_async(parent.id, url) if status.nil? status end @@ -243,15 +243,4 @@ class ProcessFeedService < BaseService "#{username}@#{domain}" 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 diff --git a/app/workers/pubsubhubbub/delivery_worker.rb b/app/workers/pubsubhubbub/delivery_worker.rb index 20c72ce24..35bf7b2f0 100644 --- a/app/workers/pubsubhubbub/delivery_worker.rb +++ b/app/workers/pubsubhubbub/delivery_worker.rb @@ -4,7 +4,7 @@ class Pubsubhubbub::DeliveryWorker include Sidekiq::Worker include RoutingHelper - sidekiq_options queue: 'push' + sidekiq_options queue: 'push', retry: 5 def perform(subscription_id, payload) subscription = Subscription.find(subscription_id) diff --git a/app/workers/thread_resolve_worker.rb b/app/workers/thread_resolve_worker.rb new file mode 100644 index 000000000..84eae73be --- /dev/null +++ b/app/workers/thread_resolve_worker.rb @@ -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 |