aboutsummaryrefslogblamecommitdiffstats
path: root/lib/active_job/queue_adapters/inline_adapter.rb
blob: 8b82d7c25a68dda1efe4bf4a1d764a0c943a7c04 (plain) (tree)
1
2
3
4
5
6
7
8
9



                       
                               
                                          
           
 
                                             

                       
                                                  
                                             
                                              

                                                                                 


               


         
   
module ActiveJob
  module QueueAdapters
    class InlineAdapter
      class << self
        def enqueue(job, *args)
          job.new.perform_with_hooks *args
        end

        def enqueue_at(job, timestamp, *args)
          Thread.new do
            begin
              interval = Time.now.to_f - timestamp
              sleep(interval) if interval > 0
              job.new.perform_with_hooks *args
            rescue => e
              ActiveJob::Base.logger.info "Error performing #{job}: #{e.message}"
            end
          end
        end
      end
    end
  end
end