We're going to want these nice helper methods, lets share them with a parent class that matches Rails 5 practices (application level abstraction)
This commit is contained in:
		
							parent
							
								
									825da6c758
								
							
						
					
					
						commit
						192f855952
					
				
					 2 changed files with 7 additions and 2 deletions
				
			
		
							
								
								
									
										5
									
								
								app/workers/application_worker.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/workers/application_worker.rb
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
class ApplicationWorker
 | 
			
		||||
  def info(message)
 | 
			
		||||
    Rails.logger.info("#{self.class.name} - #{message}")
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class DistributionWorker
 | 
			
		||||
class DistributionWorker < ApplicationWorker
 | 
			
		||||
  include Sidekiq::Worker
 | 
			
		||||
 | 
			
		||||
  def perform(status_id)
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +9,6 @@ class DistributionWorker
 | 
			
		|||
    FanOutOnWriteService.new.call(status)
 | 
			
		||||
    WarmCacheService.new.call(status)
 | 
			
		||||
  rescue ActiveRecord::RecordNotFound
 | 
			
		||||
    true
 | 
			
		||||
    info("Couldn't find the status")
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue